-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af9e08f
commit fbdbc23
Showing
3 changed files
with
87 additions
and
81 deletions.
There are no files selected for viewing
77 changes: 43 additions & 34 deletions
77
Content.Server/SimpleStation14/Speech/Components/RandomBarkComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}; | ||
} |
47 changes: 0 additions & 47 deletions
47
Content.Server/SimpleStation14/Speech/EntitySystems/RandomBarkSystem.cs
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
Content.Server/SimpleStation14/Speech/Systems/RandomBarkSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |