From b63a46e032c6b0bf19e7ba22c8adb3c747a2cbbb Mon Sep 17 00:00:00 2001 From: Cinka Date: Sat, 24 Feb 2024 21:20:43 +0300 Subject: [PATCH] - add: Crawl --- Content.Client/_Amour/Crawl/CrawlSystem.cs | 8 +++ Content.Server/_Amour/Crawl/CrawlSystem.cs | 26 +++++++ Content.Shared/_Amour/Crawl/CrawlComponent.cs | 10 +++ .../_Amour/Crawl/CrawlableComponent.cs | 7 ++ .../_Amour/Crawl/SharedCrawlSystem.cs | 70 +++++++++++++++++++ .../Prototypes/Entities/Mobs/Species/base.yml | 1 + .../_Amour/Actions/crawl_action.yml | 30 ++++++++ 7 files changed, 152 insertions(+) create mode 100644 Content.Client/_Amour/Crawl/CrawlSystem.cs create mode 100644 Content.Server/_Amour/Crawl/CrawlSystem.cs create mode 100644 Content.Shared/_Amour/Crawl/CrawlComponent.cs create mode 100644 Content.Shared/_Amour/Crawl/CrawlableComponent.cs create mode 100644 Content.Shared/_Amour/Crawl/SharedCrawlSystem.cs create mode 100644 Resources/Prototypes/_Amour/Actions/crawl_action.yml diff --git a/Content.Client/_Amour/Crawl/CrawlSystem.cs b/Content.Client/_Amour/Crawl/CrawlSystem.cs new file mode 100644 index 0000000000..1a340f7e61 --- /dev/null +++ b/Content.Client/_Amour/Crawl/CrawlSystem.cs @@ -0,0 +1,8 @@ +using Content.Shared._Amour.Crawl; + +namespace Content.Client._Amour.Crawl; + +public sealed class CrawlSystem : SharedCrawlSystem +{ + +} diff --git a/Content.Server/_Amour/Crawl/CrawlSystem.cs b/Content.Server/_Amour/Crawl/CrawlSystem.cs new file mode 100644 index 0000000000..98510c8a05 --- /dev/null +++ b/Content.Server/_Amour/Crawl/CrawlSystem.cs @@ -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(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; + } + } +} diff --git a/Content.Shared/_Amour/Crawl/CrawlComponent.cs b/Content.Shared/_Amour/Crawl/CrawlComponent.cs new file mode 100644 index 0000000000..cb72034a33 --- /dev/null +++ b/Content.Shared/_Amour/Crawl/CrawlComponent.cs @@ -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; +} diff --git a/Content.Shared/_Amour/Crawl/CrawlableComponent.cs b/Content.Shared/_Amour/Crawl/CrawlableComponent.cs new file mode 100644 index 0000000000..8201639b5c --- /dev/null +++ b/Content.Shared/_Amour/Crawl/CrawlableComponent.cs @@ -0,0 +1,7 @@ +namespace Content.Shared._Amour.Crawl; + +[RegisterComponent] +public sealed partial class CrawlableComponent : Component +{ + +} diff --git a/Content.Shared/_Amour/Crawl/SharedCrawlSystem.cs b/Content.Shared/_Amour/Crawl/SharedCrawlSystem.cs new file mode 100644 index 0000000000..454238b749 --- /dev/null +++ b/Content.Shared/_Amour/Crawl/SharedCrawlSystem.cs @@ -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(OnInit); + SubscribeLocalEvent(OnShutdown); + SubscribeLocalEvent(OnCrawlShutdown); + SubscribeLocalEvent(OnStood); + SubscribeLocalEvent(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(uid); + } + + public void DisableCrawl(EntityUid uid) + { + RemComp(uid); + } +} diff --git a/Resources/Prototypes/Entities/Mobs/Species/base.yml b/Resources/Prototypes/Entities/Mobs/Species/base.yml index 21c6f369a2..d7fe766917 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/base.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/base.yml @@ -265,6 +265,7 @@ - type: Mood - type: HoleContainer - type: Arousal + - type: Crawlable - type: InteractionPanel actionPrototypes: - SlapButt diff --git a/Resources/Prototypes/_Amour/Actions/crawl_action.yml b/Resources/Prototypes/_Amour/Actions/crawl_action.yml new file mode 100644 index 0000000000..d9e1c5066e --- /dev/null +++ b/Resources/Prototypes/_Amour/Actions/crawl_action.yml @@ -0,0 +1,30 @@ +- type: emote + id: EmoteCrawl + buttonText: Ползти + chatMessages: [падает] + chatTriggers: + - падает + - ползет + - упала + - упало + - лежит + - улегся + - улеглась + - улеглось + - упал + - лёг + allowMenu: true + +- type: emote + id: EmoteCrawlUp + buttonText: Встать + chatMessages: [встает] + chatTriggers: + - встает + - встал + - встала + - встало + - поднялась + - поднялось + - поднялся + allowMenu: true