Fix disposal pipe visuals (#10873)
This commit is contained in:
@@ -37,7 +37,8 @@ namespace Content.Server.Disposal.Tube.Components
|
|||||||
public abstract Direction NextDirection(DisposalHolderComponent holder);
|
public abstract Direction NextDirection(DisposalHolderComponent holder);
|
||||||
|
|
||||||
// TODO: Make disposal pipes extend the grid
|
// TODO: Make disposal pipes extend the grid
|
||||||
private void Connect()
|
// ???
|
||||||
|
public void Connect()
|
||||||
{
|
{
|
||||||
if (_connected)
|
if (_connected)
|
||||||
{
|
{
|
||||||
@@ -89,50 +90,6 @@ namespace Content.Server.Disposal.Tube.Components
|
|||||||
Owner.PopupMessage(entity, Loc.GetString("disposal-tube-component-popup-directions-text", ("directions", directions)));
|
Owner.PopupMessage(entity, Loc.GetString("disposal-tube-component-popup-directions-text", ("directions", directions)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateVisualState()
|
|
||||||
{
|
|
||||||
if (!_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO this should just generalized into some anchored-visuals system/comp, this has nothing to do with disposal tubes.
|
|
||||||
var state = _entMan.GetComponent<TransformComponent>(Owner).Anchored
|
|
||||||
? DisposalTubeVisualState.Anchored
|
|
||||||
: DisposalTubeVisualState.Free;
|
|
||||||
|
|
||||||
appearance.SetData(DisposalTubeVisuals.VisualState, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AnchoredChanged()
|
|
||||||
{
|
|
||||||
if (!_entMan.TryGetComponent(Owner, out PhysicsComponent? physics))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (physics.BodyType == BodyType.Static)
|
|
||||||
{
|
|
||||||
OnAnchor();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OnUnAnchor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnAnchor()
|
|
||||||
{
|
|
||||||
Connect();
|
|
||||||
UpdateVisualState();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnUnAnchor()
|
|
||||||
{
|
|
||||||
Disconnect();
|
|
||||||
UpdateVisualState();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -141,20 +98,6 @@ namespace Content.Server.Disposal.Tube.Components
|
|||||||
Owner.EnsureComponent<AnchorableComponent>();
|
Owner.EnsureComponent<AnchorableComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Startup()
|
|
||||||
{
|
|
||||||
base.Startup();
|
|
||||||
|
|
||||||
Owner.EnsureComponent<PhysicsComponent>(out var physicsComponent);
|
|
||||||
if (physicsComponent.BodyType != BodyType.Static)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Connect();
|
|
||||||
UpdateVisualState();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnRemove()
|
protected override void OnRemove()
|
||||||
{
|
{
|
||||||
base.OnRemove();
|
base.OnRemove();
|
||||||
|
|||||||
@@ -20,17 +20,23 @@ namespace Content.Server.Disposal.Tube
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<DisposalTubeComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
|
SubscribeLocalEvent<DisposalTubeComponent, AnchorStateChangedEvent>(OnAnchorChange);
|
||||||
SubscribeLocalEvent<DisposalTubeComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
SubscribeLocalEvent<DisposalTubeComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
||||||
SubscribeLocalEvent<DisposalTubeComponent, BreakageEventArgs>(OnBreak);
|
SubscribeLocalEvent<DisposalTubeComponent, BreakageEventArgs>(OnBreak);
|
||||||
SubscribeLocalEvent<DisposalRouterComponent, ActivatableUIOpenAttemptEvent>(OnOpenRouterUIAttempt);
|
SubscribeLocalEvent<DisposalRouterComponent, ActivatableUIOpenAttemptEvent>(OnOpenRouterUIAttempt);
|
||||||
SubscribeLocalEvent<DisposalTaggerComponent, ActivatableUIOpenAttemptEvent>(OnOpenTaggerUIAttempt);
|
SubscribeLocalEvent<DisposalTaggerComponent, ActivatableUIOpenAttemptEvent>(OnOpenTaggerUIAttempt);
|
||||||
|
SubscribeLocalEvent<DisposalTubeComponent, ComponentStartup>(OnStartup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStartup(EntityUid uid, DisposalTubeComponent component, ComponentStartup args)
|
||||||
|
{
|
||||||
|
UpdateAnchored(uid, component, Transform(uid).Anchored);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRelayMovement(EntityUid uid, DisposalTubeComponent component, ref ContainerRelayMovementEntityEvent args)
|
private void OnRelayMovement(EntityUid uid, DisposalTubeComponent component, ref ContainerRelayMovementEntityEvent args)
|
||||||
@@ -108,12 +114,25 @@ namespace Content.Server.Disposal.Tube
|
|||||||
router.UserInterface?.SetState(new SharedDisposalRouterComponent.DisposalRouterUserInterfaceState(taglist.ToString()));
|
router.UserInterface?.SetState(new SharedDisposalRouterComponent.DisposalRouterUserInterfaceState(taglist.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void BodyTypeChanged(
|
private void OnAnchorChange(EntityUid uid, DisposalTubeComponent component, ref AnchorStateChangedEvent args)
|
||||||
EntityUid uid,
|
|
||||||
DisposalTubeComponent component,
|
|
||||||
ref PhysicsBodyTypeChangedEvent args)
|
|
||||||
{
|
{
|
||||||
component.AnchoredChanged();
|
UpdateAnchored(uid, component, args.Anchored);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateAnchored(EntityUid uid, DisposalTubeComponent component, bool anchored)
|
||||||
|
{
|
||||||
|
if (anchored)
|
||||||
|
{
|
||||||
|
component.Connect();
|
||||||
|
|
||||||
|
// TODO this visual data should just generalized into some anchored-visuals system/comp, this has nothing to do with disposal tubes.
|
||||||
|
_appearanceSystem.SetData(uid, DisposalTubeVisuals.VisualState, DisposalTubeVisualState.Anchored);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
component.Disconnect();
|
||||||
|
_appearanceSystem.SetData(uid, DisposalTubeVisuals.VisualState, DisposalTubeVisualState.Free);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDisposalTubeComponent? NextTubeFor(EntityUid target, Direction nextDirection, IDisposalTubeComponent? targetTube = null)
|
public IDisposalTubeComponent? NextTubeFor(EntityUid target, Direction nextDirection, IDisposalTubeComponent? targetTube = null)
|
||||||
|
|||||||
Reference in New Issue
Block a user