- add: Crawl

This commit is contained in:
2024-02-24 21:20:43 +03:00
parent e15ae4ced8
commit b63a46e032
7 changed files with 152 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
using Content.Shared._Amour.Crawl;
namespace Content.Client._Amour.Crawl;
public sealed class CrawlSystem : SharedCrawlSystem
{
}

View File

@@ -0,0 +1,26 @@
using Content.Server.Chat.Systems;
using Content.Shared._Amour.Crawl;
namespace Content.Server._Amour.Crawl;
public sealed class CrawlSystem : SharedCrawlSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CrawlableComponent, EmoteEvent>(OnEmote);
}
private void OnEmote(EntityUid uid, CrawlableComponent component,ref EmoteEvent args)
{
switch (args.Emote.ID)
{
case "EmoteCrawl":
EnableCrawl(uid);
break;
case "EmoteCrawlUp":
DisableCrawl(uid);
break;
}
}
}

View File

@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;
namespace Content.Shared._Amour.Crawl;
[RegisterComponent, NetworkedComponent]
public sealed partial class CrawlComponent : Component
{
public float SprintSpeedModifier { get; set; } = 0.4f;
public float WalkSpeedModifier { get; set; } = 0.4f;
}

View File

@@ -0,0 +1,7 @@
namespace Content.Shared._Amour.Crawl;
[RegisterComponent]
public sealed partial class CrawlableComponent : Component
{
}

View File

@@ -0,0 +1,70 @@
using Content.Shared.Buckle;
using Content.Shared.Movement.Systems;
using Content.Shared.Standing;
using Content.Shared.StatusEffect;
namespace Content.Shared._Amour.Crawl;
public abstract class SharedCrawlSystem : EntitySystem
{
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
[Dependency] private readonly MovementSpeedModifierSystem _speed = default!;
[Dependency] private readonly StandingStateSystem _standingStateSystem = default!;
[Dependency] private readonly SharedBuckleSystem _buckle = default!;
public override void Initialize()
{
SubscribeLocalEvent<CrawlComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<CrawlComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<CrawlableComponent, ComponentShutdown>(OnCrawlShutdown);
SubscribeLocalEvent<CrawlComponent, StoodEvent>(OnStood);
SubscribeLocalEvent<CrawlComponent, RefreshMovementSpeedModifiersEvent>(OnRefresh);
}
private void OnRefresh(EntityUid uid, CrawlComponent component, RefreshMovementSpeedModifiersEvent args)
{
args.ModifySpeed(component.WalkSpeedModifier, component.SprintSpeedModifier);
}
private void OnInit(EntityUid uid, CrawlComponent component, ComponentInit args)
{
if (_buckle.TryUnbuckle(uid, uid) || !_standingStateSystem.Down(uid, true, false))
{
DisableCrawl(uid);
return;
}
_speed.RefreshMovementSpeedModifiers(uid);
}
private void OnCrawlShutdown(EntityUid uid, CrawlableComponent component, ComponentShutdown args)
{
DisableCrawl(uid);
}
private void OnStood(EntityUid uid, CrawlComponent component, StoodEvent args)
{
if (component.LifeStage == ComponentLifeStage.Stopping)
return;
DisableCrawl(uid);
}
private void OnShutdown(EntityUid uid, CrawlComponent component, ComponentShutdown args)
{
_standingStateSystem.Stand(uid);
component.SprintSpeedModifier = 1f;
component.WalkSpeedModifier = 1f;
_speed.RefreshMovementSpeedModifiers(uid);
}
public void EnableCrawl(EntityUid uid)
{
EnsureComp<CrawlComponent>(uid);
}
public void DisableCrawl(EntityUid uid)
{
RemComp<CrawlComponent>(uid);
}
}

View File

@@ -265,6 +265,7 @@
- type: Mood
- type: HoleContainer
- type: Arousal
- type: Crawlable
- type: InteractionPanel
actionPrototypes:
- SlapButt

View File

@@ -0,0 +1,30 @@
- type: emote
id: EmoteCrawl
buttonText: Ползти
chatMessages: [падает]
chatTriggers:
- падает
- ползет
- упала
- упало
- лежит
- улегся
- улеглась
- улеглось
- упал
- лёг
allowMenu: true
- type: emote
id: EmoteCrawlUp
buttonText: Встать
chatMessages: [встает]
chatTriggers:
- встает
- встал
- встала
- встало
- поднялась
- поднялось
- поднялся
allowMenu: true