Skip to content

Commit

Permalink
+ new sounds and RaveSystem rework
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaldetSkaeg committed Sep 24, 2024
1 parent f13c6ba commit 0f67c8e
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 22 deletions.
39 changes: 30 additions & 9 deletions Content.Server/SS220/CultYogg/RaveComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Robust.Shared.GameStates;
using System.Numerics;
using Robust.Shared.Audio;
using Content.Shared.SS220.CultYogg.Components;

namespace Content.Server.SS220.CultYogg;
Expand All @@ -9,17 +9,38 @@ namespace Content.Server.SS220.CultYogg;
public sealed partial class RaveComponent : SharedRaveComponent
{
/// <summary>
/// The random time between incidents: min, max.
/// The minimum time in seconds between pronouncing rleh phrase.
/// </summary>
public Vector2 TimeBetweenIncidents = new Vector2(0, 5);

[DataField]
public TimeSpan MinIntervalPhrase = TimeSpan.FromSeconds(20);

/// <summary>
/// The maximum time in seconds between pronouncing rleh phrase.
/// </summary>
[DataField]
public TimeSpan MaxIntervalPhrase = TimeSpan.FromSeconds(40);
/// <summary>
/// Buffer that contains next event
/// </summary>
public TimeSpan NextPhraseTime;

public TimeSpan MinIntervalSound = TimeSpan.FromSeconds(20);

public TimeSpan MaxIntervalSound = TimeSpan.FromSeconds(40);
/// <summary>
/// The minimum time in seconds between playing the sound.
/// </summary>
[DataField]
public TimeSpan MinIntervalSound = TimeSpan.FromSeconds(5);
/// <summary>
/// The maximum time in seconds between playing the sound.
/// </summary>
[DataField]
public TimeSpan MaxIntervalSound = TimeSpan.FromSeconds(10);
/// <summary>
/// Buffer that contains next event
/// </summary>
public TimeSpan NextSoundTime;

public float NextIncidentTime;
/// <summary>
/// Contains special sounds which be played during Rave
/// </summary>
[DataField]
public SoundSpecifier RaveSoundCollection = new SoundCollectionSpecifier("RaveSounds");
}
42 changes: 31 additions & 11 deletions Content.Server/SS220/CultYogg/RaveSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using Content.Shared.Dataset;
using Robust.Shared.Random;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.GameObjects;
using Robust.Shared.Audio.Systems;

namespace Content.Server.SS220.CultYogg;

Expand All @@ -14,6 +17,8 @@ public sealed class RaveSystem : SharedRaveSystem
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;

[ValidatePrototypeId<DatasetPrototype>]
private const string PhrasesPlaceholders = "CultRlehPhrases";
Expand All @@ -31,16 +36,17 @@ public override void Update(float frameTime)
var query = EntityQueryEnumerator<RaveComponent>();
while (query.MoveNext(out var uid, out var raving))
{
raving.NextIncidentTime -= frameTime;
if (raving.NextPhraseTime <= _timing.CurTime)
{
_chat.TrySendInGameICMessage(uid, PickPhrase(PhrasesPlaceholders), InGameICChatType.Speak, ChatTransmitRange.Normal);
SetNextPhraseTimer(raving);
}

if (raving.NextIncidentTime >= 0)
continue;

// Set the new time.
raving.NextIncidentTime +=
_random.NextFloat(raving.TimeBetweenIncidents.X, raving.TimeBetweenIncidents.Y);

_chat.TrySendInGameICMessage(uid, PickPhrase(PhrasesPlaceholders), InGameICChatType.Speak, ChatTransmitRange.Normal);
if (raving.NextSoundTime <= _timing.CurTime)
{
_audio.PlayPredicted(raving.RaveSoundCollection, uid, uid);//ToDo idk why it isn't doing anything
SetNextSoundTimer(raving);
}
}
}

Expand Down Expand Up @@ -71,8 +77,22 @@ public void TryRemoveRavenessTime(EntityUid uid, double timeRemoved)

private void SetupRaving(Entity<RaveComponent> uid, ref ComponentStartup args)
{
uid.Comp.NextIncidentTime =
_random.NextFloat(uid.Comp.TimeBetweenIncidents.X, uid.Comp.TimeBetweenIncidents.Y);
SetNextPhraseTimer(uid.Comp);
SetNextSoundTimer(uid.Comp);
}

private void SetNextPhraseTimer(RaveComponent comp)
{
comp.NextPhraseTime = _timing.CurTime + ((comp.MinIntervalPhrase < comp.MaxIntervalPhrase)
? _random.Next(comp.MinIntervalPhrase, comp.MaxIntervalPhrase)
: comp.MaxIntervalPhrase);
}

private void SetNextSoundTimer(RaveComponent comp)
{
comp.NextSoundTime = _timing.CurTime + ((comp.MinIntervalSound < comp.MaxIntervalSound )
? _random.Next(comp.MinIntervalSound, comp.MaxIntervalSound)
: comp.MaxIntervalSound);
}

private string PickPhrase(string name)
Expand Down
2 changes: 1 addition & 1 deletion Resources/Audio/SS220/CultYogg/attributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
copyright: "Original is created by DeezSoundzTho"
source: "https://freesound.org/people/DeezSoundzTho/sounds/383334/"

- files: ["migo_astral_in.ogg","migo_astral_out.ogg","migo_slave.ogg"]
- files: ["migo_astral_in.ogg", "migo_astral_out.ogg", "migo_slave.ogg", "nyarlathotep_step1.ogg", "nyarlathotep_step2.ogg", "nyarlathotep_voice1.ogg", "nyarlathotep_voice2.ogg", "nyarlathotep_voice3.ogg", "nyarlathotep_start.ogg"]
license: "CC-BY-3.0"
copyright: "Original is created by MIXnikita for SS220"
source: "https://github.com/SerbiaStrong-22"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 18 additions & 1 deletion Resources/Prototypes/SS220/SoundCollections/emotes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
- /Audio/SS220/Voice/MedicTF2/medic_scream_2.ogg
- /Audio/SS220/Voice/MedicTF2/medic_scream_3.ogg
- /Audio/SS220/Voice/MedicTF2/medic_scream_4.ogg

- type: soundCollection
id: MaleGiggle
files:
Expand Down Expand Up @@ -295,3 +295,20 @@
id: FelinidPurrs
files:
- /Audio/Voice/Felinid/cat_purr1.ogg

- type: soundCollection
id: NyarlathotepSounds
files:
- /Audio/SS220/CultYogg/nyarlathotep_step1.ogg
- /Audio/SS220/CultYogg/nyarlathotep_step2.ogg
- /Audio/SS220/CultYogg/nyarlathotep_voice1.ogg
- /Audio/SS220/CultYogg/nyarlathotep_voice2.ogg
- /Audio/SS220/CultYogg/nyarlathotep_voice3.ogg

- type: soundCollection
id: RaveSounds
files:
- /Audio/SS220/CultYogg/nyarlathotep_voice1.ogg
- /Audio/SS220/CultYogg/nyarlathotep_voice2.ogg
- /Audio/SS220/CultYogg/nyarlathotep_voice3.ogg

0 comments on commit 0f67c8e

Please sign in to comment.