From 1edd48004d271bb1656e3cc679c53bf8338c3fbb Mon Sep 17 00:00:00 2001 From: Vigers Ray <60344369+VigersRay@users.noreply.github.com> Date: Sun, 9 Jun 2024 06:16:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BB=D0=B0=D1=87=20=D0=B8=20=D0=BA?= =?UTF-8?q?=D1=80=D0=B8=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=83=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B0.=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * фикс спонсорских лоадаутов * paws * чейнжлог --- Content.Server/_Sunrise/Paws/PawsComponent.cs | 33 +++++++++ Content.Server/_Sunrise/Paws/PawsSystem.cs | 70 +++++++++++++++++++ Resources/Changelog/ChangelogSunrise.yml | 14 ++++ .../Prototypes/Entities/Mobs/Species/base.yml | 4 ++ 4 files changed, 121 insertions(+) create mode 100644 Content.Server/_Sunrise/Paws/PawsComponent.cs create mode 100644 Content.Server/_Sunrise/Paws/PawsSystem.cs diff --git a/Content.Server/_Sunrise/Paws/PawsComponent.cs b/Content.Server/_Sunrise/Paws/PawsComponent.cs new file mode 100644 index 00000000000..f96d3ce06af --- /dev/null +++ b/Content.Server/_Sunrise/Paws/PawsComponent.cs @@ -0,0 +1,33 @@ +using Content.Shared.FixedPoint; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; + +namespace Content.Server.Sunrise.Paws +{ + [RegisterComponent] + public sealed partial class PawsComponent : Component + { + [ViewVariables(VVAccess.ReadWrite)] + [DataField("screamInterval")] + public float ScreamInterval = 3; + + [ViewVariables(VVAccess.ReadWrite)] + [DataField("coughInterval")] + public float CoughInterval = 5; + + [ViewVariables(VVAccess.ReadWrite)] + [DataField("thresholdDamage")] + public FixedPoint2 ThresholdDamage = 5; + + public List EmotesTakeDamage = new() + { + "Scream", + "Crying" + }; + + [DataField("nextChargeTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] + public TimeSpan NextScreamTime = TimeSpan.FromSeconds(0); + + [DataField("nextCoughTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] + public TimeSpan NextCoughTime = TimeSpan.FromSeconds(0); + } +} diff --git a/Content.Server/_Sunrise/Paws/PawsSystem.cs b/Content.Server/_Sunrise/Paws/PawsSystem.cs new file mode 100644 index 00000000000..304d3e9608c --- /dev/null +++ b/Content.Server/_Sunrise/Paws/PawsSystem.cs @@ -0,0 +1,70 @@ +using Content.Server.Chat.Systems; +using Content.Shared.Damage; +using Content.Shared.Mobs; +using Content.Shared.Mobs.Components; +using Content.Shared.Mobs.Systems; +using Robust.Shared.Random; +using Robust.Shared.Timing; + +namespace Content.Server.Sunrise.Paws +{ + public sealed class PawsSystem : EntitySystem + { + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; + [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly ChatSystem _chatSystem = default!; + [Dependency] private readonly IRobustRandom _random = default!; + + public override void Initialize() + { + base.Initialize(); + // SubscribeLocalEvent(OnMobStateChanged); + SubscribeLocalEvent(OnDamaged); + } + + // private void OnMobStateChanged(EntityUid uid, PawsComponent component, MobStateChangedEvent args) + // { + // if (args.NewMobState == MobState.Dead) + // _audioSystem.PlayPvs(component.DeadSound, uid, component.DeadSound.Params); + // } + + private void OnDamaged(EntityUid uid, PawsComponent component, DamageChangedEvent args) + { + if (!_mobStateSystem.IsAlive(uid)) + return; + + if (!args.DamageIncreased) + return; + + var curTime = _timing.CurTime; + + if (curTime < component.NextScreamTime) + return; + + if (args.DamageDelta!.GetTotal() < component.ThresholdDamage) + return; + + component.NextScreamTime = curTime + TimeSpan.FromSeconds(component.ScreamInterval); + _chatSystem.TryEmoteWithChat(uid, _random.Pick(component.EmotesTakeDamage)); + } + + public override void Update(float frameTime) + { + base.Update(frameTime); + var curTime = _timing.CurTime; + + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var comp, out var state)) + { + if (state.CurrentState != MobState.Critical) + continue; + + if (curTime < comp.NextCoughTime) + return; + + comp.NextCoughTime = curTime + TimeSpan.FromSeconds(comp.CoughInterval); + _chatSystem.TryEmoteWithChat(uid, "Cough", ignoreActionBlocker: true); + } + } + } +} diff --git a/Resources/Changelog/ChangelogSunrise.yml b/Resources/Changelog/ChangelogSunrise.yml index c6582e8e59e..7b7597f6145 100644 --- a/Resources/Changelog/ChangelogSunrise.yml +++ b/Resources/Changelog/ChangelogSunrise.yml @@ -353,3 +353,17 @@ Entries: type: Tweak id: 31 time: '2024-06-09T00:03:07.870112+00:00' +- author: VigersRay + changes: + - message: "\u041F\u0440\u0438 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u0438\ + \ \u0443\u0440\u043E\u043D\u0430 \u0433\u0443\u043C\u0430\u043D\u043E\u0438\u0434\ + \u044B \u0442\u0435\u043F\u0435\u0440\u044C \u043A\u0440\u0438\u0447\u0430\u0442\ + \ \u0438 \u043F\u043B\u0430\u0447\u0443\u0442." + type: Tweak + - message: "\u0411\u0443\u0434\u0443\u0447\u0438 \u0432 \u043A\u0440\u0438\u0442\ + \u0438\u0447\u0435\u0441\u043A\u043E\u043C \u0441\u043E\u0441\u0442\u043E\u044F\ + \u043D\u0438\u0438 \u0433\u0443\u043C\u0430\u043D\u043E\u0438\u0434\u044B \u043A\ + \u0430\u0448\u043B\u044F\u044E\u0442." + type: Tweak + id: 32 + time: '2024-06-09T02:52:26.930025+00:00' diff --git a/Resources/Prototypes/Entities/Mobs/Species/base.yml b/Resources/Prototypes/Entities/Mobs/Species/base.yml index 2739f1f98a2..05cbd0ee306 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/base.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/base.yml @@ -228,6 +228,10 @@ - CanPilot - FootstepSound - DoorBumpOpener + - type: Paws + screamInterval: 3 + thresholdDamage: 5 + coughInterval: 5 - type: entity save: false