Skip to content

Commit

Permalink
uh
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Oct 29, 2023
1 parent af9e08f commit fbdbc23
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
using Robust.Shared.Random;
namespace Content.Server.SimpleStation14.Speech.Components;

namespace Content.Server.SimpleStation14.Speech.RandomBark
/// <summary>
/// Sends a random message from a list with a provided min/max time.
/// </summary>
[RegisterComponent]
public sealed partial class RandomBarkComponent : Component
{
[RegisterComponent]
public sealed class RandomBarkComponent : Component
{
[Dependency] private readonly IRobustRandom _random = default!;
// Should the message be sent to the chat log?
[DataField("chatlog")]
public bool Chatlog = false;

// Minimum time an animal will go without speaking
[DataField("minTime")]
public int MinTime = 45;
// Minimum time an animal will go without speaking
[DataField("minTime")]
public int MinTime = 45;

// Maximum time an animal will go without speaking
[DataField("maxTime")]
public int MaxTime = 350;
// Maximum time an animal will go without speaking
[DataField("maxTime")]
public int MaxTime = 350;

// Counter
[DataField("barkAccumulator")]
public float BarkAccumulator = 8f;
// Counter
[DataField("barkAccumulator")]
public float BarkAccumulator = 8f;

// Multiplier applied to the random time. Good for changing the frequency without having to specify exact values
[DataField("barkMultiplier")]
public float BarkMultiplier = 1f;
// Multiplier applied to the random time. Good for changing the frequency without having to specify exact values
[DataField("barkMultiplier")]
public float BarkMultiplier = 1f;

// List of things to be said. Filled with garbage to be modified by an accent, but can be specified in the .yml
[DataField("barks"), ViewVariables(VVAccess.ReadWrite)]
public IReadOnlyList<string> Barks = new[] {
"Bark",
"Boof",
"Woofums",
"Howling",
"Screeeeeeeeeeee",
"Barkums",
"OH MY GOD THE FIRE IT BURNS IT BURNS SO BAD!!",
"Death was here ;)",
"Ha ha not really lol",
"Goddamn I love gold fish crackers",
"This is going to be the really long default text, so I'm just going to keep typing and rambling on. You ever tried a churro? They're actually really good. I wasn't expecting much from them, thought they'd be like, dry and crunchy, but no, they're like a cakey thing. Yeah, right, you'd expect something drier, but no, it's actually soft and tasty, sugary, they're really nice."
};
}
// List of things to be said. Filled with garbage to be modified by an accent, but can be specified in the .yml
[DataField("barks"), ViewVariables(VVAccess.ReadWrite)]
public IReadOnlyList<string> Barks = new[]
{
"Bark",
"Boof",
"Woofums",
"Rawrl",
"Eeeeeee",
"Barkums",
"Awooooooooooooooooooo awoo awoooo",
"Grrrrrrrrrrrrrrrrrr",
"Rarrwrarrwr",
"Goddamn I love gold fish crackers",
"Bork bork boof boof bork bork boof boof boof bork",
"Bark",
"Boof",
"Woofums",
"Rawrl",
"Eeeeeee",
"Barkums",
};
}

This file was deleted.

44 changes: 44 additions & 0 deletions Content.Server/SimpleStation14/Speech/Systems/RandomBarkSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Content.Server.Chat.Systems;
using Content.Shared.Mind.Components;
using Robust.Shared.Random;
using Content.Server.SimpleStation14.Speech.Components;

namespace Content.Server.SimpleStation14.Speech.Systems;

public sealed class RandomBarkSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly EntityManager _entities = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RandomBarkComponent, ComponentInit>(OnInit);
}

public void OnInit(EntityUid uid, RandomBarkComponent barker, ComponentInit args)
{
barker.BarkAccumulator = _random.NextFloat(barker.MinTime, barker.MaxTime)*barker.BarkMultiplier;
}

public override void Update(float frameTime)
{
base.Update(frameTime);

while (EntityQueryEnumerator<RandomBarkComponent>().MoveNext(out var uid, out var barker))
{
barker.BarkAccumulator -= frameTime;
if (barker.BarkAccumulator > 0)
continue;

barker.BarkAccumulator = _random.NextFloat(barker.MinTime, barker.MaxTime)*barker.BarkMultiplier;
if (_entities.TryGetComponent<MindContainerComponent>(uid, out var actComp) &&
actComp.HasMind)
continue;

_chat.TrySendInGameICMessage(uid, _random.Pick(barker.Barks), InGameICChatType.Speak, barker.Chatlog ? ChatTransmitRange.Normal : ChatTransmitRange.HideChat);
}
}
}

0 comments on commit fbdbc23

Please sign in to comment.