Add minimum distance for pilot breaking (#5232)
This commit is contained in:
@@ -10,6 +10,8 @@ using Content.Shared.Tag;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Shuttles
|
||||
@@ -72,7 +74,16 @@ namespace Content.Server.Shuttles
|
||||
/// </summary>
|
||||
private void HandlePilotMove(EntityUid uid, PilotComponent component, ref MoveEvent args)
|
||||
{
|
||||
if (component.Console == null) return;
|
||||
if (component.Console == null || component.Position == null)
|
||||
{
|
||||
DebugTools.Assert(component.Position == null && component.Console == null);
|
||||
EntityManager.RemoveComponent<PilotComponent>(uid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.NewPosition.TryDistance(EntityManager, component.Position.Value, out var distance) &&
|
||||
distance < PilotComponent.BreakDistance) return;
|
||||
|
||||
RemovePilot(component);
|
||||
}
|
||||
|
||||
@@ -138,6 +149,7 @@ namespace Content.Server.Shuttles
|
||||
|
||||
entity.PopupMessage(Loc.GetString("shuttle-pilot-start"));
|
||||
pilotComponent.Console = component;
|
||||
pilotComponent.Position = EntityManager.GetComponent<TransformComponent>(entity.Uid).Coordinates;
|
||||
pilotComponent.Dirty();
|
||||
}
|
||||
|
||||
@@ -148,6 +160,7 @@ namespace Content.Server.Shuttles
|
||||
if (console is not ShuttleConsoleComponent helmsman) return;
|
||||
|
||||
pilotComponent.Console = null;
|
||||
pilotComponent.Position = null;
|
||||
|
||||
if (!helmsman.SubscribedPilots.Remove(pilotComponent)) return;
|
||||
|
||||
@@ -157,7 +170,9 @@ namespace Content.Server.Shuttles
|
||||
}
|
||||
|
||||
pilotComponent.Owner.PopupMessage(Loc.GetString("shuttle-pilot-end"));
|
||||
EntityManager.RemoveComponent<PilotComponent>(pilotComponent.Owner.Uid);
|
||||
|
||||
if (pilotComponent.LifeStage < ComponentLifeStage.Stopping)
|
||||
EntityManager.RemoveComponent<PilotComponent>(pilotComponent.Owner.Uid);
|
||||
}
|
||||
|
||||
public void RemovePilot(IEntity entity)
|
||||
|
||||
Reference in New Issue
Block a user