New Traits (#13763)

This commit is contained in:
Scribbles0
2023-03-04 19:44:13 -08:00
committed by GitHub
parent 224dd1e515
commit 46e89c07c8
11 changed files with 305 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
using Robust.Shared.GameStates;
using Content.Shared.Drunk;
namespace Content.Shared.Traits.Assorted;
/// <summary>
/// Used for the lightweight trait. DrunkSystem will check for this component and modify the boozePower accordingly if it finds it.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedDrunkSystem))]
public sealed class LightweightDrunkComponent : Component
{
[DataField("boozeStrengthMultiplier"), ViewVariables(VVAccess.ReadWrite)]
public float BoozeStrengthMultiplier = 4f;
}

View File

@@ -0,0 +1,61 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using System;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Traits.Assorted;
/// <summary>
/// This component is used for paracusia, which causes auditory hallucinations.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedParacusiaSystem))]
public sealed class ParacusiaComponent : Component
{
/// <summary>
/// The maximum time between incidents in seconds
/// </summary>
[DataField("maxTimeBetweenIncidents", required: true), ViewVariables(VVAccess.ReadWrite)]
public float MaxTimeBetweenIncidents = 30f;
/// <summary>
/// The minimum time between incidents in seconds
/// </summary>
[DataField("minTimeBetweenIncidents", required: true), ViewVariables(VVAccess.ReadWrite)]
public float MinTimeBetweenIncidents = 60f;
/// <summary>
/// How far away at most can the sound be?
/// </summary>
[DataField("maxSoundDistance", required: true), ViewVariables(VVAccess.ReadWrite)]
public float MaxSoundDistance;
/// <summary>
/// The sounds to choose from
/// </summary>
[DataField("sounds", required: true)]
public SoundSpecifier Sounds = default!;
[DataField("timeBetweenIncidents", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextIncidentTime;
public IPlayingAudioStream? Stream;
}
[Serializable, NetSerializable]
public sealed class ParacusiaComponentState : ComponentState
{
public readonly float MaxTimeBetweenIncidents;
public readonly float MinTimeBetweenIncidents;
public readonly float MaxSoundDistance;
public readonly SoundSpecifier Sounds = default!;
public ParacusiaComponentState(float maxTimeBetweenIncidents, float minTimeBetweenIncidents, float maxSoundDistance, SoundSpecifier sounds)
{
MaxTimeBetweenIncidents = maxTimeBetweenIncidents;
MinTimeBetweenIncidents = minTimeBetweenIncidents;
MaxSoundDistance = maxSoundDistance;
Sounds = sounds;
}
}

View File

@@ -0,0 +1,30 @@
using Content.Shared.GameTicking;
using Robust.Shared.GameStates;
namespace Content.Shared.Traits.Assorted;
public abstract class SharedParacusiaSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ParacusiaComponent, ComponentGetState>(GetCompState);
SubscribeLocalEvent<ParacusiaComponent, ComponentHandleState>(HandleCompState);
}
private void GetCompState(EntityUid uid, ParacusiaComponent component, ref ComponentGetState args)
{
args.State = new ParacusiaComponentState(component.MaxTimeBetweenIncidents, component.MinTimeBetweenIncidents, component.MaxSoundDistance, component.Sounds);
}
private void HandleCompState(EntityUid uid, ParacusiaComponent component, ref ComponentHandleState args)
{
if (args.Current is not ParacusiaComponentState state)
return;
component.MaxTimeBetweenIncidents = state.MaxTimeBetweenIncidents;
component.MinTimeBetweenIncidents = state.MinTimeBetweenIncidents;
component.MaxSoundDistance = state.MaxSoundDistance;
component.Sounds = state.Sounds;
}
}