From cb4a5df2cb01537ef7cc8b428b7f32f4f1a62d17 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Sun, 22 Dec 2024 20:04:02 +0000 Subject: [PATCH] add tape recorder (#2498) * add tape recorder * add filled tape recorder to trinkets * :trollface: * :trollface: --------- Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../DeltaV/TapeRecorder/TapeRecorderSystem.cs | 24 + .../UI/TapeRecorderBoundUserInterface.cs | 49 ++ .../TapeRecorder/UI/TapeRecorderWindow.xaml | 23 + .../UI/TapeRecorderWindow.xaml.cs | 129 ++++++ .../DeltaV/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 +++ .../DeltaV/TapeRecorder/TapeRecorderUI.cs | 62 +++ .../Items/TapeRecorder/attributions.yml | 14 + .../Audio/DeltaV/Items/TapeRecorder/play.ogg | Bin 0 -> 11670 bytes .../DeltaV/Items/TapeRecorder/rewind.ogg | Bin 0 -> 13159 bytes .../Audio/DeltaV/Items/TapeRecorder/stop.ogg | Bin 0 -> 7395 bytes .../deltav/taperecorder/taperecorder.ftl | 27 ++ .../Catalog/Fills/Lockers/security.yml | 1 + .../DeltaV/Catalog/Fills/Boxes/security.yml | 16 + .../Objects/Devices/tape_recorder.yml | 147 ++++++ .../DeltaV/Entities/Objects/Misc/paper.yml | 6 + .../Loadouts/Miscellaneous/trinkets.yml | 6 + .../Prototypes/DeltaV/Recipes/Lathes/misc.yml | 17 + .../Entities/Structures/Machines/lathe.yml | 2 + .../Prototypes/Loadouts/loadout_groups.yml | 15 +- .../Roles/Jobs/Wildcards/reporter.yml | 8 +- .../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 .../Objects/Storage/boxes.rsi/meta.json | 14 + .../Objects/Storage/boxes.rsi/recorder.png | Bin 0 -> 189 bytes 39 files changed, 1382 insertions(+), 9 deletions(-) create mode 100644 Content.Client/DeltaV/TapeRecorder/TapeRecorderSystem.cs create mode 100644 Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs create mode 100644 Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderWindow.xaml create mode 100644 Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderWindow.xaml.cs create mode 100644 Content.Server/DeltaV/TapeRecorder/TapeRecorderSystem.cs create mode 100644 Content.Shared/DeltaV/TapeRecorder/Components/ActiveTapeRecorderComponent.cs create mode 100644 Content.Shared/DeltaV/TapeRecorder/Components/FitsInTapeRecorderComponent.cs create mode 100644 Content.Shared/DeltaV/TapeRecorder/Components/TapeCasetteComponent.cs create mode 100644 Content.Shared/DeltaV/TapeRecorder/Components/TapeRecorderComponent.cs create mode 100644 Content.Shared/DeltaV/TapeRecorder/Systems/SharedTapeRecorderSystem.cs create mode 100644 Content.Shared/DeltaV/TapeRecorder/TapeCasetteRecordedMessage.cs create mode 100644 Content.Shared/DeltaV/TapeRecorder/TapeRecorderUI.cs create mode 100644 Resources/Audio/DeltaV/Items/TapeRecorder/attributions.yml create mode 100644 Resources/Audio/DeltaV/Items/TapeRecorder/play.ogg create mode 100644 Resources/Audio/DeltaV/Items/TapeRecorder/rewind.ogg create mode 100644 Resources/Audio/DeltaV/Items/TapeRecorder/stop.ogg create mode 100644 Resources/Locale/en-US/deltav/taperecorder/taperecorder.ftl create mode 100644 Resources/Prototypes/DeltaV/Catalog/Fills/Boxes/security.yml create mode 100644 Resources/Prototypes/DeltaV/Entities/Objects/Devices/tape_recorder.yml create mode 100644 Resources/Prototypes/DeltaV/Recipes/Lathes/misc.yml create mode 100644 Resources/Textures/DeltaV/Objects/Devices/cassette_tapes.rsi/meta.json create mode 100644 Resources/Textures/DeltaV/Objects/Devices/cassette_tapes.rsi/tape_greyscale.png create mode 100644 Resources/Textures/DeltaV/Objects/Devices/cassette_tapes.rsi/tape_ribbonoverlay.png create mode 100644 Resources/Textures/DeltaV/Objects/Devices/tape_recorder.rsi/empty.png create mode 100644 Resources/Textures/DeltaV/Objects/Devices/tape_recorder.rsi/idle.png create mode 100644 Resources/Textures/DeltaV/Objects/Devices/tape_recorder.rsi/inhand-left.png create mode 100644 Resources/Textures/DeltaV/Objects/Devices/tape_recorder.rsi/inhand-right.png create mode 100644 Resources/Textures/DeltaV/Objects/Devices/tape_recorder.rsi/meta.json create mode 100644 Resources/Textures/DeltaV/Objects/Devices/tape_recorder.rsi/playing.png create mode 100644 Resources/Textures/DeltaV/Objects/Devices/tape_recorder.rsi/recording.png create mode 100644 Resources/Textures/DeltaV/Objects/Devices/tape_recorder.rsi/rewinding.png create mode 100644 Resources/Textures/DeltaV/Objects/Storage/boxes.rsi/meta.json create mode 100644 Resources/Textures/DeltaV/Objects/Storage/boxes.rsi/recorder.png diff --git a/Content.Client/DeltaV/TapeRecorder/TapeRecorderSystem.cs b/Content.Client/DeltaV/TapeRecorder/TapeRecorderSystem.cs new file mode 100644 index 00000000000..7b8ed6663ca --- /dev/null +++ b/Content.Client/DeltaV/TapeRecorder/TapeRecorderSystem.cs @@ -0,0 +1,24 @@ +using Content.Shared.DeltaV.TapeRecorder.Systems; + +namespace Content.Client.DeltaV.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/DeltaV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs b/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs new file mode 100644 index 00000000000..521fbb96247 --- /dev/null +++ b/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs @@ -0,0 +1,49 @@ +using Content.Shared.DeltaV.TapeRecorder; +using Robust.Client.UserInterface; +using Robust.Shared.Prototypes; +using Robust.Shared.Timing; + +namespace Content.Client.DeltaV.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/DeltaV/TapeRecorder/UI/TapeRecorderWindow.xaml b/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderWindow.xaml new file mode 100644 index 00000000000..c6dc577d264 --- /dev/null +++ b/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderWindow.xaml @@ -0,0 +1,23 @@ + + + + + + + + +