Fix some thrust stuff (#5577)
This commit is contained in:
@@ -69,9 +69,9 @@ namespace Content.Server.Shuttles.EntitySystems
|
|||||||
|
|
||||||
args.PushMarkup(enabled);
|
args.PushMarkup(enabled);
|
||||||
|
|
||||||
var xform = EntityManager.GetComponent<TransformComponent>(uid);
|
if (component.Type == ThrusterType.Linear &&
|
||||||
|
EntityManager.TryGetComponent(uid, out TransformComponent? xform) &&
|
||||||
if (xform.Anchored)
|
xform.Anchored)
|
||||||
{
|
{
|
||||||
var nozzleDir = Loc.GetString("thruster-comp-nozzle-direction",
|
var nozzleDir = Loc.GetString("thruster-comp-nozzle-direction",
|
||||||
("direction", xform.LocalRotation.Opposite().ToWorldVec().GetDir().ToString().ToLowerInvariant()));
|
("direction", xform.LocalRotation.Opposite().ToWorldVec().GetDir().ToString().ToLowerInvariant()));
|
||||||
@@ -136,11 +136,33 @@ namespace Content.Server.Shuttles.EntitySystems
|
|||||||
{
|
{
|
||||||
// TODO: Disable visualizer for old direction
|
// TODO: Disable visualizer for old direction
|
||||||
|
|
||||||
if (!component.IsOn ||
|
if (!component.Enabled ||
|
||||||
component.Type != ThrusterType.Linear ||
|
component.Type != ThrusterType.Linear ||
|
||||||
!EntityManager.TryGetComponent(uid, out TransformComponent? xform) ||
|
!EntityManager.TryGetComponent(uid, out TransformComponent? xform) ||
|
||||||
!_mapManager.TryGetGrid(xform.GridID, out var grid) ||
|
!_mapManager.TryGetGrid(xform.GridID, out var grid) ||
|
||||||
!EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttleComponent)) return;
|
!EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttleComponent))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var canEnable = CanEnable(uid, component);
|
||||||
|
|
||||||
|
// If it's not on then don't enable it inadvertantly (given we don't have an old rotation)
|
||||||
|
if (!canEnable && !component.IsOn) return;
|
||||||
|
|
||||||
|
// Enable it if it was turned off but new tile is valid
|
||||||
|
if (!component.IsOn && canEnable)
|
||||||
|
{
|
||||||
|
EnableThruster(uid, component);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable if new tile invalid
|
||||||
|
if (component.IsOn && !canEnable)
|
||||||
|
{
|
||||||
|
DisableThruster(uid, component, xform, args.OldRotation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var oldDirection = (int) args.OldRotation.GetCardinalDir() / 2;
|
var oldDirection = (int) args.OldRotation.GetCardinalDir() / 2;
|
||||||
var direction = (int) args.NewRotation.GetCardinalDir() / 2;
|
var direction = (int) args.NewRotation.GetCardinalDir() / 2;
|
||||||
@@ -261,11 +283,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to disable the thruster.
|
/// Tries to disable the thruster.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uid"></param>
|
public void DisableThruster(EntityUid uid, ThrusterComponent component, TransformComponent? xform = null, Angle? angle = null)
|
||||||
/// <param name="component"></param>
|
|
||||||
/// <param name="xform"></param>
|
|
||||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
|
||||||
public void DisableThruster(EntityUid uid, ThrusterComponent component, TransformComponent? xform = null)
|
|
||||||
{
|
{
|
||||||
if (!component.IsOn ||
|
if (!component.IsOn ||
|
||||||
!Resolve(uid, ref xform) ||
|
!Resolve(uid, ref xform) ||
|
||||||
@@ -280,7 +298,8 @@ namespace Content.Server.Shuttles.EntitySystems
|
|||||||
switch (component.Type)
|
switch (component.Type)
|
||||||
{
|
{
|
||||||
case ThrusterType.Linear:
|
case ThrusterType.Linear:
|
||||||
var direction = ((int) xform.LocalRotation.GetCardinalDir() / 2);
|
angle ??= xform.LocalRotation;
|
||||||
|
var direction = (int) angle.Value.GetCardinalDir() / 2;
|
||||||
|
|
||||||
shuttleComponent.LinearThrusterImpulse[direction] -= component.Impulse;
|
shuttleComponent.LinearThrusterImpulse[direction] -= component.Impulse;
|
||||||
DebugTools.Assert(shuttleComponent.LinearThrusters[direction].Contains(component));
|
DebugTools.Assert(shuttleComponent.LinearThrusters[direction].Contains(component));
|
||||||
|
|||||||
Reference in New Issue
Block a user