-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
516 additions
and
61 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Content.Client/_White/Plumbing/PlumbingPipeVisualiserSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Content.Shared._White.Plumbing; | ||
using Content.Shared.Wires; | ||
using Robust.Client.GameObjects; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Content.Client._White.Plumbing; | ||
|
||
public sealed class PlumbingPipeVisualiserSystem : VisualizerSystem<PlumbingPipeVisComponent> | ||
{ | ||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<PlumbingPipeVisComponent, AppearanceChangeEvent>(OnAppearanceChange); | ||
} | ||
|
||
protected override void OnAppearanceChange(EntityUid uid, PlumbingPipeVisComponent component, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite == null) | ||
return; | ||
|
||
//if (!args.Sprite.Visible) | ||
//{ | ||
// // This entity is probably below a floor and is not even visible to the user -> don't bother updating sprite data. | ||
// // Note that if the subfloor visuals change, then another AppearanceChangeEvent will get triggered. | ||
// return; | ||
//} | ||
|
||
if (!AppearanceSystem.TryGetData<WireVisDirFlags>(uid, WireVisVisuals.ConnectedMask, out var mask, args.Component)) | ||
mask = WireVisDirFlags.None; | ||
|
||
args.Sprite.LayerSetState(0, $"pipe_{(int)mask}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using Content.Shared._White.Plumbing; | ||
using Robust.Client.GameObjects; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Content.Client._White.Plumbing; | ||
|
||
public sealed class PlumbingSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SpriteSystem _sprite = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<PlumbingInputOutputVisualiserComponent, ComponentInit>(OnInputOutputVisualiserInit); | ||
SubscribeLocalEvent<PlumbingInputOutputVisualiserComponent, MoveEvent>(OnInputOutputVisualiserMove); | ||
|
||
} | ||
public void UpdatePipeLayer(SpriteComponent comp, object key, Direction dir) | ||
{ | ||
if (dir == Direction.Invalid) | ||
{ | ||
comp.LayerSetVisible(key, false); | ||
return; | ||
} | ||
comp.LayerSetVisible(key, true); | ||
|
||
UpdatePipeLayer(comp, key, dir.ToAngle()); | ||
} | ||
public void UpdatePipeLayer(SpriteComponent comp, object key, Angle angle) | ||
{ | ||
comp.LayerSetRotation(key, angle); // something fishy goin' on 'ere | ||
} | ||
|
||
private void OnInputOutputVisualiserInit(EntityUid uid, PlumbingInputOutputVisualiserComponent comp, ComponentInit args) | ||
{ | ||
var spriteComp = Comp<SpriteComponent>(uid); | ||
spriteComp.LayerSetRenderingStrategy(0, LayerRenderingStrategy.NoRotation); | ||
|
||
spriteComp.LayerMapSet(PlumbingInputOutputLayers.InputLayer, spriteComp.AddLayerState("base", "_White/Structures/Machines/Plumbing/machinepipe.rsi", 0)); | ||
spriteComp.LayerMapSet(PlumbingInputOutputLayers.OutputLayer, spriteComp.AddLayerState("base", "_White/Structures/Machines/Plumbing/machinepipe.rsi", 0)); | ||
|
||
spriteComp.LayerSetColor(PlumbingInputOutputLayers.InputLayer, new Color(255, 111, 111)); | ||
spriteComp.LayerSetColor(PlumbingInputOutputLayers.OutputLayer, new Color(111, 111, 255)); | ||
UpdatePipeLayer(spriteComp, PlumbingInputOutputLayers.InputLayer, comp.InputDir); | ||
UpdatePipeLayer(spriteComp, PlumbingInputOutputLayers.OutputLayer, comp.OutputDir); | ||
|
||
//var xform = Comp<TransformComponent>(uid); | ||
//comp.InputAngleDiff = xform.LocalRotation - comp.InputDir.ToAngle(); | ||
//comp.OutputAngleDiff = xform.LocalRotation - comp.OutputDir.ToAngle(); | ||
// | ||
//UpdatePipeLayer(spriteComp, PlumbingInputOutputLayers.InputLayer, xform.LocalRotation + comp.InputAngleDiff); | ||
//UpdatePipeLayer(spriteComp, PlumbingInputOutputLayers.OutputLayer, xform.LocalRotation + comp.OutputAngleDiff); | ||
|
||
} | ||
private void OnInputOutputVisualiserAutoState(EntityUid uid, PlumbingInputOutputVisualiserComponent comp, ref AfterAutoHandleStateEvent args) | ||
{ | ||
var spriteComp = Comp<SpriteComponent>(uid); | ||
UpdatePipeLayer(spriteComp, PlumbingInputOutputLayers.InputLayer, comp.InputDir); | ||
UpdatePipeLayer(spriteComp, PlumbingInputOutputLayers.OutputLayer, comp.OutputDir); | ||
} | ||
|
||
private void OnInputOutputVisualiserMove(EntityUid uid, PlumbingInputOutputVisualiserComponent comp, ref MoveEvent args) | ||
{ | ||
//var spriteComp = Comp<SpriteComponent>(uid); | ||
//UpdatePipeLayer(spriteComp, PlumbingInputOutputLayers.InputLayer, args.NewRotation/* + comp.InputAngleDiff*/); | ||
//UpdatePipeLayer(spriteComp, PlumbingInputOutputLayers.OutputLayer, args.NewRotation/* + comp.OutputAngleDiff*/); | ||
} | ||
} | ||
|
||
public enum PlumbingInputOutputLayers | ||
{ | ||
InputLayer, | ||
OutputLayer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Content.Server.NodeContainer.EntitySystems; | ||
using Content.Server.NodeContainer.Nodes; | ||
using Content.Shared._White.Plumbing; | ||
using Content.Shared.Wires; | ||
using Robust.Shared.Map.Components; | ||
|
||
namespace Content.Server._White.Plumbing; | ||
|
||
|
||
/// <summary> | ||
/// Literally just CableVisSystem. | ||
/// </summary> | ||
public sealed partial class PlumbingPipeVisSystem : EntitySystem | ||
{ | ||
|
||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
[Dependency] private readonly NodeContainerSystem _node = default!; | ||
|
||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<PlumbingPipeVisComponent, NodeGroupsRebuilt>(UpdateAppearance); | ||
} | ||
|
||
private void UpdateAppearance(EntityUid uid, PlumbingPipeVisComponent cableVis, ref NodeGroupsRebuilt args) | ||
{ | ||
if (!_node.TryGetNode(uid, cableVis.Node, out PipeNode? node)) | ||
return; | ||
|
||
var transform = Transform(uid); | ||
if (!TryComp<MapGridComponent>(transform.GridUid, out var grid)) | ||
return; | ||
|
||
var mask = WireVisDirFlags.None; | ||
var tile = grid.TileIndicesFor(transform.Coordinates); | ||
|
||
foreach (var reachable in node.ReachableNodes) | ||
{ | ||
if (reachable is not PipeNode) | ||
continue; | ||
|
||
var otherTransform = Transform(reachable.Owner); | ||
var otherTile = grid.TileIndicesFor(otherTransform.Coordinates); | ||
var diff = otherTile - tile; | ||
|
||
mask |= diff switch | ||
{ | ||
(0, 1) => WireVisDirFlags.North, | ||
(0, -1) => WireVisDirFlags.South, | ||
(1, 0) => WireVisDirFlags.East, | ||
(-1, 0) => WireVisDirFlags.West, | ||
_ => WireVisDirFlags.None | ||
}; | ||
} | ||
|
||
_appearance.SetData(uid, WireVisVisuals.ConnectedMask, mask); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Content.Server.Chemistry.Containers.EntitySystems; | ||
using Content.Server.NodeContainer; | ||
using Content.Server.NodeContainer.EntitySystems; | ||
using Content.Server.NodeContainer.Nodes; | ||
using Content.Shared._White.Plumbing; | ||
using Content.Shared.Atmos; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Chemistry.Components.SolutionManager; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.Chemistry.Reagent; | ||
using Content.Shared.Containers.ItemSlots; | ||
using Content.Shared.FixedPoint; | ||
using Robust.Shared.Containers; | ||
using Robust.Shared.Timing; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Content.Server._White.Plumbing; | ||
|
||
public sealed partial class PlumbingSystem : EntitySystem | ||
{ | ||
|
||
|
||
//var simpleDemandQuery = EntityQueryEnumerator<PlumbingSimpleDemandComponent>(); | ||
public void InitializeVisualiser() | ||
{ | ||
SubscribeLocalEvent<PlumbingInputOutputVisualiserComponent, NodeRotatedEvent>(OnNodeRotated); | ||
} | ||
|
||
private void OnNodeRotated(EntityUid uid, PlumbingInputOutputVisualiserComponent comp, NodeRotatedEvent args) | ||
{ | ||
if(args.Node is PipeNode pipeNode) | ||
switch (pipeNode.Name) | ||
{ | ||
case "input": | ||
comp.InputDir = pipeNode.CurrentPipeDirection.ToDirection(); | ||
Dirty(uid, comp); | ||
return; | ||
case "output": | ||
comp.InputDir = pipeNode.CurrentPipeDirection.ToDirection(); | ||
Dirty(uid, comp); | ||
return; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Content.Server/_White/Plumbing/PlumbingSystem.Separator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Content.Server.Chemistry.Containers.EntitySystems; | ||
using Content.Server.NodeContainer; | ||
using Content.Shared._White.Plumbing; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Chemistry.Components.SolutionManager; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.Chemistry.Reagent; | ||
using Content.Shared.Containers.ItemSlots; | ||
using Content.Shared.FixedPoint; | ||
using Robust.Shared.Containers; | ||
using Robust.Shared.Timing; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Content.Server._White.Plumbing; | ||
|
||
|
||
// i am about to write ui again. | ||
// I am afraid God can't help me even if he wanted to. | ||
public sealed partial class PlumbingSystem | ||
{ public void InitializeSeparator() | ||
{ | ||
|
||
SubscribeLocalEvent<PlumbingInternalTankComponent, PlumbingGetTank>(OnGetTankInternal); | ||
SubscribeLocalEvent<PlumbingItemSlotTankComponent, PlumbingGetTank>(OnGetTankItemSlot); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.