mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 08:07:28 +00:00
+27









deltanedas
slarticodefast
Nemanja
Vasilis
plykiya
deltanedas
Killerqu00
Brandon Hu
Zachary Yona
Zachary Yona
Plykiya
PJBot
Alzore
Kara
EmoGarbage404
Ubaser
Token
Cojoke
LeoSantich
nikthechampiongr
pigeonpeas
Ed
PoorMansDreams
IgorAnt028
NotSoDamn
Errant
DrSmugleaf
Velcroboy
Jeff
themias
Eris
FATFSAAM2
to4no_fix
Mervill
Nim
IProduceWidgets
SlamBamActionman
f941121384
* uncomment grappling gun * Remove rest of Geras files (#30912) remove remaining geras stuff * tweak(AgeRequirement): Make the requiredAge more sensible (#30913) * chrore(ageRequirement): fix grammar. atleast -> at least (#30914) * Minor sprite fix to inhand med hardsuits and HoS turtleneck jumpsuit (#30918) * Fixes inhand hardsuit cross color from https://github.com/space-wizards/space-station-14/issues/26516#issue-2213917971 * Fixed HoS Turtle not covering all butt pixels --------- Co-authored-by: Zachary Yona <magicalusf@gmail.com> * Add execution component to all energy sword weapons (#30909) Co-authored-by: plykiya <plykiya@protonmail.com> * Automatic changelog update * chore(grammar): correct some mistakes (#30916) * Add diamond mining drills, buff regular mining drills (#30814) * why do I have to change so much just to add drills * diamon * Automatic changelog update * give trash a reusable entity table (#30921) * Contraband marking & examining (#28688) * System & loc strings * pass over syndie contraband * fixes * grand theft pass * contrabandexamine -> contraband * examine text generation update * all composition parents necessary * bring back minor contra so it has a less confusing message * minor * weapon pass * jumpsuit pass * feet pass * AUUUUUUUUUGHHHHHHHHHHHHHHHHHH * head * AUUUUGH * ear * belt * back * fix * bro * rename for more clarity * do da review * add cvar for contraband examine --------- Co-authored-by: EmoGarbage404 <retron404@gmail.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> * Automatic changelog update * Automatic changelog update * Removes variant cube migration (#30934) add * First Review Pass Contraband Fixes (#30930) * First pass contra fix * bam * More * Security crates are now marked as security restricted * Syndicate raid suit is contra * damn I forgot gatfruit * Add conducting gloves to the maintenance loot table (#30904) * add * lower weight * Fix DoDrop to DropNextTo in container cases (#30911) * Fix DoDrop to DropNextTo in container cases DoDrop is too heavy to calculation. In any other case we should use alternatives, for example DropNextTo helper method * codestyle change * Fix Reagent Fire Stacks (#30766) * Fix Reagent Fire Stacks * Comments on code * little nicer wording? * Lines 88 and 89, updated 'narsie' and 'ratvar' to 'Nar'Sie' and Ratva… (#30954) Lines 88 and 89, updated 'narsie' and 'ratvar' to 'Nar'Sie' and Ratvar, per issue #30719. * Automatic changelog update * Fix permission check for whitelists in player panel (#30948) * Automatic changelog update * Grey mantle in winterdrobe (#29774) * add the mantle * fix a few things * fix merge conflict stuff, remove from winterdrobe and lathe. * Add mantle to loadouts (20 hour requirement) * Automatic changelog update * Sliceable doAfter (#30824) * init * wtf git * Automatic changelog update * Add capfruit, a gatfruit mutation. (#30850) * add base * add fake suffix and flavor fix * address some reviews * parent it * fix test fail * add FoodSequence support and address small review * Automatic changelog update * Fixes the grey mantle (#30971) add the thing i missed * Add keybinds for rotating and flipping objects (#30540) * add keybinds for rotating and flipping objects * no popup for verbs * Automatic changelog update * tweak(Shuttle_honki): Remove DeviceQuantumSpinInverter from honki shuttle. (#30618) * Make the Borgs Names Appear When they Make an Announcement (#30107) * Make the Borgs Names Appear When they Make an Announcement * bwomp * re-order * Use Name instead of metadata * goiup * Automatic changelog update * disable contraband examine * rename our SliceFoodEvent * Throngler Plushie Sprite (#30969) Throngonkler Plush sprite * Fix bug with rotating shelves (#30978) * Main * Update shelfs.yml * Little bug fix * No weather on concrete tiles (#30952) * concrete weather * miss * development build ghostrole lottery changes (#30980) debug ghostrole lottery changes * Automatic changelog update * Add a saline syringe to the combat medical kit (#29954) saline * Automatic changelog update * fix the admin verbs trying to kill players by filling their lungs with plasma (#30991) fix the admin tools trying to kill players by filling their lungs with plasma * Custom Taco & Kebabs - FoodSequence 2 (#30905) * control layer ordering * sprite update * taco! * taco naming gen * fix separator naming * some proto fixes * default naming separation * fix taco naming * rat update * hamsterburger * organs taco * remove from spawners * fixes * fix separators and lemons * Update food-sequence.ftl * randomization offset * fix * kebabs refactor * fix * skewer weapon * Update food_single.yml * Update migration.yml * suppermatter * hamlet centered * hamsburger * Update dead-0.png * 20 -> 4 burger layers max * Update burger.yml * canReact: false * capfruit update * Update burger.yml * Update burger.yml * Update produce.yml * some fixes * Update Resources/Textures/Objects/Consumable/Food/taco.rsi/meta.json Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Update Content.Shared/Nutrition/Components/FoodSequenceStartPointComponent.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Update Content.Shared/Nutrition/Components/FoodSequenceStartPointComponent.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * chicken * Update food-sequence.ftl * documentation * fixes * Update meat.yml * Update meat.yml --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Automatic changelog update * Fix popups not working properly with an eye offset (#30990) * Adds a random smokable spawner (#30870) * Textures to make lamps mappable to East/West. * Adds a random smokable spawner * remove double derma * Increase chance for just basic cig * Update to enitity tables * Tweak values * Remove space --------- Co-authored-by: Jeff <velcroboy333@hotmail.com> * Fix lizards being unable to eat custom burgers (#31005) * Fix lizards being unable to eat custom burgers * ensure tag comp * Automatic changelog update * Sedin (#27110) * Sedin * almost forgot this. * what * Did a few fixes, tried to readd popup * Fix popup, ready for merge * minor change * Generalize seed removal/destruction system, add popups in general. * fix * fix (again) * deadcode is no more * Sedin buff (nerfing the recipe soon) * godont * webedit moment ok listen I had to nuke my setup because my computer was being Dumb As Shit so let me do this ONE webedit * CRIKEY * Revert "CRIKEY" This reverts commit 1c6959ffd9ba8bb1e97ccf2eb0b37b3ff4ec82ee. I was not supposed to commit that >:/ * Alright, it should be good now but I havent tested it * ready for merge/review * prob -> probability * Requested changes nodoc * Review nodoc * documento * thumb up emoji * Automatic changelog update * Adds a Dinky Star Sticker for security officers (#29767) * Sec-Star-TASTIC * fix license * now counts as trash * Sticks to people + wearable * no more sticky * no more sticky * mystery-space * Update Loadout Yaml * Automatic changelog update * tweak(hospital): Reduce diamond stack from 30 to 1 (#31027) * tweak(experiment): Reduce diamond stack from 30 to 1 (#31025) * replace mapped diamond stacks with single * Figurine voicelines (#30865) * initial commit * tweaks to the new voice lines capitalizations of I's and the Y on hos 3 voice lines also changed the captain figuring voice line 2 to something completely different * capitalized one letter man i really suck at capitalization * more capitalization i never thought this pr would need so many changes * changed one comma to a dot * Update Resources/Locale/en-US/datasets/figurines.ftl Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Automatic changelog update * Adding shock collar and electropack (#30529) * Adding shock collar with the new ShockOnTrigger * Cleaning and updating the shock collar * Add StripDelay datafield to ClothingComponent * Adding SelfUnremovableClothingComponent * ShockCollar Update * Correction of the shock collar * Correction of the shock collar 2 * Renaming the DamageSpecifier DataField to Damage * Fixing the damage field in ShockCollar * Cleaning the ShockCollar * Renaming ShockCollar to ClothingNeckShockCollar * Adding ClothingNeckShockCollar as a stealTarget to a thief * Fixing a typo of the sprite path in ClothingNeckShockCollar * Cleaning the ShockOnTriggerComponent * Revision of SelfUnremovableClothing * Adding a ClothingBackpackElectropack * Sprite fix * Code review * Shock Collar sprite update * add commit hash --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> * Automatic changelog update * Greatly improve the usability of the Gas Analyzer. (#30763) * greatly improve how the gas analyzer behaves * don't close the analyzer when the object goes out of range * cleanup * always switch to the device tab when a new device is analyzed * modern api part one * modern api part 2 * modern api part three * file scope namespace * Automatic changelog update * Fix false and true in player-panel.ftl (#31043) Fix false and true in player-panel Add a new True string * Contra Review Passs - Round 2 (#30942) * Contra pass round two * command too * Stamps * oopsied a bracket * Namespace cleanup around Mind Roles (#30965) * namespaces * Comment does not need a semicolon --------- Co-authored-by: Vasilis <vascreeper@yahoo.com> * Contraband Review Pass - The Threequel (#30970) Contraband pass number three * Golden toilet (#31049) * golden toilet * Destructible * sprite * fix * copyright * Automatic changelog update * Salvage Spawners (#31020) * treasure entities and spawners * no more smiles * remove nyano shock collar code * Event scheduler setting tweaks (#31018) tweaks * Automatic changelog update * remove meteor swarms rule for a moment * Revamped Meteor Swarm (#28974) * meteor code and balanced values * Meteor Swarms * Update meteors.yml * Update meteors.yml * HOO! (fix overkill bug and buff space dust) * undo BloodstreamComponent.cs changes * DamageDistribution -> DamageTypes * part 2. * Missing meteor presets (#29044) * add meteors into missing game presets * changes for real * implement code * this too * Meteors now leave behind a bit of ore (#30419) * Meteors that leave behind asteroid ore * bigger offset * Bit more generic * Better defaults * hrm? * I HATE CUSTOM SERIALIZERS * More comments * renamed a variable --------- Co-authored-by: plykiya <plykiya@protonmail.com> * refactor event schedulers to use explicit game rules (#29320) * works, still has testing values, im sure I did stupid shit. * shitvent crapfactor * snap extra word out of existence * shit I died of old * remove useless inaccurate design comments * Oopsie, handle requirement params in RandomRuleSystem too * I'm a slash slinging hasher * Address reviews, add admin alerts I forgor * EntityMan saves the day * address reviews 1 * eh, I actually don't care about the cargo gifts thing. * started * Do reviews * you actually meant 1.2 lmao * dependency inheritance is a fickle bitch * I have no idea. * Threads are for sheets not computers. * fix traitor rule test * fix round type tattling * break things * It worky * Toolshed makes we want to drink depresso. * Finished? * remove debug values * timings * use defaults * alphabetize * bobby drop tables * Float required fr fr * continue * more continence * uno mas * obsolution * cleanup and documentations * Yell at self * use the right value defaults * housekeeping * Event scheduler setting tweaks (#31018) tweaks * Automatic changelog update * remove(NukeopsRuleComponent): Remove a trap from the component file (#31029) ah * Fix bug with holding objects (#31009) Main * Automatic changelog update * Replace obsolete map functions in IconSmoothSystem (#30958) * first part * second part * Automatic changelog update * Fix reagents with ReagentData being duplicated (#30983) Initial commit * :trollface: * :trollface: * actually untroll * a * 50 burger * add back old meteor code * fix * use some live config options in dev * remove old shock collar icon * make ammo more consistent and work more * clean up lathes diff to upstream * a * move rubber bullets to deltav folder * a * untroll * more untrolls * more untrolls * untroll * :trollface: * a * b * remove it for real * add missing lathe recipes * replace cvars with component field * remove taco from roboisseur * migrate cardboard box with smg mags * remove kebabs * a --------- Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: Killerqu00 <47712032+Killerqu00@users.noreply.github.com> Co-authored-by: Brandon Hu <103440971+Brandon-Huu@users.noreply.github.com> Co-authored-by: Zachary Yona <58833995+Magicalus@users.noreply.github.com> Co-authored-by: Zachary Yona <magicalusf@gmail.com> Co-authored-by: Plykiya <58439124+Plykiya@users.noreply.github.com> Co-authored-by: plykiya <plykiya@protonmail.com> Co-authored-by: PJBot <pieterjan.briers+bot@gmail.com> Co-authored-by: Alzore <140123969+Blackern5000@users.noreply.github.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: Kara <lunarautomaton6@gmail.com> Co-authored-by: EmoGarbage404 <retron404@gmail.com> Co-authored-by: Ubaser <134914314+UbaserB@users.noreply.github.com> Co-authored-by: Token <esil.bektay@yandex.com> Co-authored-by: Cojoke <83733158+Cojoke-dot@users.noreply.github.com> Co-authored-by: LeoSantich <108027402+LeoSantich@users.noreply.github.com> Co-authored-by: nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com> Co-authored-by: pigeonpeas <147350443+pigeonpeas@users.noreply.github.com> Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Co-authored-by: PoorMansDreams <150595537+PoorMansDreams@users.noreply.github.com> Co-authored-by: IgorAnt028 <118114530+IgorAnt028@users.noreply.github.com> Co-authored-by: NotSoDamn <75203942+NotSoDana@users.noreply.github.com> Co-authored-by: Errant <35878406+Errant-4@users.noreply.github.com> Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Co-authored-by: Velcroboy <107660393+IamVelcroboy@users.noreply.github.com> Co-authored-by: Jeff <velcroboy333@hotmail.com> Co-authored-by: themias <89101928+themias@users.noreply.github.com> Co-authored-by: Eris <eris@erisws.com> Co-authored-by: FATFSAAM2 <saamboroujerdi@gmail.com> Co-authored-by: to4no_fix <156101927+chavonadelal@users.noreply.github.com> Co-authored-by: Mervill <mervills.email@gmail.com> Co-authored-by: Vasilis <vascreeper@yahoo.com> Co-authored-by: Nim <128169402+Nimfar11@users.noreply.github.com> Co-authored-by: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com> Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
540 lines
19 KiB
C#
540 lines
19 KiB
C#
using Content.Shared.ActionBlocker;
|
|
using Content.Shared.Administration.Logs;
|
|
using Content.Shared.Alert;
|
|
using Content.Shared.Buckle.Components;
|
|
using Content.Shared.Cuffs.Components;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Hands;
|
|
using Content.Shared.Hands.EntitySystems;
|
|
using Content.Shared.Input;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Item;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.Movement.Events;
|
|
using Content.Shared.Movement.Pulling.Components;
|
|
using Content.Shared.Movement.Pulling.Events;
|
|
using Content.Shared.Movement.Systems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Pulling.Events;
|
|
using Content.Shared.Standing;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.Input.Binding;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Physics.Events;
|
|
using Robust.Shared.Physics.Systems;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared.Movement.Pulling.Systems;
|
|
|
|
/// <summary>
|
|
/// Allows one entity to pull another behind them via a physics distance joint.
|
|
/// </summary>
|
|
public sealed class PullingSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
|
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
|
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
|
[Dependency] private readonly MovementSpeedModifierSystem _modifierSystem = default!;
|
|
[Dependency] private readonly SharedJointSystem _joints = default!;
|
|
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
|
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
|
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
|
[Dependency] private readonly HeldSpeedModifierSystem _clothingMoveSpeed = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
UpdatesAfter.Add(typeof(SharedPhysicsSystem));
|
|
UpdatesOutsidePrediction = true;
|
|
|
|
SubscribeLocalEvent<PullableComponent, MoveInputEvent>(OnPullableMoveInput);
|
|
SubscribeLocalEvent<PullableComponent, CollisionChangeEvent>(OnPullableCollisionChange);
|
|
SubscribeLocalEvent<PullableComponent, JointRemovedEvent>(OnJointRemoved);
|
|
SubscribeLocalEvent<PullableComponent, GetVerbsEvent<Verb>>(AddPullVerbs);
|
|
SubscribeLocalEvent<PullableComponent, EntGotInsertedIntoContainerMessage>(OnPullableContainerInsert);
|
|
SubscribeLocalEvent<PullableComponent, ModifyUncuffDurationEvent>(OnModifyUncuffDuration);
|
|
SubscribeLocalEvent<PullableComponent, StopBeingPulledAlertEvent>(OnStopBeingPulledAlert);
|
|
|
|
SubscribeLocalEvent<PullerComponent, UpdateMobStateEvent>(OnStateChanged);
|
|
SubscribeLocalEvent<PullerComponent, AfterAutoHandleStateEvent>(OnAfterState);
|
|
SubscribeLocalEvent<PullerComponent, EntGotInsertedIntoContainerMessage>(OnPullerContainerInsert);
|
|
SubscribeLocalEvent<PullerComponent, EntityUnpausedEvent>(OnPullerUnpaused);
|
|
SubscribeLocalEvent<PullerComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
|
|
SubscribeLocalEvent<PullerComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
|
SubscribeLocalEvent<PullerComponent, DropHandItemsEvent>(OnDropHandItems);
|
|
SubscribeLocalEvent<PullerComponent, StopPullingAlertEvent>(OnStopPullingAlert);
|
|
|
|
SubscribeLocalEvent<PullableComponent, StrappedEvent>(OnBuckled);
|
|
SubscribeLocalEvent<PullableComponent, BuckledEvent>(OnGotBuckled);
|
|
|
|
CommandBinds.Builder
|
|
.Bind(ContentKeyFunctions.ReleasePulledObject, InputCmdHandler.FromDelegate(OnReleasePulledObject, handle: false))
|
|
.Register<PullingSystem>();
|
|
}
|
|
|
|
private void OnStateChanged(EntityUid uid, PullerComponent component, ref UpdateMobStateEvent args)
|
|
{
|
|
if (component.Pulling == null)
|
|
return;
|
|
|
|
if (TryComp<PullableComponent>(component.Pulling, out var comp) && (args.State == MobState.Critical || args.State == MobState.Dead))
|
|
{
|
|
TryStopPull(component.Pulling.Value, comp);
|
|
}
|
|
}
|
|
|
|
private void OnBuckled(Entity<PullableComponent> ent, ref StrappedEvent args)
|
|
{
|
|
// Prevent people from pulling the entity they are buckled to
|
|
if (ent.Comp.Puller == args.Buckle.Owner && !args.Buckle.Comp.PullStrap)
|
|
StopPulling(ent, ent);
|
|
}
|
|
|
|
private void OnGotBuckled(Entity<PullableComponent> ent, ref BuckledEvent args)
|
|
{
|
|
StopPulling(ent, ent);
|
|
}
|
|
|
|
private void OnAfterState(Entity<PullerComponent> ent, ref AfterAutoHandleStateEvent args)
|
|
{
|
|
if (ent.Comp.Pulling == null)
|
|
RemComp<ActivePullerComponent>(ent.Owner);
|
|
else
|
|
EnsureComp<ActivePullerComponent>(ent.Owner);
|
|
}
|
|
|
|
private void OnDropHandItems(EntityUid uid, PullerComponent pullerComp, DropHandItemsEvent args)
|
|
{
|
|
if (pullerComp.Pulling == null || pullerComp.NeedsHands)
|
|
return;
|
|
|
|
if (!TryComp(pullerComp.Pulling, out PullableComponent? pullableComp))
|
|
return;
|
|
|
|
TryStopPull(pullerComp.Pulling.Value, pullableComp, uid);
|
|
}
|
|
|
|
private void OnStopPullingAlert(Entity<PullerComponent> ent, ref StopPullingAlertEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
if (!TryComp<PullableComponent>(ent.Comp.Pulling, out var pullable))
|
|
return;
|
|
args.Handled = TryStopPull(ent.Comp.Pulling.Value, pullable, ent);
|
|
}
|
|
|
|
private void OnPullerContainerInsert(Entity<PullerComponent> ent, ref EntGotInsertedIntoContainerMessage args)
|
|
{
|
|
if (ent.Comp.Pulling == null)
|
|
return;
|
|
|
|
if (!TryComp(ent.Comp.Pulling.Value, out PullableComponent? pulling))
|
|
return;
|
|
|
|
TryStopPull(ent.Comp.Pulling.Value, pulling, ent.Owner);
|
|
}
|
|
|
|
private void OnPullableContainerInsert(Entity<PullableComponent> ent, ref EntGotInsertedIntoContainerMessage args)
|
|
{
|
|
TryStopPull(ent.Owner, ent.Comp);
|
|
}
|
|
|
|
private void OnModifyUncuffDuration(Entity<PullableComponent> ent, ref ModifyUncuffDurationEvent args)
|
|
{
|
|
if (!ent.Comp.BeingPulled)
|
|
return;
|
|
|
|
// We don't care if the person is being uncuffed by someone else
|
|
if (args.User != args.Target)
|
|
return;
|
|
|
|
args.Duration *= 2;
|
|
}
|
|
|
|
private void OnStopBeingPulledAlert(Entity<PullableComponent> ent, ref StopBeingPulledAlertEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
args.Handled = TryStopPull(ent, ent, ent);
|
|
}
|
|
|
|
public override void Shutdown()
|
|
{
|
|
base.Shutdown();
|
|
CommandBinds.Unregister<PullingSystem>();
|
|
}
|
|
|
|
private void OnPullerUnpaused(EntityUid uid, PullerComponent component, ref EntityUnpausedEvent args)
|
|
{
|
|
component.NextThrow += args.PausedTime;
|
|
}
|
|
|
|
private void OnVirtualItemDeleted(EntityUid uid, PullerComponent component, VirtualItemDeletedEvent args)
|
|
{
|
|
// If client deletes the virtual hand then stop the pull.
|
|
if (component.Pulling == null)
|
|
return;
|
|
|
|
if (component.Pulling != args.BlockingEntity)
|
|
return;
|
|
|
|
if (EntityManager.TryGetComponent(args.BlockingEntity, out PullableComponent? comp))
|
|
{
|
|
TryStopPull(args.BlockingEntity, comp, uid);
|
|
}
|
|
}
|
|
|
|
private void AddPullVerbs(EntityUid uid, PullableComponent component, GetVerbsEvent<Verb> args)
|
|
{
|
|
if (!args.CanAccess || !args.CanInteract)
|
|
return;
|
|
|
|
// Are they trying to pull themselves up by their bootstraps?
|
|
if (args.User == args.Target)
|
|
return;
|
|
|
|
//TODO VERB ICONS add pulling icon
|
|
if (component.Puller == args.User)
|
|
{
|
|
Verb verb = new()
|
|
{
|
|
Text = Loc.GetString("pulling-verb-get-data-text-stop-pulling"),
|
|
Act = () => TryStopPull(uid, component, user: args.User),
|
|
DoContactInteraction = false // pulling handle its own contact interaction.
|
|
};
|
|
args.Verbs.Add(verb);
|
|
}
|
|
else if (CanPull(args.User, args.Target))
|
|
{
|
|
Verb verb = new()
|
|
{
|
|
Text = Loc.GetString("pulling-verb-get-data-text"),
|
|
Act = () => TryStartPull(args.User, args.Target),
|
|
DoContactInteraction = false // pulling handle its own contact interaction.
|
|
};
|
|
args.Verbs.Add(verb);
|
|
}
|
|
}
|
|
|
|
private void OnRefreshMovespeed(EntityUid uid, PullerComponent component, RefreshMovementSpeedModifiersEvent args)
|
|
{
|
|
if (TryComp<HeldSpeedModifierComponent>(component.Pulling, out var heldMoveSpeed) && component.Pulling.HasValue)
|
|
{
|
|
var (walkMod, sprintMod) =
|
|
_clothingMoveSpeed.GetHeldMovementSpeedModifiers(component.Pulling.Value, heldMoveSpeed);
|
|
args.ModifySpeed(walkMod, sprintMod);
|
|
return;
|
|
}
|
|
|
|
args.ModifySpeed(component.WalkSpeedModifier, component.SprintSpeedModifier);
|
|
}
|
|
|
|
private void OnPullableMoveInput(EntityUid uid, PullableComponent component, ref MoveInputEvent args)
|
|
{
|
|
// If someone moves then break their pulling.
|
|
if (!component.BeingPulled)
|
|
return;
|
|
|
|
var entity = args.Entity;
|
|
|
|
if (!_blocker.CanMove(entity))
|
|
return;
|
|
|
|
TryStopPull(uid, component, user: uid);
|
|
}
|
|
|
|
private void OnPullableCollisionChange(EntityUid uid, PullableComponent component, ref CollisionChangeEvent args)
|
|
{
|
|
// IDK what this is supposed to be.
|
|
if (!_timing.ApplyingState && component.PullJointId != null && !args.CanCollide)
|
|
{
|
|
_joints.RemoveJoint(uid, component.PullJointId);
|
|
}
|
|
}
|
|
|
|
private void OnJointRemoved(EntityUid uid, PullableComponent component, JointRemovedEvent args)
|
|
{
|
|
// Just handles the joint getting nuked without going through pulling system (valid behavior).
|
|
|
|
// Not relevant / pullable state handle it.
|
|
if (component.Puller != args.OtherEntity ||
|
|
args.Joint.ID != component.PullJointId ||
|
|
_timing.ApplyingState)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (args.Joint.ID != component.PullJointId || component.Puller == null)
|
|
return;
|
|
|
|
StopPulling(uid, component);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Forces pulling to stop and handles cleanup.
|
|
/// </summary>
|
|
private void StopPulling(EntityUid pullableUid, PullableComponent pullableComp)
|
|
{
|
|
if (pullableComp.Puller == null)
|
|
return;
|
|
|
|
if (!_timing.ApplyingState)
|
|
{
|
|
// Joint shutdown
|
|
if (pullableComp.PullJointId != null)
|
|
{
|
|
_joints.RemoveJoint(pullableUid, pullableComp.PullJointId);
|
|
pullableComp.PullJointId = null;
|
|
}
|
|
|
|
if (TryComp<PhysicsComponent>(pullableUid, out var pullablePhysics))
|
|
{
|
|
_physics.SetFixedRotation(pullableUid, pullableComp.PrevFixedRotation, body: pullablePhysics);
|
|
}
|
|
}
|
|
|
|
var oldPuller = pullableComp.Puller;
|
|
if (oldPuller != null)
|
|
RemComp<ActivePullerComponent>(oldPuller.Value);
|
|
|
|
pullableComp.PullJointId = null;
|
|
pullableComp.Puller = null;
|
|
Dirty(pullableUid, pullableComp);
|
|
|
|
// No more joints with puller -> force stop pull.
|
|
if (TryComp<PullerComponent>(oldPuller, out var pullerComp))
|
|
{
|
|
var pullerUid = oldPuller.Value;
|
|
_alertsSystem.ClearAlert(pullerUid, pullerComp.PullingAlert);
|
|
pullerComp.Pulling = null;
|
|
Dirty(oldPuller.Value, pullerComp);
|
|
|
|
// Messaging
|
|
var message = new PullStoppedMessage(pullerUid, pullableUid);
|
|
_modifierSystem.RefreshMovementSpeedModifiers(pullerUid);
|
|
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(pullerUid):user} stopped pulling {ToPrettyString(pullableUid):target}");
|
|
|
|
RaiseLocalEvent(pullerUid, message);
|
|
RaiseLocalEvent(pullableUid, message);
|
|
}
|
|
|
|
|
|
_alertsSystem.ClearAlert(pullableUid, pullableComp.PulledAlert);
|
|
}
|
|
|
|
public bool IsPulled(EntityUid uid, PullableComponent? component = null)
|
|
{
|
|
return Resolve(uid, ref component, false) && component.BeingPulled;
|
|
}
|
|
|
|
public bool IsPulling(EntityUid puller, PullerComponent? component = null)
|
|
{
|
|
return Resolve(puller, ref component, false) && component.Pulling != null;
|
|
}
|
|
|
|
private void OnReleasePulledObject(ICommonSession? session)
|
|
{
|
|
if (session?.AttachedEntity is not { Valid: true } player)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!TryComp(player, out PullerComponent? pullerComp) ||
|
|
!TryComp(pullerComp.Pulling, out PullableComponent? pullableComp))
|
|
{
|
|
return;
|
|
}
|
|
|
|
TryStopPull(pullerComp.Pulling.Value, pullableComp, user: player);
|
|
}
|
|
|
|
public bool CanPull(EntityUid puller, EntityUid pullableUid, PullerComponent? pullerComp = null)
|
|
{
|
|
if (!Resolve(puller, ref pullerComp, false))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (pullerComp.NeedsHands
|
|
&& !_handsSystem.TryGetEmptyHand(puller, out _)
|
|
&& pullerComp.Pulling == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!_blocker.CanInteract(puller, pullableUid))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!EntityManager.TryGetComponent<PhysicsComponent>(pullableUid, out var physics))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (physics.BodyType == BodyType.Static)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (puller == pullableUid)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!_containerSystem.IsInSameOrNoContainer(puller, pullableUid))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var getPulled = new BeingPulledAttemptEvent(puller, pullableUid);
|
|
RaiseLocalEvent(pullableUid, getPulled, true);
|
|
var startPull = new StartPullAttemptEvent(puller, pullableUid);
|
|
RaiseLocalEvent(puller, startPull, true);
|
|
return !startPull.Cancelled && !getPulled.Cancelled;
|
|
}
|
|
|
|
public bool TogglePull(Entity<PullableComponent?> pullable, EntityUid pullerUid)
|
|
{
|
|
if (!Resolve(pullable, ref pullable.Comp, false))
|
|
return false;
|
|
|
|
if (pullable.Comp.Puller == pullerUid)
|
|
{
|
|
return TryStopPull(pullable, pullable.Comp);
|
|
}
|
|
|
|
return TryStartPull(pullerUid, pullable, pullableComp: pullable);
|
|
}
|
|
|
|
public bool TogglePull(EntityUid pullerUid, PullerComponent puller)
|
|
{
|
|
if (!TryComp<PullableComponent>(puller.Pulling, out var pullable))
|
|
return false;
|
|
|
|
return TogglePull((puller.Pulling.Value, pullable), pullerUid);
|
|
}
|
|
|
|
public bool TryStartPull(EntityUid pullerUid, EntityUid pullableUid,
|
|
PullerComponent? pullerComp = null, PullableComponent? pullableComp = null)
|
|
{
|
|
if (!Resolve(pullerUid, ref pullerComp, false) ||
|
|
!Resolve(pullableUid, ref pullableComp, false))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (pullerComp.Pulling == pullableUid)
|
|
return true;
|
|
|
|
if (!CanPull(pullerUid, pullableUid))
|
|
return false;
|
|
|
|
if (!HasComp<PhysicsComponent>(pullerUid) || !TryComp(pullableUid, out PhysicsComponent? pullablePhysics))
|
|
return false;
|
|
|
|
// Ensure that the puller is not currently pulling anything.
|
|
if (TryComp<PullableComponent>(pullerComp.Pulling, out var oldPullable)
|
|
&& !TryStopPull(pullerComp.Pulling.Value, oldPullable, pullerUid))
|
|
return false;
|
|
|
|
// Stop anyone else pulling the entity we want to pull
|
|
if (pullableComp.Puller != null)
|
|
{
|
|
// We're already pulling this item
|
|
if (pullableComp.Puller == pullerUid)
|
|
return false;
|
|
|
|
if (!TryStopPull(pullableUid, pullableComp, pullableComp.Puller))
|
|
return false;
|
|
}
|
|
|
|
var pullAttempt = new PullAttemptEvent(pullerUid, pullableUid);
|
|
RaiseLocalEvent(pullerUid, pullAttempt);
|
|
|
|
if (pullAttempt.Cancelled)
|
|
return false;
|
|
|
|
RaiseLocalEvent(pullableUid, pullAttempt);
|
|
|
|
if (pullAttempt.Cancelled)
|
|
return false;
|
|
|
|
// Pulling confirmed
|
|
|
|
_interaction.DoContactInteraction(pullableUid, pullerUid);
|
|
|
|
// Use net entity so it's consistent across client and server.
|
|
pullableComp.PullJointId = $"pull-joint-{GetNetEntity(pullableUid)}";
|
|
|
|
EnsureComp<ActivePullerComponent>(pullerUid);
|
|
pullerComp.Pulling = pullableUid;
|
|
pullableComp.Puller = pullerUid;
|
|
|
|
// store the pulled entity's physics FixedRotation setting in case we change it
|
|
pullableComp.PrevFixedRotation = pullablePhysics.FixedRotation;
|
|
|
|
// joint state handling will manage its own state
|
|
if (!_timing.ApplyingState)
|
|
{
|
|
// Joint startup
|
|
var union = _physics.GetHardAABB(pullerUid).Union(_physics.GetHardAABB(pullableUid, body: pullablePhysics));
|
|
var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f;
|
|
|
|
var joint = _joints.CreateDistanceJoint(pullableUid, pullerUid, id: pullableComp.PullJointId);
|
|
joint.CollideConnected = false;
|
|
// This maximum has to be there because if the object is constrained too closely, the clamping goes backwards and asserts.
|
|
joint.MaxLength = Math.Max(1.0f, length);
|
|
joint.Length = length * 0.75f;
|
|
joint.MinLength = 0f;
|
|
joint.Stiffness = 1f;
|
|
|
|
_physics.SetFixedRotation(pullableUid, pullableComp.FixedRotationOnPull, body: pullablePhysics);
|
|
}
|
|
|
|
// Messaging
|
|
var message = new PullStartedMessage(pullerUid, pullableUid);
|
|
_modifierSystem.RefreshMovementSpeedModifiers(pullerUid);
|
|
_alertsSystem.ShowAlert(pullerUid, pullerComp.PullingAlert);
|
|
_alertsSystem.ShowAlert(pullableUid, pullableComp.PulledAlert);
|
|
|
|
RaiseLocalEvent(pullerUid, message);
|
|
RaiseLocalEvent(pullableUid, message);
|
|
|
|
Dirty(pullerUid, pullerComp);
|
|
Dirty(pullableUid, pullableComp);
|
|
|
|
_adminLogger.Add(LogType.Action, LogImpact.Low,
|
|
$"{ToPrettyString(pullerUid):user} started pulling {ToPrettyString(pullableUid):target}");
|
|
return true;
|
|
}
|
|
|
|
public bool TryStopPull(EntityUid pullableUid, PullableComponent pullable, EntityUid? user = null)
|
|
{
|
|
var pullerUidNull = pullable.Puller;
|
|
|
|
if (pullerUidNull == null)
|
|
return true;
|
|
|
|
if (user != null && !_blocker.CanInteract(user.Value, pullableUid))
|
|
return false;
|
|
|
|
var msg = new AttemptStopPullingEvent(user);
|
|
RaiseLocalEvent(pullableUid, msg, true);
|
|
|
|
if (msg.Cancelled)
|
|
return false;
|
|
|
|
StopPulling(pullableUid, pullable);
|
|
return true;
|
|
}
|
|
}
|