-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
308 changed files
with
18,044 additions
and
10,141 deletions.
There are no files selected for viewing
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,27 @@ | ||
using Content.Shared.Conveyor; | ||
using Content.Shared.Materials; | ||
using Robust.Client.GameObjects; | ||
|
||
namespace Content.Client.Materials; | ||
|
||
public sealed class RecyclerVisualizerSystem : VisualizerSystem<RecyclerVisualsComponent> | ||
{ | ||
protected override void OnAppearanceChange(EntityUid uid, RecyclerVisualsComponent component, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite == null || !args.Sprite.LayerMapTryGet(RecyclerVisualLayers.Main, out var layer)) | ||
return; | ||
|
||
AppearanceSystem.TryGetData<ConveyorState>(uid, ConveyorVisuals.State, out var running); | ||
AppearanceSystem.TryGetData<bool>(uid, RecyclerVisuals.Bloody, out var bloody); | ||
AppearanceSystem.TryGetData<bool>(uid, RecyclerVisuals.Broken, out var broken); | ||
|
||
var activityState = running == ConveyorState.Off ? 0 : 1; | ||
if (broken) //breakage overrides activity | ||
activityState = 2; | ||
|
||
var bloodyKey = bloody ? component.BloodyKey : string.Empty; | ||
|
||
var state = $"{component.BaseKey}{activityState}{bloodyKey}"; | ||
args.Sprite.LayerSetState(layer, state); | ||
} | ||
} |
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,17 @@ | ||
namespace Content.Client.Materials; | ||
|
||
[RegisterComponent] | ||
public sealed partial class RecyclerVisualsComponent : Component | ||
{ | ||
/// <summary> | ||
/// Key appended to state string if bloody. | ||
/// </summary> | ||
[DataField] | ||
public string BloodyKey = "bld"; | ||
|
||
/// <summary> | ||
/// Base key for the visual state. | ||
/// </summary> | ||
[DataField] | ||
public string BaseKey = "grinder-o"; | ||
} |
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
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
40 changes: 40 additions & 0 deletions
40
Content.Server/DeviceLinking/Components/MemoryCellComponent.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,40 @@ | ||
using Content.Server.DeviceLinking.Systems; | ||
using Content.Shared.DeviceLinking; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.DeviceLinking.Components; | ||
|
||
/// <summary> | ||
/// Memory cell that sets the output to the input when enabled. | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(MemoryCellSystem))] | ||
public sealed partial class MemoryCellComponent : Component | ||
{ | ||
/// <summary> | ||
/// Name of the input port. | ||
/// </summary> | ||
[DataField] | ||
public ProtoId<SinkPortPrototype> InputPort = "MemoryInput"; | ||
|
||
/// <summary> | ||
/// Name of the enable port. | ||
/// </summary> | ||
[DataField] | ||
public ProtoId<SinkPortPrototype> EnablePort = "MemoryEnable"; | ||
|
||
/// <summary> | ||
/// Name of the output port. | ||
/// </summary> | ||
[DataField] | ||
public ProtoId<SourcePortPrototype> OutputPort = "Output"; | ||
|
||
// State | ||
[DataField] | ||
public SignalState InputState = SignalState.Low; | ||
|
||
[DataField] | ||
public SignalState EnableState = SignalState.Low; | ||
|
||
[DataField] | ||
public bool LastOutput; | ||
} |
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,74 @@ | ||
using Content.Server.DeviceLinking.Components; | ||
using Content.Server.DeviceLinking.Events; | ||
using Content.Server.DeviceNetwork; | ||
using Content.Shared.DeviceLinking; | ||
|
||
namespace Content.Server.DeviceLinking.Systems; | ||
|
||
/// <summary> | ||
/// Handles the control of output based on the input and enable ports. | ||
/// </summary> | ||
public sealed class MemoryCellSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly DeviceLinkSystem _deviceLink = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<MemoryCellComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<MemoryCellComponent, SignalReceivedEvent>(OnSignalReceived); | ||
} | ||
|
||
public override void Update(float deltaTime) | ||
{ | ||
base.Update(deltaTime); | ||
|
||
var query = EntityQueryEnumerator<MemoryCellComponent, DeviceLinkSourceComponent>(); | ||
while (query.MoveNext(out var uid, out var comp, out var source)) | ||
{ | ||
if (comp.InputState == SignalState.Momentary) | ||
comp.InputState = SignalState.Low; | ||
if (comp.EnableState == SignalState.Momentary) | ||
comp.EnableState = SignalState.Low; | ||
|
||
UpdateOutput((uid, comp, source)); | ||
} | ||
} | ||
|
||
private void OnInit(Entity<MemoryCellComponent> ent, ref ComponentInit args) | ||
{ | ||
var (uid, comp) = ent; | ||
_deviceLink.EnsureSinkPorts(uid, comp.InputPort, comp.EnablePort); | ||
_deviceLink.EnsureSourcePorts(uid, comp.OutputPort); | ||
} | ||
|
||
private void OnSignalReceived(Entity<MemoryCellComponent> ent, ref SignalReceivedEvent args) | ||
{ | ||
var state = SignalState.Momentary; | ||
args.Data?.TryGetValue(DeviceNetworkConstants.LogicState, out state); | ||
|
||
if (args.Port == ent.Comp.InputPort) | ||
ent.Comp.InputState = state; | ||
else if (args.Port == ent.Comp.EnablePort) | ||
ent.Comp.EnableState = state; | ||
|
||
UpdateOutput(ent); | ||
} | ||
|
||
private void UpdateOutput(Entity<MemoryCellComponent, DeviceLinkSourceComponent?> ent) | ||
{ | ||
if (!Resolve(ent, ref ent.Comp2)) | ||
return; | ||
|
||
if (ent.Comp1.EnableState == SignalState.Low) | ||
return; | ||
|
||
var value = ent.Comp1.InputState != SignalState.Low; | ||
if (value == ent.Comp1.LastOutput) | ||
return; | ||
|
||
ent.Comp1.LastOutput = value; | ||
_deviceLink.SendSignal(ent, ent.Comp1.OutputPort, value, ent.Comp2); | ||
} | ||
} |
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
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
Oops, something went wrong.