mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-04 13:27:30 +00:00
+24









Debug
deltanedas
metalgearsloth
Nemanja
PJBot
Psychpsyo
deltanedas
metalgearsloth
ravage
Pieter-Jan Briers
LEVELcat
Repo
nikthechampiongr
Doru991
DrSmugleaf
Skarletto
NULL882
lunarcomets
Miro Kavaliou
Kara
Kacper Urbańczyk
TsjipTsjip
daerSeebaer
Fluffiest Floofers
Flareguy
Leon Friedrich
Kevin Zheng
drteaspoon420
Ubaser
Nim
Kacper Urbańczyk
Tox Cruize
Ed
Michael Cu
fd2cc8570d
* Automatic changelog update * Make NPC names proper nouns & fix some genders (#20534) * Proper names & genders * Uppercase proper names * Make Smile female * fix bingus wrinkly head (#20531) * rouny meat and steak (#20526) * lost friendship flavor * add rouny steak * rouny special meat * rouny meat textures --------- Co-authored-by: deltanedas <@deltanedas:kde.org> * Automatic changelog update * Wearable Wet Floor Sign and 'Janitorial Suicide Vest' (#20311) * Explosive wet floor sign & janitorial suicide vest * fix attributions * Remove name & desc from explosive wet floor sign * Make wet floor sign chameleonable * Automatic changelog update * Minor slippery stuff (#20535) * Update submodule to 162.2.0 (#20570) * Predicted armor (#20560) * clean up some lines in smile the slime prototype (#20552) * Revert "Use full file path for temp replays (#19002)" (#20545) * Add EyesGlasses into ClothesMate (#20523) * Automatic changelog update * Fix Punpun crew monitor sensor (#20484) * Automatic changelog update * EasyPry airlocks for arrivals. Now also prying refactor I guess (#19394) Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> * Automatic changelog update * Make arcades hackable again (#20555) * Automatic changelog update * Health alert tweaks (#20557) * Automatic changelog update * Add active and ended game rule components, generic TryRoundStartAttempt and minPlayers field (#20564) * Improve active game rule querying, add generic try round start attempt method, move minPlayers to GameRuleComponent * Nukeops todo and cleanup * Remove Active field * Add EndedGameRuleComponent * bartender suit (#20521) * give me a drink bartender * guh * aARG * Necropolis and mine walls (#20578) * Automatic changelog update * archaic accent tweaks (#20567) * Automatic changelog update * Add confirmation to kick and respawn in the admin player actions panel (#20542) * Remove windows-latest CI runs, remove unused build-test-release.yml (#20540) * Change .editorconfig to keep existing attribute arrangement (#20538) * Automatic changelog update * Catch replay start and end errors on round restarts (#20565) * Update trivial components to use auto comp states (#20539) * Fix role unbans not applying in real time (#20547) * Disable AHelp buttons when no player is selected, update button styling (#20568) * Automatic changelog update * Added a toggle fullscreen button (default F11) (#20272) * Added a toggle fullscreen button (default F11) * Removed un-needed comments * Review Requested Changes * Fixed Acidental Spacing Change * bwoink, removed extraneous code * nothing, litterally * Automatic changelog update * Fix not networking markings (#20588) * Automatic changelog update * Update RobustToolbox to v162.2.1 (#20590) * Automatic changelog update * Glorfcode (force say on damage/stun/crit) (#20562) * Automatic changelog update * Fix AHelp progressively showing more AHelp panels (#20591) * Automatic changelog update * caninsert entitystorage tweaks (#20589) * Automatic changelog update * Fix mapping actions crashing on load (#20592) * Fix loading a map with a ThirstComponent crashing the game (#20594) * Fix electrocution displaying real name of disguised players (#20603) * Organ fixes (#20488) * Automatic changelog update * Kettle medical rework (#20435) * Initial try at medical rework for kettle * Re-add decal decorations to Kettle's medical * Add more lockers to kettle's med * Actually upload kettle's map, not its proto * Automatic changelog update * Added blocked visuals to volumetric pump (#20610) * Automatic changelog update * Move TimedDespawn to engine (#20515) * Update submodule to 163.0.0 (#20616) * Remove v0.1 version number from local main menu screen (#20617) * Remove cloneData parameter from AutoNetworkedField (#20596) * Update submodule to 164.0.0 (#20618) * fix cognizine ghost role (#20632) Co-authored-by: deltanedas <@deltanedas:kde.org> * Automatic changelog update * Move ID layer one pixel to correct alignment (#20630) * Update nukie hardsuit descriptions (#20529) * Make holofans destructable (#20445) * Automatic changelog update * bowl is open (#20453) Co-authored-by: deltanedas <@deltanedas:kde.org> * Add TestPair.WaitCommand() (#20615) * Rename ThreatPrototype and mark fields as required (#20611) * Adjust hard bomb shape (#20608) * dragon refactor, objectives and use GenericAntag (#20201) Co-authored-by: deltanedas <@deltanedas:kde.org> * Automatic changelog update * Added generic empty liquids tank (#20563) * Move view variables verb to the top of the list with no category and localize it (#20546) * saltern update (#20325) Co-authored-by: deltanedas <@deltanedas:kde.org> * Fix followers leaking (#20643) * Add Winter Boots (#20622) * add * fix prototype * Add QM mantle (#20621) * add * fix prototype * Automatic changelog update * Slime mobs breathe nitrogen and resprite their organs (#20577) * Slimes breathe nitrogen and resprite their organs * ups * mmm * Automatic changelog update * Fix the new lizard horn's consistency + issue (#20620) * fix * add * Revert "add" This reverts commit a054a3204a8f185a94ceb80b1bd3bc9f30423711. * Add RandomHumanoidAppearance component to for space ninjas (#20605) * Automatic changelog update * Space cat breathes space (#20550) * Space cat breathes space Made Space Cat lungs ROBUST * Made Space Cat's lungs ROBUST 2.0 * Automatic changelog update * Wide anomaly locator (#20581) * Add files via upload * Add files via upload * Add files via upload * Add files via upload * add textures * fix encoding * fix 2 * Automatic changelog update * Fixed Telescopic Shield Lighting (#20650) * Fixed Telescopic Shield Lighting Bug fix #20199 * no need for these at all --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> * Automatic changelog update * Add a special hardsuit for nukie medic (#20471) * Automatic changelog update * Carry over other mutations when doing species mutation (#20551) * Automatic changelog update * Add Spanish accent to poncho and sombrero (#20377) --------- Co-authored-by: PJBot <pieterjan.briers+bot@gmail.com> Co-authored-by: Psychpsyo <60073468+Psychpsyo@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: ravage <142820619+ravage123321@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: LEVELcat <68501903+LEVELcat@users.noreply.github.com> Co-authored-by: Repo <47093363+Titian3@users.noreply.github.com> Co-authored-by: nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> Co-authored-by: Doru991 <75124791+Doru991@users.noreply.github.com> Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Skarletto <122584947+Skarletto@users.noreply.github.com> Co-authored-by: NULL882 <104377798+NULL882@users.noreply.github.com> Co-authored-by: lunarcomets <140772713+lunarcomets@users.noreply.github.com> Co-authored-by: Miro Kavaliou <miraslauk@gmail.com> Co-authored-by: Kara <lunarautomaton6@gmail.com> Co-authored-by: Kacper Urbańczyk <kacperjaroslawurbanczyk@gmail.com> Co-authored-by: TsjipTsjip <19798667+TsjipTsjip@users.noreply.github.com> Co-authored-by: daerSeebaer <61566539+daerSeebaer@users.noreply.github.com> Co-authored-by: Fluffiest Floofers <thebluewulf@gmail.com> Co-authored-by: Flareguy <78941145+Flareguy@users.noreply.github.com> Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: Kevin Zheng <kevinz5000@gmail.com> Co-authored-by: drteaspoon420 <87363733+drteaspoon420@users.noreply.github.com> Co-authored-by: Ubaser <134914314+UbaserB@users.noreply.github.com> Co-authored-by: Nim <128169402+Nimfar11@users.noreply.github.com> Co-authored-by: Kacper Urbańczyk <mikrel071204@gmail.com> Co-authored-by: Tox Cruize <141375638+TexCruize@users.noreply.github.com> Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: Michael Cu <43478115+michaelcu@users.noreply.github.com>
477 lines
18 KiB
C#
477 lines
18 KiB
C#
using System.Numerics;
|
|
using Content.Server.Body.Systems;
|
|
using Content.Server.Climbing.Components;
|
|
using Content.Server.Interaction;
|
|
using Content.Server.Popups;
|
|
using Content.Server.Stunnable;
|
|
using Content.Shared.ActionBlocker;
|
|
using Content.Shared.Body.Components;
|
|
using Content.Shared.Body.Part;
|
|
using Content.Shared.Buckle.Components;
|
|
using Content.Shared.Climbing;
|
|
using Content.Shared.Climbing.Events;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.DoAfter;
|
|
using Content.Shared.DragDrop;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.Hands.Components;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Physics;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Verbs;
|
|
using JetBrains.Annotations;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Physics.Collision.Shapes;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Physics.Dynamics;
|
|
using Robust.Shared.Physics.Events;
|
|
using Robust.Shared.Physics.Systems;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Server.Climbing;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class ClimbSystem : SharedClimbSystem
|
|
{
|
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
|
[Dependency] private readonly AudioSystem _audio = default!;
|
|
[Dependency] private readonly BodySystem _bodySystem = default!;
|
|
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
|
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
|
[Dependency] private readonly FixtureSystem _fixtureSystem = default!;
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly InteractionSystem _interactionSystem = default!;
|
|
[Dependency] private readonly StunSystem _stunSystem = default!;
|
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
|
|
|
private const string ClimbingFixtureName = "climb";
|
|
private const int ClimbingCollisionGroup = (int) (CollisionGroup.TableLayer | CollisionGroup.LowImpassable);
|
|
|
|
private readonly Dictionary<EntityUid, Dictionary<string, Fixture>> _fixtureRemoveQueue = new();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
|
SubscribeLocalEvent<ClimbableComponent, GetVerbsEvent<AlternativeVerb>>(AddClimbableVerb);
|
|
SubscribeLocalEvent<ClimbableComponent, DragDropTargetEvent>(OnClimbableDragDrop);
|
|
|
|
SubscribeLocalEvent<ClimbingComponent, ClimbDoAfterEvent>(OnDoAfter);
|
|
SubscribeLocalEvent<ClimbingComponent, EndCollideEvent>(OnClimbEndCollide);
|
|
SubscribeLocalEvent<ClimbingComponent, BuckleChangeEvent>(OnBuckleChange);
|
|
|
|
SubscribeLocalEvent<GlassTableComponent, ClimbedOnEvent>(OnGlassClimbed);
|
|
}
|
|
|
|
protected override void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, ref CanDropTargetEvent args)
|
|
{
|
|
base.OnCanDragDropOn(uid, component, ref args);
|
|
|
|
if (!args.CanDrop)
|
|
return;
|
|
|
|
string reason;
|
|
var canVault = args.User == args.Dragged
|
|
? CanVault(component, args.User, uid, out reason)
|
|
: CanVault(component, args.User, args.Dragged, uid, out reason);
|
|
|
|
if (!canVault)
|
|
_popupSystem.PopupEntity(reason, args.User, args.User);
|
|
|
|
args.CanDrop = canVault;
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void AddClimbableVerb(EntityUid uid, ClimbableComponent component, GetVerbsEvent<AlternativeVerb> args)
|
|
{
|
|
if (!args.CanAccess || !args.CanInteract || !_actionBlockerSystem.CanMove(args.User))
|
|
return;
|
|
|
|
if (!TryComp(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
|
return;
|
|
|
|
// TODO VERBS ICON add a climbing icon?
|
|
args.Verbs.Add(new AlternativeVerb
|
|
{
|
|
Act = () => TryClimb(args.User, args.User, args.Target, out _, component),
|
|
Text = Loc.GetString("comp-climbable-verb-climb")
|
|
});
|
|
}
|
|
|
|
private void OnClimbableDragDrop(EntityUid uid, ClimbableComponent component, ref DragDropTargetEvent args)
|
|
{
|
|
// definitely a better way to check if two entities are equal
|
|
// but don't have computer access and i have to do this without syntax
|
|
if (args.Handled || args.User != args.Dragged && !HasComp<HandsComponent>(args.User))
|
|
return;
|
|
TryClimb(args.User, args.Dragged, uid, out _, component);
|
|
}
|
|
|
|
public bool TryClimb(EntityUid user,
|
|
EntityUid entityToMove,
|
|
EntityUid climbable,
|
|
out DoAfterId? id,
|
|
ClimbableComponent? comp = null,
|
|
ClimbingComponent? climbing = null)
|
|
{
|
|
id = null;
|
|
|
|
if (!Resolve(climbable, ref comp) || !Resolve(entityToMove, ref climbing))
|
|
return false;
|
|
|
|
// Note, IsClimbing does not mean a DoAfter is active, it means the target has already finished a DoAfter and
|
|
// is currently on top of something..
|
|
if (climbing.IsClimbing)
|
|
return true;
|
|
|
|
var args = new DoAfterArgs(EntityManager, user, comp.ClimbDelay, new ClimbDoAfterEvent(), entityToMove, target: climbable, used: entityToMove)
|
|
{
|
|
BreakOnTargetMove = true,
|
|
BreakOnUserMove = true,
|
|
BreakOnDamage = true
|
|
};
|
|
|
|
_audio.PlayPvs(comp.StartClimbSound, climbable);
|
|
_doAfterSystem.TryStartDoAfter(args, out id);
|
|
return true;
|
|
}
|
|
|
|
private void OnDoAfter(EntityUid uid, ClimbingComponent component, ClimbDoAfterEvent args)
|
|
{
|
|
if (args.Handled || args.Cancelled || args.Args.Target == null || args.Args.Used == null)
|
|
return;
|
|
|
|
Climb(uid, args.Args.User, args.Args.Used.Value, args.Args.Target.Value, climbing: component);
|
|
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void Climb(EntityUid uid, EntityUid user, EntityUid instigator, EntityUid climbable, bool silent = false, ClimbingComponent? climbing = null,
|
|
PhysicsComponent? physics = null, FixturesComponent? fixtures = null, ClimbableComponent? comp = null)
|
|
{
|
|
if (!Resolve(uid, ref climbing, ref physics, ref fixtures, false))
|
|
return;
|
|
|
|
if (!Resolve(climbable, ref comp))
|
|
return;
|
|
|
|
if (!ReplaceFixtures(climbing, fixtures))
|
|
return;
|
|
|
|
climbing.IsClimbing = true;
|
|
Dirty(climbing);
|
|
|
|
_audio.PlayPvs(comp.FinishClimbSound, climbable);
|
|
MoveEntityToward(uid, climbable, physics, climbing);
|
|
// we may potentially need additional logic since we're forcing a player onto a climbable
|
|
// there's also the cases where the user might collide with the person they are forcing onto the climbable that i haven't accounted for
|
|
|
|
RaiseLocalEvent(uid, new StartClimbEvent(climbable), false);
|
|
RaiseLocalEvent(climbable, new ClimbedOnEvent(uid, user), false);
|
|
|
|
if (silent)
|
|
return;
|
|
if (user == uid)
|
|
{
|
|
var othersMessage = Loc.GetString("comp-climbable-user-climbs-other", ("user", Identity.Entity(uid, EntityManager)),
|
|
("climbable", climbable));
|
|
uid.PopupMessageOtherClients(othersMessage);
|
|
|
|
var selfMessage = Loc.GetString("comp-climbable-user-climbs", ("climbable", climbable));
|
|
uid.PopupMessage(selfMessage);
|
|
}
|
|
else
|
|
{
|
|
var othersMessage = Loc.GetString("comp-climbable-user-climbs-force-other", ("user", Identity.Entity(user, EntityManager)),
|
|
("moved-user", Identity.Entity(uid, EntityManager)), ("climbable", climbable));
|
|
user.PopupMessageOtherClients(othersMessage);
|
|
|
|
var selfMessage = Loc.GetString("comp-climbable-user-climbs-force", ("moved-user", Identity.Entity(uid, EntityManager)),
|
|
("climbable", climbable));
|
|
user.PopupMessage(selfMessage);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Replaces the current fixtures with non-climbing collidable versions so that climb end can be detected
|
|
/// </summary>
|
|
/// <returns>Returns whether adding the new fixtures was successful</returns>
|
|
private bool ReplaceFixtures(ClimbingComponent climbingComp, FixturesComponent fixturesComp)
|
|
{
|
|
var uid = climbingComp.Owner;
|
|
|
|
// Swap fixtures
|
|
foreach (var (name, fixture) in fixturesComp.Fixtures)
|
|
{
|
|
if (climbingComp.DisabledFixtureMasks.ContainsKey(name)
|
|
|| fixture.Hard == false
|
|
|| (fixture.CollisionMask & ClimbingCollisionGroup) == 0)
|
|
continue;
|
|
|
|
climbingComp.DisabledFixtureMasks.Add(name, fixture.CollisionMask & ClimbingCollisionGroup);
|
|
_physics.SetCollisionMask(uid, name, fixture, fixture.CollisionMask & ~ClimbingCollisionGroup, fixturesComp);
|
|
}
|
|
|
|
if (!_fixtureSystem.TryCreateFixture(
|
|
uid,
|
|
new PhysShapeCircle(0.35f),
|
|
ClimbingFixtureName,
|
|
collisionLayer: (int) CollisionGroup.None,
|
|
collisionMask: ClimbingCollisionGroup,
|
|
hard: false,
|
|
manager: fixturesComp))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private void OnClimbEndCollide(EntityUid uid, ClimbingComponent component, ref EndCollideEvent args)
|
|
{
|
|
if (args.OurFixtureId != ClimbingFixtureName
|
|
|| !component.IsClimbing
|
|
|| component.OwnerIsTransitioning)
|
|
return;
|
|
|
|
foreach (var fixture in args.OurFixture.Contacts.Keys)
|
|
{
|
|
if (fixture == args.OtherFixture)
|
|
continue;
|
|
// If still colliding with a climbable, do not stop climbing
|
|
if (HasComp<ClimbableComponent>(args.OtherEntity))
|
|
return;
|
|
}
|
|
|
|
StopClimb(uid, component);
|
|
}
|
|
|
|
private void StopClimb(EntityUid uid, ClimbingComponent? climbing = null, FixturesComponent? fixtures = null)
|
|
{
|
|
if (!Resolve(uid, ref climbing, ref fixtures, false))
|
|
return;
|
|
|
|
foreach (var (name, fixtureMask) in climbing.DisabledFixtureMasks)
|
|
{
|
|
if (!fixtures.Fixtures.TryGetValue(name, out var fixture))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
_physics.SetCollisionMask(uid, name, fixture, fixture.CollisionMask | fixtureMask, fixtures);
|
|
}
|
|
climbing.DisabledFixtureMasks.Clear();
|
|
|
|
if (!_fixtureRemoveQueue.TryGetValue(uid, out var removeQueue))
|
|
{
|
|
removeQueue = new Dictionary<string, Fixture>();
|
|
_fixtureRemoveQueue.Add(uid, removeQueue);
|
|
}
|
|
|
|
if (fixtures.Fixtures.TryGetValue(ClimbingFixtureName, out var climbingFixture))
|
|
removeQueue.Add(ClimbingFixtureName, climbingFixture);
|
|
|
|
climbing.IsClimbing = false;
|
|
climbing.OwnerIsTransitioning = false;
|
|
var ev = new EndClimbEvent();
|
|
RaiseLocalEvent(uid, ref ev);
|
|
Dirty(climbing);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks if the user can vault the target
|
|
/// </summary>
|
|
/// <param name="component">The component of the entity that is being vaulted</param>
|
|
/// <param name="user">The entity that wants to vault</param>
|
|
/// <param name="target">The object that is being vaulted</param>
|
|
/// <param name="reason">The reason why it cant be dropped</param>
|
|
/// <returns></returns>
|
|
public bool CanVault(ClimbableComponent component, EntityUid user, EntityUid target, out string reason)
|
|
{
|
|
if (!_actionBlockerSystem.CanInteract(user, target))
|
|
{
|
|
reason = Loc.GetString("comp-climbable-cant-interact");
|
|
return false;
|
|
}
|
|
|
|
if (!HasComp<ClimbingComponent>(user)
|
|
|| !TryComp(user, out BodyComponent? body)
|
|
|| !_bodySystem.BodyHasPartType(user, BodyPartType.Leg, body)
|
|
|| !_bodySystem.BodyHasPartType(user, BodyPartType.Foot, body))
|
|
{
|
|
reason = Loc.GetString("comp-climbable-cant-climb");
|
|
return false;
|
|
}
|
|
|
|
if (!_interactionSystem.InRangeUnobstructed(user, target, component.Range))
|
|
{
|
|
reason = Loc.GetString("comp-climbable-cant-reach");
|
|
return false;
|
|
}
|
|
|
|
reason = string.Empty;
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks if the user can vault the dragged entity onto the the target
|
|
/// </summary>
|
|
/// <param name="component">The climbable component of the object being vaulted onto</param>
|
|
/// <param name="user">The user that wants to vault the entity</param>
|
|
/// <param name="dragged">The entity that is being vaulted</param>
|
|
/// <param name="target">The object that is being vaulted onto</param>
|
|
/// <param name="reason">The reason why it cant be dropped</param>
|
|
/// <returns></returns>
|
|
public bool CanVault(ClimbableComponent component, EntityUid user, EntityUid dragged, EntityUid target,
|
|
out string reason)
|
|
{
|
|
if (!_actionBlockerSystem.CanInteract(user, dragged) || !_actionBlockerSystem.CanInteract(user, target))
|
|
{
|
|
reason = Loc.GetString("comp-climbable-cant-interact");
|
|
return false;
|
|
}
|
|
|
|
if (!HasComp<ClimbingComponent>(dragged))
|
|
{
|
|
reason = Loc.GetString("comp-climbable-cant-climb");
|
|
return false;
|
|
}
|
|
|
|
bool Ignored(EntityUid entity) => entity == target || entity == user || entity == dragged;
|
|
|
|
if (!_interactionSystem.InRangeUnobstructed(user, target, component.Range, predicate: Ignored)
|
|
|| !_interactionSystem.InRangeUnobstructed(user, dragged, component.Range, predicate: Ignored))
|
|
{
|
|
reason = Loc.GetString("comp-climbable-cant-reach");
|
|
return false;
|
|
}
|
|
|
|
reason = string.Empty;
|
|
return true;
|
|
}
|
|
|
|
public void ForciblySetClimbing(EntityUid uid, EntityUid climbable, ClimbingComponent? component = null)
|
|
{
|
|
Climb(uid, uid, uid, climbable, true, component);
|
|
}
|
|
|
|
private void OnBuckleChange(EntityUid uid, ClimbingComponent component, ref BuckleChangeEvent args)
|
|
{
|
|
if (!args.Buckling)
|
|
return;
|
|
StopClimb(uid, component);
|
|
}
|
|
|
|
private void OnGlassClimbed(EntityUid uid, GlassTableComponent component, ClimbedOnEvent args)
|
|
{
|
|
if (TryComp<PhysicsComponent>(args.Climber, out var physics) && physics.Mass <= component.MassLimit)
|
|
return;
|
|
|
|
_damageableSystem.TryChangeDamage(args.Climber, component.ClimberDamage, origin: args.Climber);
|
|
_damageableSystem.TryChangeDamage(uid, component.TableDamage, origin: args.Climber);
|
|
_stunSystem.TryParalyze(args.Climber, TimeSpan.FromSeconds(component.StunTime), true);
|
|
|
|
// Not shown to the user, since they already get a 'you climb on the glass table' popup
|
|
_popupSystem.PopupEntity(
|
|
Loc.GetString("glass-table-shattered-others", ("table", uid), ("climber", Identity.Entity(args.Climber, EntityManager))), args.Climber,
|
|
Filter.PvsExcept(args.Climber), true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Moves the entity toward the target climbed entity
|
|
/// </summary>
|
|
public void MoveEntityToward(EntityUid uid, EntityUid target, PhysicsComponent? physics = null, ClimbingComponent? climbing = null)
|
|
{
|
|
if (!Resolve(uid, ref physics, ref climbing, false))
|
|
return;
|
|
|
|
var from = Transform(uid).WorldPosition;
|
|
var to = Transform(target).WorldPosition;
|
|
var (x, y) = (to - from).Normalized();
|
|
|
|
if (MathF.Abs(x) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line
|
|
to = new Vector2(from.X, to.Y);
|
|
else if (MathF.Abs(y) < 0.6f) // user climbed mostly horizontally so lets make it a clean straight line
|
|
to = new Vector2(to.X, from.Y);
|
|
|
|
var velocity = (to - from).Length();
|
|
|
|
if (velocity <= 0.0f)
|
|
return;
|
|
|
|
// Since there are bodies with different masses:
|
|
// mass * 10 seems enough to move entity
|
|
// instead of launching cats like rockets against the walls with constant impulse value.
|
|
_physics.ApplyLinearImpulse(uid, (to - from).Normalized() * velocity * physics.Mass * 10, body: physics);
|
|
_physics.SetBodyType(uid, BodyType.Dynamic, body: physics);
|
|
climbing.OwnerIsTransitioning = true;
|
|
_actionBlockerSystem.UpdateCanMove(uid);
|
|
|
|
// Transition back to KinematicController after BufferTime
|
|
climbing.Owner.SpawnTimer((int) (ClimbingComponent.BufferTime * 1000), () =>
|
|
{
|
|
if (climbing.Deleted)
|
|
return;
|
|
|
|
_physics.SetBodyType(uid, BodyType.KinematicController);
|
|
climbing.OwnerIsTransitioning = false;
|
|
_actionBlockerSystem.UpdateCanMove(uid);
|
|
});
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
foreach (var (uid, fixtures) in _fixtureRemoveQueue)
|
|
{
|
|
if (!TryComp<PhysicsComponent>(uid, out var physicsComp)
|
|
|| !TryComp<FixturesComponent>(uid, out var fixturesComp))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
foreach (var fixture in fixtures)
|
|
{
|
|
_fixtureSystem.DestroyFixture(uid, fixture.Key, fixture.Value, body: physicsComp, manager: fixturesComp);
|
|
}
|
|
}
|
|
|
|
_fixtureRemoveQueue.Clear();
|
|
}
|
|
|
|
private void Reset(RoundRestartCleanupEvent ev)
|
|
{
|
|
_fixtureRemoveQueue.Clear();
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised on an entity when it is climbed on.
|
|
/// </summary>
|
|
public sealed class ClimbedOnEvent : EntityEventArgs
|
|
{
|
|
public EntityUid Climber;
|
|
public EntityUid Instigator;
|
|
|
|
public ClimbedOnEvent(EntityUid climber, EntityUid instigator)
|
|
{
|
|
Climber = climber;
|
|
Instigator = instigator;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised on an entity when it successfully climbs on something.
|
|
/// </summary>
|
|
public sealed class StartClimbEvent : EntityEventArgs
|
|
{
|
|
public EntityUid Climbable;
|
|
|
|
public StartClimbEvent(EntityUid climbable)
|
|
{
|
|
Climbable = climbable;
|
|
}
|
|
}
|