From 96db8e64f957d386e3963babb042e57e55fa20eb Mon Sep 17 00:00:00 2001 From: Epic Toast <44736041+EpicToastTM@users.noreply.github.com> Date: Thu, 9 Jan 2025 21:50:27 -0800 Subject: [PATCH] Port tape recorders from Delta-V --- .../_DV/TapeRecorder/TapeRecorderSystem.cs | 24 + .../UI/TapeRecorderBoundUserInterface.cs | 49 ++ .../TapeRecorder/UI/TapeRecorderWindow.xaml | 23 + .../UI/TapeRecorderWindow.xaml.cs | 129 ++++++ .../_DV/TapeRecorder/TapeRecorderSystem.cs | 132 ++++++ .../Components/ActiveTapeRecorderComponent.cs | 9 + .../Components/FitsInTapeRecorderComponent.cs | 9 + .../Components/TapeCasetteComponent.cs | 53 +++ .../Components/TapeRecorderComponent.cs | 83 ++++ .../Systems/SharedTapeRecorderSystem.cs | 419 ++++++++++++++++++ .../TapeCasetteRecordedMessage.cs | 51 +++ .../_DV/TapeRecorder/TapeRecorderUI.cs | 62 +++ .../_DV/Items/TapeRecorder/attributions.yml | 14 + .../Audio/_DV/Items/TapeRecorder/play.ogg | Bin 0 -> 11670 bytes .../Audio/_DV/Items/TapeRecorder/rewind.ogg | Bin 0 -> 13159 bytes .../Audio/_DV/Items/TapeRecorder/stop.ogg | Bin 0 -> 7395 bytes .../en-US/_DV/taperecorder/taperecorder.ftl | 27 ++ .../Catalog/Fills/Lockers/security.yml | 1 + .../Entities/Structures/Machines/lathe.yml | 3 + .../Roles/Jobs/Civilian/librarian.yml | 3 + .../Roles/Jobs/Wildcards/reporter.yml | 9 +- .../_DV/Catalog/Fills/Boxes/security.yml | 16 + .../Objects/Devices/tape_recorder.yml | 147 ++++++ .../_DV/Entities/Objects/Misc/paper.yml | 5 + .../Prototypes/_DV/Recipes/Lathes/misc.yml | 17 + .../Entities/Structures/Machines/lathe.yml | 2 + .../Devices/cassette_tapes.rsi/meta.json | 17 + .../cassette_tapes.rsi/tape_greyscale.png | Bin 0 -> 423 bytes .../cassette_tapes.rsi/tape_ribbonoverlay.png | Bin 0 -> 449 bytes .../Devices/tape_recorder.rsi/empty.png | Bin 0 -> 581 bytes .../Devices/tape_recorder.rsi/idle.png | Bin 0 -> 597 bytes .../Devices/tape_recorder.rsi/inhand-left.png | Bin 0 -> 491 bytes .../tape_recorder.rsi/inhand-right.png | Bin 0 -> 487 bytes .../Devices/tape_recorder.rsi/meta.json | 58 +++ .../Devices/tape_recorder.rsi/playing.png | Bin 0 -> 955 bytes .../Devices/tape_recorder.rsi/recording.png | Bin 0 -> 934 bytes .../Devices/tape_recorder.rsi/rewinding.png | Bin 0 -> 887 bytes .../_DV/Objects/Storage/boxes.rsi/meta.json | 14 + .../Objects/Storage/boxes.rsi/recorder.png | Bin 0 -> 189 bytes 39 files changed, 1373 insertions(+), 3 deletions(-) create mode 100644 Content.Client/_DV/TapeRecorder/TapeRecorderSystem.cs create mode 100644 Content.Client/_DV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs create mode 100644 Content.Client/_DV/TapeRecorder/UI/TapeRecorderWindow.xaml create mode 100644 Content.Client/_DV/TapeRecorder/UI/TapeRecorderWindow.xaml.cs create mode 100644 Content.Server/_DV/TapeRecorder/TapeRecorderSystem.cs create mode 100644 Content.Shared/_DV/TapeRecorder/Components/ActiveTapeRecorderComponent.cs create mode 100644 Content.Shared/_DV/TapeRecorder/Components/FitsInTapeRecorderComponent.cs create mode 100644 Content.Shared/_DV/TapeRecorder/Components/TapeCasetteComponent.cs create mode 100644 Content.Shared/_DV/TapeRecorder/Components/TapeRecorderComponent.cs create mode 100644 Content.Shared/_DV/TapeRecorder/Systems/SharedTapeRecorderSystem.cs create mode 100644 Content.Shared/_DV/TapeRecorder/TapeCasetteRecordedMessage.cs create mode 100644 Content.Shared/_DV/TapeRecorder/TapeRecorderUI.cs create mode 100644 Resources/Audio/_DV/Items/TapeRecorder/attributions.yml create mode 100644 Resources/Audio/_DV/Items/TapeRecorder/play.ogg create mode 100644 Resources/Audio/_DV/Items/TapeRecorder/rewind.ogg create mode 100644 Resources/Audio/_DV/Items/TapeRecorder/stop.ogg create mode 100644 Resources/Locale/en-US/_DV/taperecorder/taperecorder.ftl create mode 100644 Resources/Prototypes/_DV/Catalog/Fills/Boxes/security.yml create mode 100644 Resources/Prototypes/_DV/Entities/Objects/Devices/tape_recorder.yml create mode 100644 Resources/Prototypes/_DV/Entities/Objects/Misc/paper.yml create mode 100644 Resources/Prototypes/_DV/Recipes/Lathes/misc.yml create mode 100644 Resources/Textures/_DV/Objects/Devices/cassette_tapes.rsi/meta.json create mode 100644 Resources/Textures/_DV/Objects/Devices/cassette_tapes.rsi/tape_greyscale.png create mode 100644 Resources/Textures/_DV/Objects/Devices/cassette_tapes.rsi/tape_ribbonoverlay.png create mode 100644 Resources/Textures/_DV/Objects/Devices/tape_recorder.rsi/empty.png create mode 100644 Resources/Textures/_DV/Objects/Devices/tape_recorder.rsi/idle.png create mode 100644 Resources/Textures/_DV/Objects/Devices/tape_recorder.rsi/inhand-left.png create mode 100644 Resources/Textures/_DV/Objects/Devices/tape_recorder.rsi/inhand-right.png create mode 100644 Resources/Textures/_DV/Objects/Devices/tape_recorder.rsi/meta.json create mode 100644 Resources/Textures/_DV/Objects/Devices/tape_recorder.rsi/playing.png create mode 100644 Resources/Textures/_DV/Objects/Devices/tape_recorder.rsi/recording.png create mode 100644 Resources/Textures/_DV/Objects/Devices/tape_recorder.rsi/rewinding.png create mode 100644 Resources/Textures/_DV/Objects/Storage/boxes.rsi/meta.json create mode 100644 Resources/Textures/_DV/Objects/Storage/boxes.rsi/recorder.png diff --git a/Content.Client/_DV/TapeRecorder/TapeRecorderSystem.cs b/Content.Client/_DV/TapeRecorder/TapeRecorderSystem.cs new file mode 100644 index 000000000000..470aad9408d4 --- /dev/null +++ b/Content.Client/_DV/TapeRecorder/TapeRecorderSystem.cs @@ -0,0 +1,24 @@ +using Content.Shared._DV.TapeRecorder.Systems; + +namespace Content.Client._DV.TapeRecorder; + +/// +/// Required for client side prediction stuff +/// +public sealed class TapeRecorderSystem : SharedTapeRecorderSystem +{ + private TimeSpan _lastTickTime = TimeSpan.Zero; + + public override void Update(float frameTime) + { + if (!Timing.IsFirstTimePredicted) + return; + + //We need to know the exact time period that has passed since the last update to ensure the tape position is sync'd with the server + //Since the client can skip frames when lagging, we cannot use frameTime + var realTime = (float) (Timing.CurTime - _lastTickTime).TotalSeconds; + _lastTickTime = Timing.CurTime; + + base.Update(realTime); + } +} diff --git a/Content.Client/_DV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs b/Content.Client/_DV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs new file mode 100644 index 000000000000..21ce6156441c --- /dev/null +++ b/Content.Client/_DV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs @@ -0,0 +1,49 @@ +using Content.Shared._DV.TapeRecorder; +using Robust.Client.UserInterface; +using Robust.Shared.Prototypes; +using Robust.Shared.Timing; + +namespace Content.Client._DV.TapeRecorder.UI; + +public sealed class TapeRecorderBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) +{ + [ViewVariables] + private TapeRecorderWindow? _window; + + [ViewVariables] + private TimeSpan _printCooldown; + + protected override void Open() + { + base.Open(); + + _window = this.CreateWindow(); + _window.Owner = Owner; + _window.OnModeChanged += mode => SendMessage(new ChangeModeTapeRecorderMessage(mode)); + _window.OnPrintTranscript += PrintTranscript; + } + + private void PrintTranscript() + { + SendMessage(new PrintTapeRecorderMessage()); + + _window?.UpdatePrint(true); + + Timer.Spawn(_printCooldown, () => + { + _window?.UpdatePrint(false); + }); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (state is not TapeRecorderState cast) + return; + + _printCooldown = cast.PrintCooldown; + + _window?.UpdateState(cast); + } +} diff --git a/Content.Client/_DV/TapeRecorder/UI/TapeRecorderWindow.xaml b/Content.Client/_DV/TapeRecorder/UI/TapeRecorderWindow.xaml new file mode 100644 index 000000000000..c6dc577d264b --- /dev/null +++ b/Content.Client/_DV/TapeRecorder/UI/TapeRecorderWindow.xaml @@ -0,0 +1,23 @@ + + + + + + + + +