- add: interface for interaction
This commit is contained in:
9
Content.Shared/_Amour/Arousal/ArousalComponent.cs
Normal file
9
Content.Shared/_Amour/Arousal/ArousalComponent.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Content.Shared._Amour.Arousal;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class ArousalComponent : Component
|
||||
{
|
||||
[ViewVariables] public short Arousal;
|
||||
[DataField] public short ArousalExide;
|
||||
}
|
||||
|
||||
5
Content.Shared/_Amour/Arousal/ArousalEvents.cs
Normal file
5
Content.Shared/_Amour/Arousal/ArousalEvents.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Content.Shared._Amour.Arousal;
|
||||
|
||||
public record struct ArousalUpdated(Entity<ArousalComponent> Entity);
|
||||
|
||||
public record struct ArousalSplash(Entity<ArousalComponent> Entity);
|
||||
51
Content.Shared/_Amour/Arousal/ArousalSystem.cs
Normal file
51
Content.Shared/_Amour/Arousal/ArousalSystem.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Content.Shared.Alert;
|
||||
|
||||
namespace Content.Shared._Amour.Arousal;
|
||||
|
||||
public sealed class ArousalSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<ArousalComponent,ComponentInit>(OnComponentInit);
|
||||
}
|
||||
|
||||
private void OnComponentInit(EntityUid uid, ArousalComponent component, ComponentInit args)
|
||||
{
|
||||
UpdateAlarm(new Entity<ArousalComponent?>(uid,component));
|
||||
}
|
||||
|
||||
private void UpdateAlarm(Entity<ArousalComponent?> entity)
|
||||
{
|
||||
if(!Resolve(entity,ref entity.Comp))
|
||||
return;
|
||||
|
||||
if (entity.Comp.Arousal is > 100 or < 0)
|
||||
{
|
||||
entity.Comp.Arousal = 0;
|
||||
RaiseLocalEvent(entity,new ArousalSplash(new Entity<ArousalComponent>(entity,entity.Comp)));
|
||||
}
|
||||
RaiseLocalEvent(entity,new ArousalUpdated(new Entity<ArousalComponent>(entity,entity.Comp)));
|
||||
|
||||
_alerts.ShowAlert(entity,AlertType.Arousal,(short)(entity.Comp.Arousal/10));
|
||||
}
|
||||
|
||||
public void SetArousal(Entity<ArousalComponent?> entity, short count)
|
||||
{
|
||||
if(!Resolve(entity,ref entity.Comp))
|
||||
return;
|
||||
|
||||
entity.Comp.Arousal = count;
|
||||
UpdateAlarm(entity);
|
||||
}
|
||||
|
||||
public void AddArousal(Entity<ArousalComponent?> entity, short count)
|
||||
{
|
||||
if(!Resolve(entity,ref entity.Comp))
|
||||
return;
|
||||
|
||||
SetArousal(entity,(short) (entity.Comp.Arousal + count));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user