Skip to content

Commit

Permalink
no more oracle spam
Browse files Browse the repository at this point in the history
  • Loading branch information
Guess-My-Name committed Feb 22, 2024
1 parent 4639342 commit 39460d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Content.Server/Nyanotrasen/Research/Oracle/OracleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;

Expand Down
8 changes: 7 additions & 1 deletion Content.Server/Nyanotrasen/Research/Oracle/OracleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -120,8 +121,12 @@ private void OnInteractUsing(EntityUid uid, OracleComponent component, InteractU

if (!validItem)
{
if (!HasComp<RefillableSolutionComponent>(args.Used))
if (!HasComp<RefillableSolutionComponent>(args.Used) &&
component.RejectAccumulator >= component.RejectTime.TotalSeconds)
{
component.RejectAccumulator = 0;
_chat.TrySendInGameICMessage(uid, _random.Pick(component.RejectMessages), InGameICChatType.Speak, true);
}
return;
}

Expand Down Expand Up @@ -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<EntityPrototype>(protoString, out var proto))
component.DesiredPrototype = proto;
Expand Down

0 comments on commit 39460d2

Please sign in to comment.