From de25fd690a25c801965bbace3b7f79b35c21a31f Mon Sep 17 00:00:00 2001
From: lzk <124214523+lzk228@users.noreply.github.com>
Date: Mon, 18 Nov 2024 20:38:40 +0100
Subject: [PATCH 1/6] Togglable tinted windows
---
.../Light/ToggleableOccluderComponent.cs | 29 ++++++++++
.../Light/ToggleableOccluderSystem.cs | 56 +++++++++++++++++++
.../entities/structures/windows/window.ftl | 3 +
.../entities/structures/windows/window.ftl | 3 +-
.../Entities/Structures/Windows/window.yml | 8 +++
.../Entities/Structures/Windows/window.yml | 7 +++
6 files changed, 105 insertions(+), 1 deletion(-)
create mode 100644 Content.Server/_CorvaxNext/Light/ToggleableOccluderComponent.cs
create mode 100644 Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
create mode 100644 Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/structures/windows/window.ftl
create mode 100644 Resources/Prototypes/_CorvaxNext/Entities/Structures/Windows/window.yml
diff --git a/Content.Server/_CorvaxNext/Light/ToggleableOccluderComponent.cs b/Content.Server/_CorvaxNext/Light/ToggleableOccluderComponent.cs
new file mode 100644
index 00000000000..bf378f0408e
--- /dev/null
+++ b/Content.Server/_CorvaxNext/Light/ToggleableOccluderComponent.cs
@@ -0,0 +1,29 @@
+using Content.Shared.DeviceLinking;
+using Robust.Shared.Prototypes;
+
+namespace Content.Server.Light.Components;
+
+///
+/// Allows entities with OccluderComponent to toggle that component on and off.
+///
+[RegisterComponent]
+public sealed partial class ToggleableOccluderComponent : Component
+{
+ ///
+ /// Port for toggling occluding on.
+ ///
+ [DataField]
+ public ProtoId OnPort = "On";
+
+ ///
+ /// Port for toggling occluding off.
+ ///
+ [DataField]
+ public ProtoId OffPort = "Off";
+
+ ///
+ /// Port for toggling occluding.
+ ///
+ [DataField]
+ public ProtoId TogglePort = "Toggle";
+}
diff --git a/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
new file mode 100644
index 00000000000..2bd3e0fd332
--- /dev/null
+++ b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
@@ -0,0 +1,56 @@
+using Content.Server.DeviceLinking.Events;
+using Content.Server.DeviceLinking.Systems;
+using Content.Server.Light.Components;
+
+namespace Content.Server.Light.EntitySystems;
+
+///
+/// Handles the logic between signals and toggling OccluderComponent
+///
+public sealed class ToggleableOccluderSystem : EntitySystem
+{
+ [Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
+ [Dependency] private readonly OccluderSystem _occluder = default!;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+ SubscribeLocalEvent(OnSignalReceived);
+ SubscribeLocalEvent(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(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);
+ }
+
+}
diff --git a/Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/structures/windows/window.ftl b/Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/structures/windows/window.ftl
new file mode 100644
index 00000000000..4e1e1954485
--- /dev/null
+++ b/Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/structures/windows/window.ftl
@@ -0,0 +1,3 @@
+ent-TintedWindowTransparent = { ent-TintedWindow }
+ .desc = { ent-TintedWindow.desc }
+ .suffix = Прозрачный
diff --git a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
index f581123a6da..20060449021 100644
--- a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
+++ b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
@@ -1,7 +1,8 @@
ent-Window = окно
.desc = Смотри не заляпай.
ent-TintedWindow = матовое окно
- .desc = { ent-Window.desc }
+# Corvax-Next-Togglable-Tinted-Window Changed desc
+ .desc = Умное тонированое окно с функцией переключения состояния.
ent-WindowRCDResistant = { ent-Window }
.desc = { ent-Window.desc }
ent-WindowDirectional = направленное окно
diff --git a/Resources/Prototypes/Entities/Structures/Windows/window.yml b/Resources/Prototypes/Entities/Structures/Windows/window.yml
index ce7fc5ea3cd..331810e37a9 100644
--- a/Resources/Prototypes/Entities/Structures/Windows/window.yml
+++ b/Resources/Prototypes/Entities/Structures/Windows/window.yml
@@ -111,6 +111,14 @@
- type: Occluder
- type: StaticPrice
price: 70
+# Corvax-Next-Togglable-Tinted-Window-Start
+ - type: ToggleableOccluder
+ - type: DeviceLinkSink
+ ports:
+ - On
+ - Off
+ - Toggle
+# Corvax-Next-Togglable-Tinted-Window-End
- type: entity
id: WindowRCDResistant
diff --git a/Resources/Prototypes/_CorvaxNext/Entities/Structures/Windows/window.yml b/Resources/Prototypes/_CorvaxNext/Entities/Structures/Windows/window.yml
new file mode 100644
index 00000000000..1f38a259cd9
--- /dev/null
+++ b/Resources/Prototypes/_CorvaxNext/Entities/Structures/Windows/window.yml
@@ -0,0 +1,7 @@
+- type: entity
+ parent: TintedWindow
+ id: TintedWindowTransparent
+ suffix: Transparent
+ components:
+ - type: Occluder
+ enabled: false
From 21a9629e10686cbeec2f3446e233069cbeecd5d1 Mon Sep 17 00:00:00 2001
From: lzk <124214523+lzk228@users.noreply.github.com>
Date: Mon, 18 Nov 2024 20:59:17 +0100
Subject: [PATCH 2/6] fix tests
---
.../ss14-ru/prototypes/entities/structures/windows/window.ftl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
index 20060449021..6d988870fbd 100644
--- a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
+++ b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
@@ -1,7 +1,7 @@
ent-Window = окно
.desc = Смотри не заляпай.
+# Corvax-Next-Togglable-Tinted-Window changed desc below
ent-TintedWindow = матовое окно
-# Corvax-Next-Togglable-Tinted-Window Changed desc
.desc = Умное тонированое окно с функцией переключения состояния.
ent-WindowRCDResistant = { ent-Window }
.desc = { ent-Window.desc }
From 40a7fe4214f7624f622457260a854bde36d757df Mon Sep 17 00:00:00 2001
From: lzk <124214523+lzk228@users.noreply.github.com>
Date: Mon, 18 Nov 2024 20:59:40 +0100
Subject: [PATCH 3/6] Update
Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
Co-authored-by: AwareFoxy <135021509+AwareFoxy@users.noreply.github.com>
---
.../ss14-ru/prototypes/entities/structures/windows/window.ftl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
index 6d988870fbd..b1a50f16429 100644
--- a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
+++ b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/structures/windows/window.ftl
@@ -2,7 +2,7 @@ ent-Window = окно
.desc = Смотри не заляпай.
# Corvax-Next-Togglable-Tinted-Window changed desc below
ent-TintedWindow = матовое окно
- .desc = Умное тонированое окно с функцией переключения состояния.
+ .desc = Умное тонированное окно с функцией переключения состояния.
ent-WindowRCDResistant = { ent-Window }
.desc = { ent-Window.desc }
ent-WindowDirectional = направленное окно
From 85bc892d5536c843ccf0a7d1f2530522a2a749dc Mon Sep 17 00:00:00 2001
From: lzk <124214523+lzk228@users.noreply.github.com>
Date: Sat, 23 Nov 2024 18:27:15 +0100
Subject: [PATCH 4/6] changess
---
.../Light/ToggleableOccluderSystem.cs | 25 +++++++++++++------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
index 2bd3e0fd332..2a3c560da52 100644
--- a/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
+++ b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
@@ -19,7 +19,8 @@ public override void Initialize()
SubscribeLocalEvent(OnInit);
}
- private void OnInit(EntityUid uid, ToggleableOccluderComponent comp, ComponentInit args)
+ private void OnInit(Entity uid, ref ComponentInit args)
+
{
_signalSystem.EnsureSinkPorts(uid, comp.OnPort, comp.OffPort, comp.TogglePort);
}
@@ -29,12 +30,20 @@ private void OnSignalReceived(EntityUid uid, ToggleableOccluderComponent comp, r
if (!TryComp(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);
+ switch (args.Port)
+ {
+ case comp.OffPort:
+ SetState(uid, false, occluder);
+ break;
+
+ case comp.OnPort:
+ SetState(uid, true, occluder);
+ break;
+
+ case comp.TogglePort:
+ ToggleState(uid, occluder);
+ break;
+ }
}
public void ToggleState(EntityUid uid, OccluderComponent? occluder = null)
@@ -42,7 +51,7 @@ public void ToggleState(EntityUid uid, OccluderComponent? occluder = null)
if (!Resolve(uid, ref occluder))
return;
- _occluder.SetEnabled(uid, !occluder.Enabled);
+ SetState(uid, !occluder.Enabled, occluder);
}
public void SetState(EntityUid uid, bool state, OccluderComponent? occluder = null)
From f21ece66364be410c6a3c1e577c377028c19c887 Mon Sep 17 00:00:00 2001
From: lzk <124214523+lzk228@users.noreply.github.com>
Date: Sat, 23 Nov 2024 18:41:49 +0100
Subject: [PATCH 5/6] net
---
Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
index 2a3c560da52..d7be5cfff0f 100644
--- a/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
+++ b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
@@ -19,8 +19,7 @@ public override void Initialize()
SubscribeLocalEvent(OnInit);
}
- private void OnInit(Entity uid, ref ComponentInit args)
-
+ private void OnInit(EntityUid uid, ToggleableOccluderComponent comp, ComponentInit args)
{
_signalSystem.EnsureSinkPorts(uid, comp.OnPort, comp.OffPort, comp.TogglePort);
}
From 8aa57e8fd5f2d0f7fa70e13446e3c02b25fc4150 Mon Sep 17 00:00:00 2001
From: lzk <124214523+lzk228@users.noreply.github.com>
Date: Sun, 24 Nov 2024 22:06:23 +0100
Subject: [PATCH 6/6] =?UTF-8?q?=D0=B1=D0=BB=D1=8F=D1=82=D1=8C=20=D0=BD?=
=?UTF-8?q?=D1=83=20=D1=8D=D1=82=D0=BE=20=D1=85=D1=83=D0=B9=D0=BD=D1=8F,?=
=?UTF-8?q?=20=D0=BF=D1=83=D1=81=D1=82=D1=8C=20=D0=B8=D1=84=D0=B5=D0=BB?=
=?UTF-8?q?=D1=81=20=D0=B1=D1=83=D0=B4=D0=B5=D1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Light/ToggleableOccluderSystem.cs | 22 ++++++-------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
index d7be5cfff0f..90f911aa26d 100644
--- a/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
+++ b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs
@@ -28,21 +28,13 @@ private void OnSignalReceived(EntityUid uid, ToggleableOccluderComponent comp, r
{
if (!TryComp(uid, out var occluder))
return;
-
- switch (args.Port)
- {
- case comp.OffPort:
- SetState(uid, false, occluder);
- break;
-
- case comp.OnPort:
- SetState(uid, true, occluder);
- break;
-
- case comp.TogglePort:
- ToggleState(uid, occluder);
- break;
- }
+
+ 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)