Skip to content

Commit

Permalink
Mam teraz rozwolnienie
Browse files Browse the repository at this point in the history
  • Loading branch information
RedFoxIV committed Dec 21, 2024
1 parent 6b873bc commit 83367d3
Show file tree
Hide file tree
Showing 15 changed files with 516 additions and 61 deletions.
36 changes: 36 additions & 0 deletions Content.Client/_White/Plumbing/PlumbingPipeVisualiserSystem.cs
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}");
}
}
77 changes: 77 additions & 0 deletions Content.Client/_White/Plumbing/PlumbingSystem.cs
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
}
14 changes: 14 additions & 0 deletions Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ private void OnMoveEvent(EntityUid uid, NodeContainerComponent container, ref Mo
continue;

if (rotatableNode.RotateNode(in ev))
{ // WD EDIT START
RaiseLocalEvent(uid, new NodeRotatedEvent(node));
_nodeGroupSystem.QueueReflood(node);
} // WD EDIT END
}
}

Expand Down Expand Up @@ -223,4 +226,15 @@ private void OnExamine(EntityUid uid, NodeContainerComponent component, Examined
}
}
}
// WD EDIT START
public sealed class NodeRotatedEvent : EntityEventArgs
{
public Node Node;
public NodeRotatedEvent(Node node)
{
Node = node;
}
}
// WD EDIT END
}

1 change: 1 addition & 0 deletions Content.Server/NodeContainer/Nodes/PipeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public partial class PipeNode : Node, IGasMixtureHolder, IRotatableNode

private HashSet<PipeNode>? _alwaysReachable;

public PipeDirection GetOriginalPipeDirection() => _originalPipeDirection; // WD EDIT
public void AddAlwaysReachable(PipeNode pipeNode)
{
if (pipeNode.NodeGroupID != NodeGroupID) return;
Expand Down
59 changes: 59 additions & 0 deletions Content.Server/_White/Plumbing/PlumbingPipeVisSystem.cs
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);
}

}
48 changes: 48 additions & 0 deletions Content.Server/_White/Plumbing/PlumbingSystem.Move.cs
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 Content.Server/_White/Plumbing/PlumbingSystem.Separator.cs
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);
}


}
6 changes: 5 additions & 1 deletion Content.Server/_White/Plumbing/PlumbingSystem.Tank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void InitializeTank()

SubscribeLocalEvent<PlumbingInternalTankComponent, PlumbingGetTank>(OnGetTankInternal);
SubscribeLocalEvent<PlumbingItemSlotTankComponent, PlumbingGetTank>(OnGetTankItemSlot);

SubscribeLocalEvent<PlumbingInfiniteTankComponent, PlumbingGetTank>(OnGetTankInfinite);
//SubscribeLocalEvent<PlumbingSimpleInputComponent, PlumbingRequestOutputEvent>(OnFactoryRequest);
//simpleDemandQuery = GetEntityQuery<PlumbingSimpleDemandComponent>();
}
Expand All @@ -45,4 +45,8 @@ private void OnGetTankItemSlot(EntityUid uid, PlumbingItemSlotTankComponent comp
args.solutionEnt = ent;
}

private void OnGetTankInfinite(EntityUid uid, PlumbingInfiniteTankComponent comp, ref PlumbingGetTank args)
{
args.solution = new Solution(comp.ReagentPrototype, comp.tankSize);
}
}
Loading

0 comments on commit 83367d3

Please sign in to comment.