Fix formatting to match .editorconfig (IDE0055 warnings) (#23301)
This commit is contained in:
@@ -16,7 +16,7 @@ public sealed partial class ClimbingComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the owner is being moved onto the climbed entity.
|
/// Whether the owner is being moved onto the climbed entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AutoNetworkedField, DataField(customTypeSerializer:typeof(TimeOffsetSerializer))]
|
[AutoNetworkedField, DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||||
public TimeSpan? NextTransition;
|
public TimeSpan? NextTransition;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -158,341 +158,341 @@ public sealed partial class ClimbSystem : VirtualController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, ref CanDropTargetEvent args)
|
private void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, ref CanDropTargetEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
var canVault = args.User == args.Dragged
|
var canVault = args.User == args.Dragged
|
||||||
? CanVault(component, args.User, uid, out _)
|
? CanVault(component, args.User, uid, out _)
|
||||||
: CanVault(component, args.User, args.Dragged, uid, out _);
|
: CanVault(component, args.User, args.Dragged, uid, out _);
|
||||||
|
|
||||||
args.CanDrop = canVault;
|
args.CanDrop = canVault;
|
||||||
|
|
||||||
if (!HasComp<HandsComponent>(args.User))
|
if (!HasComp<HandsComponent>(args.User))
|
||||||
args.CanDrop = false;
|
args.CanDrop = false;
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddClimbableVerb(EntityUid uid, ClimbableComponent component, GetVerbsEvent<AlternativeVerb> args)
|
private void AddClimbableVerb(EntityUid uid, ClimbableComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||||
{
|
{
|
||||||
if (!args.CanAccess || !args.CanInteract || !_actionBlockerSystem.CanMove(args.User))
|
if (!args.CanAccess || !args.CanInteract || !_actionBlockerSystem.CanMove(args.User))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TryComp(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
if (!TryComp(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO VERBS ICON add a climbing icon?
|
// TODO VERBS ICON add a climbing icon?
|
||||||
args.Verbs.Add(new AlternativeVerb
|
args.Verbs.Add(new AlternativeVerb
|
||||||
{
|
{
|
||||||
Act = () => TryClimb(args.User, args.User, args.Target, out _, component),
|
Act = () => TryClimb(args.User, args.User, args.Target, out _, component),
|
||||||
Text = Loc.GetString("comp-climbable-verb-climb")
|
Text = Loc.GetString("comp-climbable-verb-climb")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClimbableDragDrop(EntityUid uid, ClimbableComponent component, ref DragDropTargetEvent args)
|
private void OnClimbableDragDrop(EntityUid uid, ClimbableComponent component, ref DragDropTargetEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TryClimb(args.User, args.Dragged, uid, out _, component);
|
TryClimb(args.User, args.Dragged, uid, out _, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryClimb(
|
public bool TryClimb(
|
||||||
EntityUid user,
|
EntityUid user,
|
||||||
EntityUid entityToMove,
|
EntityUid entityToMove,
|
||||||
EntityUid climbable,
|
EntityUid climbable,
|
||||||
out DoAfterId? id,
|
out DoAfterId? id,
|
||||||
ClimbableComponent? comp = null,
|
ClimbableComponent? comp = null,
|
||||||
ClimbingComponent? climbing = null)
|
ClimbingComponent? climbing = null)
|
||||||
{
|
{
|
||||||
id = null;
|
id = null;
|
||||||
|
|
||||||
if (!Resolve(climbable, ref comp) || !Resolve(entityToMove, ref climbing))
|
if (!Resolve(climbable, ref comp) || !Resolve(entityToMove, ref climbing))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Note, IsClimbing does not mean a DoAfter is active, it means the target has already finished a DoAfter and
|
// 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..
|
// is currently on top of something..
|
||||||
if (climbing.IsClimbing)
|
if (climbing.IsClimbing)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var args = new DoAfterArgs(EntityManager, user, comp.ClimbDelay, new ClimbDoAfterEvent(),
|
var args = new DoAfterArgs(EntityManager, user, comp.ClimbDelay, new ClimbDoAfterEvent(),
|
||||||
entityToMove,
|
entityToMove,
|
||||||
target: climbable,
|
target: climbable,
|
||||||
used: entityToMove)
|
used: entityToMove)
|
||||||
{
|
{
|
||||||
BreakOnTargetMove = true,
|
BreakOnTargetMove = true,
|
||||||
BreakOnUserMove = true,
|
BreakOnUserMove = true,
|
||||||
BreakOnDamage = true
|
BreakOnDamage = true
|
||||||
};
|
};
|
||||||
|
|
||||||
_audio.PlayPredicted(comp.StartClimbSound, climbable, user);
|
_audio.PlayPredicted(comp.StartClimbSound, climbable, user);
|
||||||
return _doAfterSystem.TryStartDoAfter(args, out id);
|
return _doAfterSystem.TryStartDoAfter(args, out id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDoAfter(EntityUid uid, ClimbingComponent component, ClimbDoAfterEvent args)
|
private void OnDoAfter(EntityUid uid, ClimbingComponent component, ClimbDoAfterEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled || args.Cancelled || args.Args.Target == null || args.Args.Used == null)
|
if (args.Handled || args.Cancelled || args.Args.Target == null || args.Args.Used == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Climb(uid, args.Args.User, args.Args.Target.Value, climbing: component);
|
Climb(uid, args.Args.User, args.Args.Target.Value, climbing: component);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Climb(EntityUid uid, EntityUid user, EntityUid climbable, bool silent = false, ClimbingComponent? climbing = null,
|
private void Climb(EntityUid uid, EntityUid user, EntityUid climbable, bool silent = false, ClimbingComponent? climbing = null,
|
||||||
PhysicsComponent? physics = null, FixturesComponent? fixtures = null, ClimbableComponent? comp = null)
|
PhysicsComponent? physics = null, FixturesComponent? fixtures = null, ClimbableComponent? comp = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref climbing, ref physics, ref fixtures, false))
|
if (!Resolve(uid, ref climbing, ref physics, ref fixtures, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!Resolve(climbable, ref comp))
|
if (!Resolve(climbable, ref comp))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ReplaceFixtures(uid, climbing, fixtures))
|
if (!ReplaceFixtures(uid, climbing, fixtures))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var xform = _xformQuery.GetComponent(uid);
|
var xform = _xformQuery.GetComponent(uid);
|
||||||
var (worldPos, worldRot) = _xformSystem.GetWorldPositionRotation(xform);
|
var (worldPos, worldRot) = _xformSystem.GetWorldPositionRotation(xform);
|
||||||
var worldDirection = _xformSystem.GetWorldPosition(climbable) - worldPos;
|
var worldDirection = _xformSystem.GetWorldPosition(climbable) - worldPos;
|
||||||
var distance = worldDirection.Length();
|
var distance = worldDirection.Length();
|
||||||
var parentRot = (worldRot - xform.LocalRotation);
|
var parentRot = (worldRot - xform.LocalRotation);
|
||||||
// Need direction relative to climber's parent.
|
// Need direction relative to climber's parent.
|
||||||
var localDirection = (-parentRot).RotateVec(worldDirection);
|
var localDirection = (-parentRot).RotateVec(worldDirection);
|
||||||
|
|
||||||
// On top of it already so just do it in place.
|
// On top of it already so just do it in place.
|
||||||
if (localDirection.LengthSquared() < 0.01f)
|
if (localDirection.LengthSquared() < 0.01f)
|
||||||
{
|
{
|
||||||
climbing.NextTransition = null;
|
climbing.NextTransition = null;
|
||||||
}
|
}
|
||||||
// VirtualController over to the thing.
|
// VirtualController over to the thing.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var climbDuration = TimeSpan.FromSeconds(distance / climbing.TransitionRate);
|
var climbDuration = TimeSpan.FromSeconds(distance / climbing.TransitionRate);
|
||||||
climbing.NextTransition = _timing.CurTime + climbDuration;
|
climbing.NextTransition = _timing.CurTime + climbDuration;
|
||||||
|
|
||||||
climbing.Direction = localDirection.Normalized() * climbing.TransitionRate;
|
climbing.Direction = localDirection.Normalized() * climbing.TransitionRate;
|
||||||
_actionBlockerSystem.UpdateCanMove(uid);
|
_actionBlockerSystem.UpdateCanMove(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
climbing.IsClimbing = true;
|
climbing.IsClimbing = true;
|
||||||
Dirty(uid, climbing);
|
Dirty(uid, climbing);
|
||||||
|
|
||||||
_audio.PlayPredicted(comp.FinishClimbSound, climbable, user);
|
_audio.PlayPredicted(comp.FinishClimbSound, climbable, user);
|
||||||
|
|
||||||
var startEv = new StartClimbEvent(climbable);
|
var startEv = new StartClimbEvent(climbable);
|
||||||
var climbedEv = new ClimbedOnEvent(uid, user);
|
var climbedEv = new ClimbedOnEvent(uid, user);
|
||||||
RaiseLocalEvent(uid, ref startEv);
|
RaiseLocalEvent(uid, ref startEv);
|
||||||
RaiseLocalEvent(climbable, ref climbedEv);
|
RaiseLocalEvent(climbable, ref climbedEv);
|
||||||
|
|
||||||
if (silent)
|
if (silent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string selfMessage;
|
string selfMessage;
|
||||||
string othersMessage;
|
string othersMessage;
|
||||||
|
|
||||||
if (user == uid)
|
if (user == uid)
|
||||||
{
|
{
|
||||||
othersMessage = Loc.GetString("comp-climbable-user-climbs-other",
|
othersMessage = Loc.GetString("comp-climbable-user-climbs-other",
|
||||||
("user", Identity.Entity(uid, EntityManager)),
|
("user", Identity.Entity(uid, EntityManager)),
|
||||||
("climbable", climbable));
|
("climbable", climbable));
|
||||||
|
|
||||||
selfMessage = Loc.GetString("comp-climbable-user-climbs", ("climbable", climbable));
|
selfMessage = Loc.GetString("comp-climbable-user-climbs", ("climbable", climbable));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
othersMessage = Loc.GetString("comp-climbable-user-climbs-force-other",
|
othersMessage = Loc.GetString("comp-climbable-user-climbs-force-other",
|
||||||
("user", Identity.Entity(user, EntityManager)),
|
("user", Identity.Entity(user, EntityManager)),
|
||||||
("moved-user", Identity.Entity(uid, EntityManager)), ("climbable", climbable));
|
("moved-user", Identity.Entity(uid, EntityManager)), ("climbable", climbable));
|
||||||
|
|
||||||
selfMessage = Loc.GetString("comp-climbable-user-climbs-force", ("moved-user", Identity.Entity(uid, EntityManager)),
|
selfMessage = Loc.GetString("comp-climbable-user-climbs-force", ("moved-user", Identity.Entity(uid, EntityManager)),
|
||||||
("climbable", climbable));
|
("climbable", climbable));
|
||||||
}
|
}
|
||||||
|
|
||||||
_popupSystem.PopupEntity(othersMessage, uid, Filter.PvsExcept(user, entityManager: EntityManager), true);
|
_popupSystem.PopupEntity(othersMessage, uid, Filter.PvsExcept(user, entityManager: EntityManager), true);
|
||||||
_popupSystem.PopupClient(selfMessage, uid, user);
|
_popupSystem.PopupClient(selfMessage, uid, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces the current fixtures with non-climbing collidable versions so that climb end can be detected
|
/// Replaces the current fixtures with non-climbing collidable versions so that climb end can be detected
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns whether adding the new fixtures was successful</returns>
|
/// <returns>Returns whether adding the new fixtures was successful</returns>
|
||||||
private bool ReplaceFixtures(EntityUid uid, ClimbingComponent climbingComp, FixturesComponent fixturesComp)
|
private bool ReplaceFixtures(EntityUid uid, ClimbingComponent climbingComp, FixturesComponent fixturesComp)
|
||||||
{
|
{
|
||||||
// Swap fixtures
|
// Swap fixtures
|
||||||
foreach (var (name, fixture) in fixturesComp.Fixtures)
|
foreach (var (name, fixture) in fixturesComp.Fixtures)
|
||||||
{
|
{
|
||||||
if (climbingComp.DisabledFixtureMasks.ContainsKey(name)
|
if (climbingComp.DisabledFixtureMasks.ContainsKey(name)
|
||||||
|| fixture.Hard == false
|
|| fixture.Hard == false
|
||||||
|| (fixture.CollisionMask & ClimbingCollisionGroup) == 0)
|
|| (fixture.CollisionMask & ClimbingCollisionGroup) == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
climbingComp.DisabledFixtureMasks.Add(name, fixture.CollisionMask & ClimbingCollisionGroup);
|
climbingComp.DisabledFixtureMasks.Add(name, fixture.CollisionMask & ClimbingCollisionGroup);
|
||||||
_physics.SetCollisionMask(uid, name, fixture, fixture.CollisionMask & ~ClimbingCollisionGroup, fixturesComp);
|
_physics.SetCollisionMask(uid, name, fixture, fixture.CollisionMask & ~ClimbingCollisionGroup, fixturesComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_fixtureSystem.TryCreateFixture(
|
if (!_fixtureSystem.TryCreateFixture(
|
||||||
uid,
|
uid,
|
||||||
new PhysShapeCircle(0.35f),
|
new PhysShapeCircle(0.35f),
|
||||||
ClimbingFixtureName,
|
ClimbingFixtureName,
|
||||||
collisionLayer: (int) CollisionGroup.None,
|
collisionLayer: (int) CollisionGroup.None,
|
||||||
collisionMask: ClimbingCollisionGroup,
|
collisionMask: ClimbingCollisionGroup,
|
||||||
hard: false,
|
hard: false,
|
||||||
manager: fixturesComp))
|
manager: fixturesComp))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClimbEndCollide(EntityUid uid, ClimbingComponent component, ref EndCollideEvent args)
|
private void OnClimbEndCollide(EntityUid uid, ClimbingComponent component, ref EndCollideEvent args)
|
||||||
{
|
{
|
||||||
if (args.OurFixtureId != ClimbingFixtureName
|
if (args.OurFixtureId != ClimbingFixtureName
|
||||||
|| !component.IsClimbing
|
|| !component.IsClimbing
|
||||||
|| component.NextTransition != null)
|
|| component.NextTransition != null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var otherFixture in args.OurFixture.Contacts.Keys)
|
foreach (var otherFixture in args.OurFixture.Contacts.Keys)
|
||||||
{
|
{
|
||||||
// If it's the other fixture then ignore em
|
// If it's the other fixture then ignore em
|
||||||
if (otherFixture == args.OtherFixture)
|
if (otherFixture == args.OtherFixture)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If still colliding with a climbable, do not stop climbing
|
// If still colliding with a climbable, do not stop climbing
|
||||||
if (HasComp<ClimbableComponent>(otherFixture.Owner))
|
if (HasComp<ClimbableComponent>(otherFixture.Owner))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StopClimb(uid, component);
|
StopClimb(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StopClimb(EntityUid uid, ClimbingComponent? climbing = null, FixturesComponent? fixtures = null)
|
private void StopClimb(EntityUid uid, ClimbingComponent? climbing = null, FixturesComponent? fixtures = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref climbing, ref fixtures, false))
|
if (!Resolve(uid, ref climbing, ref fixtures, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var (name, fixtureMask) in climbing.DisabledFixtureMasks)
|
foreach (var (name, fixtureMask) in climbing.DisabledFixtureMasks)
|
||||||
{
|
{
|
||||||
if (!fixtures.Fixtures.TryGetValue(name, out var fixture))
|
if (!fixtures.Fixtures.TryGetValue(name, out var fixture))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_physics.SetCollisionMask(uid, name, fixture, fixture.CollisionMask | fixtureMask, fixtures);
|
_physics.SetCollisionMask(uid, name, fixture, fixture.CollisionMask | fixtureMask, fixtures);
|
||||||
}
|
}
|
||||||
|
|
||||||
climbing.DisabledFixtureMasks.Clear();
|
climbing.DisabledFixtureMasks.Clear();
|
||||||
_fixtureSystem.DestroyFixture(uid, ClimbingFixtureName, manager: fixtures);
|
_fixtureSystem.DestroyFixture(uid, ClimbingFixtureName, manager: fixtures);
|
||||||
climbing.IsClimbing = false;
|
climbing.IsClimbing = false;
|
||||||
climbing.NextTransition = null;
|
climbing.NextTransition = null;
|
||||||
var ev = new EndClimbEvent();
|
var ev = new EndClimbEvent();
|
||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
Dirty(uid, climbing);
|
Dirty(uid, climbing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the user can vault the target
|
/// Checks if the user can vault the target
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="component">The component of the entity that is being vaulted</param>
|
/// <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="user">The entity that wants to vault</param>
|
||||||
/// <param name="target">The object that is being vaulted</param>
|
/// <param name="target">The object that is being vaulted</param>
|
||||||
/// <param name="reason">The reason why it cant be dropped</param>
|
/// <param name="reason">The reason why it cant be dropped</param>
|
||||||
public bool CanVault(ClimbableComponent component, EntityUid user, EntityUid target, out string reason)
|
public bool CanVault(ClimbableComponent component, EntityUid user, EntityUid target, out string reason)
|
||||||
{
|
{
|
||||||
if (!_actionBlockerSystem.CanInteract(user, target))
|
if (!_actionBlockerSystem.CanInteract(user, target))
|
||||||
{
|
{
|
||||||
reason = Loc.GetString("comp-climbable-cant-interact");
|
reason = Loc.GetString("comp-climbable-cant-interact");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HasComp<ClimbingComponent>(user)
|
if (!HasComp<ClimbingComponent>(user)
|
||||||
|| !TryComp(user, out BodyComponent? body)
|
|| !TryComp(user, out BodyComponent? body)
|
||||||
|| !_bodySystem.BodyHasPartType(user, BodyPartType.Leg, body)
|
|| !_bodySystem.BodyHasPartType(user, BodyPartType.Leg, body)
|
||||||
|| !_bodySystem.BodyHasPartType(user, BodyPartType.Foot, body))
|
|| !_bodySystem.BodyHasPartType(user, BodyPartType.Foot, body))
|
||||||
{
|
{
|
||||||
reason = Loc.GetString("comp-climbable-cant-climb");
|
reason = Loc.GetString("comp-climbable-cant-climb");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_interactionSystem.InRangeUnobstructed(user, target, component.Range))
|
if (!_interactionSystem.InRangeUnobstructed(user, target, component.Range))
|
||||||
{
|
{
|
||||||
reason = Loc.GetString("comp-climbable-cant-reach");
|
reason = Loc.GetString("comp-climbable-cant-reach");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
reason = string.Empty;
|
reason = string.Empty;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the user can vault the dragged entity onto the the target
|
/// Checks if the user can vault the dragged entity onto the the target
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="component">The climbable component of the object being vaulted onto</param>
|
/// <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="user">The user that wants to vault the entity</param>
|
||||||
/// <param name="dragged">The entity that is being vaulted</param>
|
/// <param name="dragged">The entity that is being vaulted</param>
|
||||||
/// <param name="target">The object that is being vaulted onto</param>
|
/// <param name="target">The object that is being vaulted onto</param>
|
||||||
/// <param name="reason">The reason why it cant be dropped</param>
|
/// <param name="reason">The reason why it cant be dropped</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool CanVault(ClimbableComponent component, EntityUid user, EntityUid dragged, EntityUid target,
|
public bool CanVault(ClimbableComponent component, EntityUid user, EntityUid dragged, EntityUid target,
|
||||||
out string reason)
|
out string reason)
|
||||||
{
|
{
|
||||||
if (!_actionBlockerSystem.CanInteract(user, dragged) || !_actionBlockerSystem.CanInteract(user, target))
|
if (!_actionBlockerSystem.CanInteract(user, dragged) || !_actionBlockerSystem.CanInteract(user, target))
|
||||||
{
|
{
|
||||||
reason = Loc.GetString("comp-climbable-cant-interact");
|
reason = Loc.GetString("comp-climbable-cant-interact");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HasComp<ClimbingComponent>(dragged))
|
if (!HasComp<ClimbingComponent>(dragged))
|
||||||
{
|
{
|
||||||
reason = Loc.GetString("comp-climbable-cant-climb");
|
reason = Loc.GetString("comp-climbable-cant-climb");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Ignored(EntityUid entity) => entity == target || entity == user || entity == dragged;
|
bool Ignored(EntityUid entity) => entity == target || entity == user || entity == dragged;
|
||||||
|
|
||||||
if (!_interactionSystem.InRangeUnobstructed(user, target, component.Range, predicate: Ignored)
|
if (!_interactionSystem.InRangeUnobstructed(user, target, component.Range, predicate: Ignored)
|
||||||
|| !_interactionSystem.InRangeUnobstructed(user, dragged, component.Range, predicate: Ignored))
|
|| !_interactionSystem.InRangeUnobstructed(user, dragged, component.Range, predicate: Ignored))
|
||||||
{
|
{
|
||||||
reason = Loc.GetString("comp-climbable-cant-reach");
|
reason = Loc.GetString("comp-climbable-cant-reach");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
reason = string.Empty;
|
reason = string.Empty;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForciblySetClimbing(EntityUid uid, EntityUid climbable, ClimbingComponent? component = null)
|
public void ForciblySetClimbing(EntityUid uid, EntityUid climbable, ClimbingComponent? component = null)
|
||||||
{
|
{
|
||||||
Climb(uid, uid, climbable, true, component);
|
Climb(uid, uid, climbable, true, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBuckleChange(EntityUid uid, ClimbingComponent component, ref BuckleChangeEvent args)
|
private void OnBuckleChange(EntityUid uid, ClimbingComponent component, ref BuckleChangeEvent args)
|
||||||
{
|
{
|
||||||
if (!args.Buckling)
|
if (!args.Buckling)
|
||||||
return;
|
return;
|
||||||
StopClimb(uid, component);
|
StopClimb(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGlassClimbed(EntityUid uid, GlassTableComponent component, ref ClimbedOnEvent args)
|
private void OnGlassClimbed(EntityUid uid, GlassTableComponent component, ref ClimbedOnEvent args)
|
||||||
{
|
{
|
||||||
if (TryComp<PhysicsComponent>(args.Climber, out var physics) && physics.Mass <= component.MassLimit)
|
if (TryComp<PhysicsComponent>(args.Climber, out var physics) && physics.Mass <= component.MassLimit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_damageableSystem.TryChangeDamage(args.Climber, component.ClimberDamage, origin: args.Climber);
|
_damageableSystem.TryChangeDamage(args.Climber, component.ClimberDamage, origin: args.Climber);
|
||||||
_damageableSystem.TryChangeDamage(uid, component.TableDamage, origin: args.Climber);
|
_damageableSystem.TryChangeDamage(uid, component.TableDamage, origin: args.Climber);
|
||||||
_stunSystem.TryParalyze(args.Climber, TimeSpan.FromSeconds(component.StunTime), true);
|
_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
|
// Not shown to the user, since they already get a 'you climb on the glass table' popup
|
||||||
_popupSystem.PopupEntity(
|
_popupSystem.PopupEntity(
|
||||||
Loc.GetString("glass-table-shattered-others", ("table", uid), ("climber", Identity.Entity(args.Climber, EntityManager))), args.Climber,
|
Loc.GetString("glass-table-shattered-others", ("table", uid), ("climber", Identity.Entity(args.Climber, EntityManager))), args.Climber,
|
||||||
Filter.PvsExcept(args.Climber), true);
|
Filter.PvsExcept(args.Climber), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
private sealed partial class ClimbDoAfterEvent : SimpleDoAfterEvent
|
private sealed partial class ClimbDoAfterEvent : SimpleDoAfterEvent
|
||||||
|
|||||||
Reference in New Issue
Block a user