forked from space-syndicate/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 59
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
6 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
Content.Server/_CorvaxNext/Light/ToggleableOccluderComponent.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,29 @@ | ||
using Content.Shared.DeviceLinking; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Light.Components; | ||
|
||
/// <summary> | ||
/// Allows entities with OccluderComponent to toggle that component on and off. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class ToggleableOccluderComponent : Component | ||
{ | ||
/// <summary> | ||
/// Port for toggling occluding on. | ||
/// </summary> | ||
[DataField] | ||
public ProtoId<SinkPortPrototype> OnPort = "On"; | ||
|
||
/// <summary> | ||
/// Port for toggling occluding off. | ||
/// </summary> | ||
[DataField] | ||
public ProtoId<SinkPortPrototype> OffPort = "Off"; | ||
|
||
/// <summary> | ||
/// Port for toggling occluding. | ||
/// </summary> | ||
[DataField] | ||
public ProtoId<SinkPortPrototype> TogglePort = "Toggle"; | ||
} |
56 changes: 56 additions & 0 deletions
56
Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.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,56 @@ | ||
using Content.Server.DeviceLinking.Events; | ||
using Content.Server.DeviceLinking.Systems; | ||
using Content.Server.Light.Components; | ||
|
||
namespace Content.Server.Light.EntitySystems; | ||
|
||
/// <summary> | ||
/// Handles the logic between signals and toggling OccluderComponent | ||
/// </summary> | ||
public sealed class ToggleableOccluderSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!; | ||
[Dependency] private readonly OccluderSystem _occluder = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<ToggleableOccluderComponent, SignalReceivedEvent>(OnSignalReceived); | ||
SubscribeLocalEvent<ToggleableOccluderComponent, ComponentInit>(OnInit); | ||
} | ||
|
||
private void OnInit(EntityUid uid, ToggleableOccluderComponent comp, ComponentInit args) | ||
{ | ||
_signalSystem.EnsureSinkPorts(uid, comp.OnPort, comp.OffPort, comp.TogglePort); | ||
} | ||
|
||
private void OnSignalReceived(EntityUid uid, ToggleableOccluderComponent comp, ref SignalReceivedEvent args) | ||
{ | ||
if (!TryComp<OccluderComponent>(uid, out var occluder)) | ||
return; | ||
|
||
if (args.Port == comp.OffPort) | ||
SetState(uid, false, occluder); | ||
else if (args.Port == comp.OnPort) | ||
SetState(uid, true, occluder); | ||
else if (args.Port == comp.TogglePort) | ||
ToggleState(uid, occluder); | ||
} | ||
|
||
public void ToggleState(EntityUid uid, OccluderComponent? occluder = null) | ||
{ | ||
if (!Resolve(uid, ref occluder)) | ||
return; | ||
|
||
_occluder.SetEnabled(uid, !occluder.Enabled); | ||
} | ||
|
||
public void SetState(EntityUid uid, bool state, OccluderComponent? occluder = null) | ||
{ | ||
if (!Resolve(uid, ref occluder)) | ||
return; | ||
|
||
_occluder.SetEnabled(uid, state); | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/structures/windows/window.ftl
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,3 @@ | ||
ent-TintedWindowTransparent = { ent-TintedWindow } | ||
.desc = { ent-TintedWindow.desc } | ||
.suffix = Прозрачный |
3 changes: 2 additions & 1 deletion
3
Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
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
7 changes: 7 additions & 0 deletions
7
Resources/Prototypes/_CorvaxNext/Entities/Structures/Windows/window.yml
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,7 @@ | ||
- type: entity | ||
parent: TintedWindow | ||
id: TintedWindowTransparent | ||
suffix: Transparent | ||
components: | ||
- type: Occluder | ||
enabled: false |