@@ -45,7 +45,6 @@ public sealed class ThrusterSystem : EntitySystem
|
||||
SubscribeLocalEvent<ThrusterComponent, ComponentShutdown>(OnThrusterShutdown);
|
||||
SubscribeLocalEvent<ThrusterComponent, PowerChangedEvent>(OnPowerChange);
|
||||
SubscribeLocalEvent<ThrusterComponent, AnchorStateChangedEvent>(OnAnchorChange);
|
||||
SubscribeLocalEvent<ThrusterComponent, ReAnchorEvent>(OnThrusterReAnchor);
|
||||
SubscribeLocalEvent<ThrusterComponent, MoveEvent>(OnRotate);
|
||||
SubscribeLocalEvent<ThrusterComponent, IsHotEvent>(OnIsHotEvent);
|
||||
SubscribeLocalEvent<ThrusterComponent, StartCollideEvent>(OnStartCollide);
|
||||
@@ -151,9 +150,9 @@ public sealed class ThrusterSystem : EntitySystem
|
||||
private void OnRotate(EntityUid uid, ThrusterComponent component, ref MoveEvent args)
|
||||
{
|
||||
// TODO: Disable visualizer for old direction
|
||||
// TODO: Don't make them rotatable and make it require anchoring.
|
||||
|
||||
if (!component.Enabled ||
|
||||
component.Type != ThrusterType.Linear ||
|
||||
!EntityManager.TryGetComponent(uid, out TransformComponent? xform) ||
|
||||
!EntityManager.TryGetComponent(xform.GridUid, out ShuttleComponent? shuttleComponent))
|
||||
{
|
||||
@@ -176,22 +175,44 @@ public sealed class ThrusterSystem : EntitySystem
|
||||
// Disable if new tile invalid
|
||||
if (component.IsOn && !canEnable)
|
||||
{
|
||||
DisableThruster(uid, component, xform, args.OldRotation);
|
||||
DisableThruster(uid, component, args.OldPosition.EntityId, xform, args.OldRotation);
|
||||
return;
|
||||
}
|
||||
|
||||
var oldDirection = (int) args.OldRotation.GetCardinalDir() / 2;
|
||||
var direction = (int) args.NewRotation.GetCardinalDir() / 2;
|
||||
var oldShuttleComponent = shuttleComponent;
|
||||
|
||||
shuttleComponent.LinearThrust[oldDirection] -= component.Thrust;
|
||||
shuttleComponent.BaseLinearThrust[oldDirection] -= component.BaseThrust;
|
||||
DebugTools.Assert(shuttleComponent.LinearThrusters[oldDirection].Contains(uid));
|
||||
shuttleComponent.LinearThrusters[oldDirection].Remove(uid);
|
||||
if (args.ParentChanged)
|
||||
{
|
||||
oldShuttleComponent = Comp<ShuttleComponent>(args.OldPosition.EntityId);
|
||||
|
||||
shuttleComponent.LinearThrust[direction] += component.Thrust;
|
||||
shuttleComponent.BaseLinearThrust[direction] += component.BaseThrust;
|
||||
DebugTools.Assert(!shuttleComponent.LinearThrusters[direction].Contains(uid));
|
||||
shuttleComponent.LinearThrusters[direction].Add(uid);
|
||||
// If no parent change doesn't matter for angular.
|
||||
if (component.Type == ThrusterType.Angular)
|
||||
{
|
||||
oldShuttleComponent.AngularThrust -= component.Thrust;
|
||||
DebugTools.Assert(oldShuttleComponent.AngularThrusters.Contains(uid));
|
||||
oldShuttleComponent.AngularThrusters.Remove(uid);
|
||||
|
||||
shuttleComponent.AngularThrust += component.Thrust;
|
||||
DebugTools.Assert(!shuttleComponent.AngularThrusters.Contains(uid));
|
||||
shuttleComponent.AngularThrusters.Add(uid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (component.Type == ThrusterType.Linear)
|
||||
{
|
||||
oldShuttleComponent.LinearThrust[oldDirection] -= component.Thrust;
|
||||
oldShuttleComponent.BaseLinearThrust[oldDirection] -= component.BaseThrust;
|
||||
DebugTools.Assert(oldShuttleComponent.LinearThrusters[oldDirection].Contains(uid));
|
||||
oldShuttleComponent.LinearThrusters[oldDirection].Remove(uid);
|
||||
|
||||
shuttleComponent.LinearThrust[direction] += component.Thrust;
|
||||
shuttleComponent.BaseLinearThrust[direction] += component.BaseThrust;
|
||||
DebugTools.Assert(!shuttleComponent.LinearThrusters[direction].Contains(uid));
|
||||
shuttleComponent.LinearThrusters[direction].Add(uid);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAnchorChange(EntityUid uid, ThrusterComponent component, ref AnchorStateChangedEvent args)
|
||||
@@ -206,14 +227,6 @@ public sealed class ThrusterSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnThrusterReAnchor(EntityUid uid, ThrusterComponent component, ref ReAnchorEvent args)
|
||||
{
|
||||
DisableThruster(uid, component, args.OldGrid);
|
||||
|
||||
if (CanEnable(uid, component))
|
||||
EnableThruster(uid, component);
|
||||
}
|
||||
|
||||
private void OnThrusterInit(EntityUid uid, ThrusterComponent component, ComponentInit args)
|
||||
{
|
||||
_ambient.SetAmbience(uid, false);
|
||||
|
||||
Reference in New Issue
Block a user