From 39460d2faae4c02948b2b3f0342bbe495d295544 Mon Sep 17 00:00:00 2001 From: Guess-My-Name <34919974+Guess-My-Name@users.noreply.github.com> Date: Thu, 22 Feb 2024 05:18:11 +0100 Subject: [PATCH] no more oracle spam --- .../Nyanotrasen/Research/Oracle/OracleComponent.cs | 6 ++++++ .../Nyanotrasen/Research/Oracle/OracleSystem.cs | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Content.Server/Nyanotrasen/Research/Oracle/OracleComponent.cs b/Content.Server/Nyanotrasen/Research/Oracle/OracleComponent.cs index 73d1a4ecc60..e238d5c7a18 100644 --- a/Content.Server/Nyanotrasen/Research/Oracle/OracleComponent.cs +++ b/Content.Server/Nyanotrasen/Research/Oracle/OracleComponent.cs @@ -23,6 +23,12 @@ public sealed partial class OracleComponent : Component [DataField("barkTime")] public TimeSpan BarkTime = TimeSpan.FromMinutes(1); + [DataField("rejectAccumulator")] + public float RejectAccumulator; + + [DataField("rejectTime")] + public TimeSpan RejectTime = TimeSpan.FromSeconds(5); + [ViewVariables(VVAccess.ReadWrite)] public EntityPrototype DesiredPrototype = default!; diff --git a/Content.Server/Nyanotrasen/Research/Oracle/OracleSystem.cs b/Content.Server/Nyanotrasen/Research/Oracle/OracleSystem.cs index eccf064e33d..148598fe2c3 100644 --- a/Content.Server/Nyanotrasen/Research/Oracle/OracleSystem.cs +++ b/Content.Server/Nyanotrasen/Research/Oracle/OracleSystem.cs @@ -38,6 +38,7 @@ public override void Update(float frameTime) { oracle.Accumulator += frameTime; oracle.BarkAccumulator += frameTime; + oracle.RejectAccumulator += frameTime; if (oracle.BarkAccumulator >= oracle.BarkTime.TotalSeconds) { oracle.BarkAccumulator = 0; @@ -120,8 +121,12 @@ private void OnInteractUsing(EntityUid uid, OracleComponent component, InteractU if (!validItem) { - if (!HasComp(args.Used)) + if (!HasComp(args.Used) && + component.RejectAccumulator >= component.RejectTime.TotalSeconds) + { + component.RejectAccumulator = 0; _chat.TrySendInGameICMessage(uid, _random.Pick(component.RejectMessages), InGameICChatType.Speak, true); + } return; } @@ -186,6 +191,7 @@ private void NextItem(OracleComponent component) { component.Accumulator = 0; component.BarkAccumulator = 0; + component.RejectAccumulator = 0; var protoString = GetDesiredItem(component); if (_prototypeManager.TryIndex(protoString, out var proto)) component.DesiredPrototype = proto;