Atmos pipe rework (#3833)
* Initial * Cleanup a bunch of things * some changes dunno * RequireAnchored * a * stuff * more work * Lots of progress * delete pipe visualizer * a * b * pipenet and pipenode cleanup * Fixes * Adds GasValve * Adds GasMiner * Fix stuff, maybe? * More fixes * Ignored components on the client * Adds thermomachine behavior, change a bunch of stuff * Remove Anchored * some work, but it's shitcode * significantly more ECS * ECS AtmosDevices * Cleanup * fix appearance * when the pipe direction is sus * Gas tanks and canisters * pipe anchoring and stuff * coding is my passion * Unsafe pipes take longer to unanchor * turns out we're no longer using eris canisters * Gas canister inserted tank appearance, improvements * Work on a bunch of appearances * Scrubber appearance * Reorganize AtmosphereSystem.Piping into a bunch of different systems * Appearance for vent/scrubber/pump turns off when leaving atmosphere * ThermoMachine appearance * Cleanup gas tanks * Remove passive gate unused imports * remove old canister UI functionality * PipeNode environment air, make everything use AssumeAir instead of merging manually * a * Reorganize atmos to follow new structure * ????? * Canister UI, restructure client * Restructure shared * Fix build tho * listen, at least the canister UI works entirely... * fix build : ) * Atmos device prototypes have names and descriptions * gas canister ui slider doesn't jitter * trinary prototypes * sprite for miners * ignore components * fix YAML * Fix port system doing useless thing * Fix build * fix thinking moment * fix build again because * canister direction * pipenode is a word * GasTank Air will throw on invalid states * fix build.... * Unhardcode volume pump thresholds * Volume pump and filter take time into account * Rename Join/Leave atmosphere events to AtmosDeviceEnabled/Disabled Event * Gas tank node volume is set by initial mixtuer * I love node container
This commit is contained in:
committed by
GitHub
parent
cfc3f2e7fc
commit
a2b737d945
204
Content.Shared/Atmos/PipeDirection.cs
Normal file
204
Content.Shared/Atmos/PipeDirection.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Atmos
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum PipeVisuals
|
||||
{
|
||||
VisualState
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class PipeVisualState
|
||||
{
|
||||
// TODO ATMOS: Make this not a class and just be the field below...
|
||||
[ViewVariables]
|
||||
public readonly PipeDirection ConnectedDirections;
|
||||
|
||||
public PipeVisualState(PipeDirection connectedDirections)
|
||||
{
|
||||
ConnectedDirections = connectedDirections;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
[Serializable, NetSerializable]
|
||||
public enum PipeDirection
|
||||
{
|
||||
None = 0,
|
||||
|
||||
//Half of a pipe in a direction
|
||||
North = 1 << 0,
|
||||
South = 1 << 1,
|
||||
West = 1 << 2,
|
||||
East = 1 << 3,
|
||||
Port = 1 << 4,
|
||||
Connector = 1 << 5,
|
||||
|
||||
//Straight pipes
|
||||
Longitudinal = North | South,
|
||||
Lateral = West | East,
|
||||
|
||||
//Bends
|
||||
NWBend = North | West,
|
||||
NEBend = North | East,
|
||||
SWBend = South | West,
|
||||
SEBend = South | East,
|
||||
|
||||
//Vertical Bends (Port only)
|
||||
NPBend = North | Port,
|
||||
SPBend = South | Port,
|
||||
WPBend = West | Port,
|
||||
EPBend = East | Port,
|
||||
|
||||
//T-Junctions
|
||||
TNorth = North | Lateral,
|
||||
TSouth = South | Lateral,
|
||||
TWest = West | Longitudinal,
|
||||
TEast = East | Longitudinal,
|
||||
|
||||
//Four way
|
||||
Fourway = North | South | East | West,
|
||||
|
||||
All = -1,
|
||||
}
|
||||
|
||||
public enum PipeShape
|
||||
{
|
||||
Half,
|
||||
Straight,
|
||||
Bend,
|
||||
VerticalBend,
|
||||
TJunction,
|
||||
Fourway
|
||||
}
|
||||
|
||||
public static class PipeShapeHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the direction of a shape when facing 0 degrees (the initial direction of entities).
|
||||
/// </summary>
|
||||
public static PipeDirection ToBaseDirection(this PipeShape shape)
|
||||
{
|
||||
return shape switch
|
||||
{
|
||||
PipeShape.Half => PipeDirection.South,
|
||||
PipeShape.Straight => PipeDirection.Longitudinal,
|
||||
PipeShape.Bend => PipeDirection.SWBend,
|
||||
PipeShape.VerticalBend => PipeDirection.SPBend,
|
||||
PipeShape.TJunction => PipeDirection.TSouth,
|
||||
PipeShape.Fourway => PipeDirection.Fourway,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(shape), $"{shape} does not have an associated {nameof(PipeDirection)}."),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static class PipeDirectionHelpers
|
||||
{
|
||||
public const int PipeDirections = 4;
|
||||
|
||||
/// <summary>
|
||||
/// Includes the Up and Down directions.
|
||||
/// </summary>
|
||||
public const int AllPipeDirections = 6;
|
||||
|
||||
public static bool HasDirection(this PipeDirection pipeDirection, PipeDirection other)
|
||||
{
|
||||
return (pipeDirection & other) == other;
|
||||
}
|
||||
|
||||
public static Angle ToAngle(this PipeDirection pipeDirection)
|
||||
{
|
||||
return pipeDirection.ToDirection().ToAngle();
|
||||
}
|
||||
|
||||
public static PipeDirection ToPipeDirection(this Direction direction)
|
||||
{
|
||||
return direction switch
|
||||
{
|
||||
Direction.North => PipeDirection.North,
|
||||
Direction.South => PipeDirection.South,
|
||||
Direction.East => PipeDirection.East,
|
||||
Direction.West => PipeDirection.West,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(direction)),
|
||||
};
|
||||
}
|
||||
|
||||
public static Direction ToDirection(this PipeDirection pipeDirection)
|
||||
{
|
||||
return pipeDirection switch
|
||||
{
|
||||
PipeDirection.North => Direction.North,
|
||||
PipeDirection.South => Direction.South,
|
||||
PipeDirection.East => Direction.East,
|
||||
PipeDirection.West => Direction.West,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(pipeDirection)),
|
||||
};
|
||||
}
|
||||
|
||||
public static PipeDirection GetOpposite(this PipeDirection pipeDirection)
|
||||
{
|
||||
return pipeDirection switch
|
||||
{
|
||||
PipeDirection.North => PipeDirection.South,
|
||||
PipeDirection.South => PipeDirection.North,
|
||||
PipeDirection.East => PipeDirection.West,
|
||||
PipeDirection.West => PipeDirection.East,
|
||||
PipeDirection.Port => PipeDirection.Connector,
|
||||
PipeDirection.Connector => PipeDirection.Port,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(pipeDirection)),
|
||||
};
|
||||
}
|
||||
|
||||
public static PipeShape PipeDirectionToPipeShape(this PipeDirection pipeDirection)
|
||||
{
|
||||
return pipeDirection switch
|
||||
{
|
||||
PipeDirection.North => PipeShape.Half,
|
||||
PipeDirection.South => PipeShape.Half,
|
||||
PipeDirection.East => PipeShape.Half,
|
||||
PipeDirection.West => PipeShape.Half,
|
||||
|
||||
PipeDirection.Lateral => PipeShape.Straight,
|
||||
PipeDirection.Longitudinal => PipeShape.Straight,
|
||||
|
||||
PipeDirection.NEBend => PipeShape.Bend,
|
||||
PipeDirection.NWBend => PipeShape.Bend,
|
||||
PipeDirection.SEBend => PipeShape.Bend,
|
||||
PipeDirection.SWBend => PipeShape.Bend,
|
||||
|
||||
PipeDirection.NPBend => PipeShape.VerticalBend,
|
||||
PipeDirection.SPBend => PipeShape.VerticalBend,
|
||||
PipeDirection.WPBend => PipeShape.VerticalBend,
|
||||
PipeDirection.EPBend => PipeShape.VerticalBend,
|
||||
|
||||
PipeDirection.TNorth => PipeShape.TJunction,
|
||||
PipeDirection.TSouth => PipeShape.TJunction,
|
||||
PipeDirection.TEast => PipeShape.TJunction,
|
||||
PipeDirection.TWest => PipeShape.TJunction,
|
||||
|
||||
PipeDirection.Fourway => PipeShape.Fourway,
|
||||
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(pipeDirection)),
|
||||
};
|
||||
}
|
||||
|
||||
public static PipeDirection RotatePipeDirection(this PipeDirection pipeDirection, double diff)
|
||||
{
|
||||
var newPipeDir = PipeDirection.None;
|
||||
for (var i = 0; i < PipeDirections; i++)
|
||||
{
|
||||
var currentPipeDirection = (PipeDirection) (1 << i);
|
||||
if (!pipeDirection.HasFlag(currentPipeDirection)) continue;
|
||||
var angle = currentPipeDirection.ToAngle();
|
||||
angle += diff;
|
||||
newPipeDir |= angle.GetCardinalDir().ToPipeDirection();
|
||||
}
|
||||
return newPipeDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user