- add: interface for interaction

This commit is contained in:
2024-02-20 14:28:01 +03:00
parent c3135f160e
commit 28c8b45eec
32 changed files with 319 additions and 14 deletions

View 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;
}

View File

@@ -0,0 +1,5 @@
namespace Content.Shared._Amour.Arousal;
public record struct ArousalUpdated(Entity<ArousalComponent> Entity);
public record struct ArousalSplash(Entity<ArousalComponent> Entity);

View 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));
}
}