-
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.
# Changelog :cl: - add: Animals will no longer be a silent, soulless shell --------- Co-authored-by: Pspritechologist <[email protected]>
- Loading branch information
1 parent
ce823ae
commit ebe8760
Showing
5 changed files
with
176 additions
and
9 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
namespace Content.Server.SimpleStation14.Speech.Components; | ||
|
||
/// <summary> | ||
/// Sends a random message from a list with a provided min/max time. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class RandomBarkComponent : Component | ||
{ | ||
// Should the message be sent to the chat log? | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool ChatLog = false; | ||
|
||
// Minimum time an animal will go without speaking | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public int MinTime = 45; | ||
|
||
// Maximum time an animal will go without speaking | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public int MaxTime = 350; | ||
|
||
// Counter | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float BarkAccumulator = 8f; | ||
|
||
// Multiplier applied to the random time. Good for changing the frequency without having to specify exact values | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
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, 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: 47 additions & 0 deletions
47
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,47 @@ | ||
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 _entity = default!; | ||
|
||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<RandomBarkComponent, ComponentInit>(OnInit); | ||
} | ||
|
||
|
||
private 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); | ||
|
||
var query = EntityQueryEnumerator<RandomBarkComponent>(); | ||
while (query.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 (_entity.TryGetComponent<MindContainerComponent>(uid, out var actComp) && | ||
actComp.HasMind) | ||
continue; | ||
|
||
_chat.TrySendInGameICMessage(uid, _random.Pick(barker.Barks), InGameICChatType.Speak, barker.ChatLog ? ChatTransmitRange.Normal : ChatTransmitRange.HideChat); | ||
} | ||
} | ||
} |
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
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
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 |
---|---|---|
|
@@ -106,4 +106,4 @@ | |
- type: FloatingVisuals | ||
- type: Puller | ||
needsHands: True | ||
|
||
- type: Speech |