From 858d1647dbc38756c2170d8117e101abe5db281a Mon Sep 17 00:00:00 2001 From: FaDeOkno Date: Tue, 20 Aug 2024 23:36:56 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=B7=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20!=3D=20=D0=BF=D0=B0=D1=80=D0=B8=D1=82=D1=8C=20=D0=BD=D0=B0?= =?UTF-8?q?=D0=B4=20=D1=81=D1=82=D0=BE=D0=BB=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/ADT/Crawling/CrawlingSystem.cs | 53 +++++++++++++++++++ Content.Server/ADT/Crawling/CrawlingSystem.cs | 16 ++++++ .../ADT/Crawling/CrawlingComponent.cs | 2 +- ...wlingSystem.cs => SharedCrawlingSystem.cs} | 27 +++++++++- 4 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 Content.Client/ADT/Crawling/CrawlingSystem.cs create mode 100644 Content.Server/ADT/Crawling/CrawlingSystem.cs rename Content.Shared/ADT/Crawling/{CrawlingSystem.cs => SharedCrawlingSystem.cs} (83%) diff --git a/Content.Client/ADT/Crawling/CrawlingSystem.cs b/Content.Client/ADT/Crawling/CrawlingSystem.cs new file mode 100644 index 00000000000..5c2909377c5 --- /dev/null +++ b/Content.Client/ADT/Crawling/CrawlingSystem.cs @@ -0,0 +1,53 @@ +using Content.Shared.DoAfter; +using Content.Shared.Explosion; +using Content.Shared.Input; +using Robust.Shared.Input.Binding; +using Content.Shared.Standing; +using Robust.Shared.Serialization; +using Content.Shared.Stunnable; +using Robust.Shared.Player; +using Content.Shared.Movement.Systems; +using Content.Shared.Alert; +using Content.Shared.ADT.Crawling; +using DrawDepth = Content.Shared.DrawDepth.DrawDepth; +using Robust.Client.GameObjects; +using Robust.Shared.Prototypes; + +namespace Content.Client.ADT.Crawling; +public sealed partial class CrawlingSystem : SharedCrawlingSystem +{ + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly IPrototypeManager _proto = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnAppearanceChange); + } + + private void OnAppearanceChange(EntityUid uid, CrawlerComponent comp, AppearanceChangeEvent args) + { + if (args.Sprite == null) + return; + + if (_appearance.TryGetData(uid, CrawlingVisuals.Crawling, out var crawling, args.Component) && crawling) + { + args.Sprite.DrawDepth = (int) DrawDepth.SmallMobs; + } + else if (_appearance.TryGetData(uid, CrawlingVisuals.Standing, out var standing, args.Component) && standing) + { + if (TryPrototype(uid, out var proto) && proto.Components.TryGetComponent("SpriteComponent", out var sprite)) // TODO нормальное читание прототипа. Этот вариант не работает, потому маленьким мобам ползание не добавляем + { + var spriteComp = (SpriteComponent) sprite; + if (spriteComp != null) + args.Sprite.DrawDepth = spriteComp.DrawDepth; + else + args.Sprite.DrawDepth = (int) DrawDepth.Mobs; + } + else + args.Sprite.DrawDepth = (int) DrawDepth.Mobs; + } + + } +} diff --git a/Content.Server/ADT/Crawling/CrawlingSystem.cs b/Content.Server/ADT/Crawling/CrawlingSystem.cs new file mode 100644 index 00000000000..0aa29fc39c5 --- /dev/null +++ b/Content.Server/ADT/Crawling/CrawlingSystem.cs @@ -0,0 +1,16 @@ +using Content.Shared.DoAfter; +using Content.Shared.Explosion; +using Content.Shared.Input; +using Robust.Shared.Input.Binding; +using Content.Shared.Standing; +using Robust.Shared.Serialization; +using Content.Shared.Stunnable; +using Robust.Shared.Player; +using Content.Shared.Movement.Systems; +using Content.Shared.Alert; +using Content.Shared.ADT.Crawling; + +namespace Content.Server.ADT.Crawling; +public sealed partial class CrawlingSystem : SharedCrawlingSystem +{ +} diff --git a/Content.Shared/ADT/Crawling/CrawlingComponent.cs b/Content.Shared/ADT/Crawling/CrawlingComponent.cs index 76176040131..9ecf9dec0d8 100644 --- a/Content.Shared/ADT/Crawling/CrawlingComponent.cs +++ b/Content.Shared/ADT/Crawling/CrawlingComponent.cs @@ -3,7 +3,7 @@ namespace Content.Shared.ADT.Crawling; -[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(CrawlingSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedCrawlingSystem))] public sealed partial class CrawlingComponent : Component { [ViewVariables, DataField("sprintSpeedModifier"), AutoNetworkedField] diff --git a/Content.Shared/ADT/Crawling/CrawlingSystem.cs b/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs similarity index 83% rename from Content.Shared/ADT/Crawling/CrawlingSystem.cs rename to Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs index 284aedd23b4..8296958c65f 100644 --- a/Content.Shared/ADT/Crawling/CrawlingSystem.cs +++ b/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs @@ -8,14 +8,18 @@ using Robust.Shared.Player; using Content.Shared.Movement.Systems; using Content.Shared.Alert; +using Robust.Shared.Physics.Systems; +using System.Numerics; namespace Content.Shared.ADT.Crawling; -public sealed partial class CrawlingSystem : EntitySystem +public abstract class SharedCrawlingSystem : EntitySystem { [Dependency] private readonly StandingStateSystem _standing = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!; [Dependency] private readonly AlertsSystem _alerts = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedPhysicsSystem _physics = default!; public override void Initialize() { base.Initialize(); @@ -31,9 +35,11 @@ public override void Initialize() SubscribeLocalEvent(OnCrawlSlowRemove); SubscribeLocalEvent(OnRefreshMovespeed); + SubscribeLocalEvent(OnCrawlerInit); + CommandBinds.Builder .Bind(ContentKeyFunctions.ToggleCrawling, InputCmdHandler.FromDelegate(ToggleCrawlingKeybind, handle: false)) - .Register(); + .Register(); } private void ToggleCrawlingKeybind(ICommonSession? session) @@ -99,17 +105,27 @@ private void OnGetExplosionResistance(EntityUid uid, CrawlerComponent component, private void OnCrawlSlowdownInit(EntityUid uid, CrawlingComponent component, ComponentInit args) { _movementSpeedModifier.RefreshMovementSpeedModifiers(uid); + _appearance.SetData(uid, CrawlingVisuals.Standing, false); + _appearance.SetData(uid, CrawlingVisuals.Crawling, true); } private void OnCrawlSlowRemove(EntityUid uid, CrawlingComponent component, ComponentShutdown args) { component.SprintSpeedModifier = 1f; component.WalkSpeedModifier = 1f; _movementSpeedModifier.RefreshMovementSpeedModifiers(uid); + _appearance.SetData(uid, CrawlingVisuals.Crawling, false); + _appearance.SetData(uid, CrawlingVisuals.Standing, true); } private void OnRefreshMovespeed(EntityUid uid, CrawlingComponent component, RefreshMovementSpeedModifiersEvent args) { args.ModifySpeed(component.WalkSpeedModifier, component.SprintSpeedModifier); } + + private void OnCrawlerInit(EntityUid uid, CrawlerComponent comp, MapInitEvent args) + { + _appearance.SetData(uid, CrawlingVisuals.Standing, true); + _appearance.SetData(uid, CrawlingVisuals.Crawling, false); + } } [Serializable, NetSerializable] @@ -121,3 +137,10 @@ public sealed partial class CrawlStandupDoAfterEvent : SimpleDoAfterEvent public sealed partial class CrawlingKeybindEvent { } + +[NetSerializable, Serializable] +public enum CrawlingVisuals : byte +{ + Standing, + Crawling, +} From d0d8a3bbc96aa96f76c7b27cbc66c94373973c9b Mon Sep 17 00:00:00 2001 From: FaDeOkno Date: Tue, 20 Aug 2024 23:52:52 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D0=A3=D0=B1=D0=B8=D1=80=D0=B0=D0=B5=D0=BC?= =?UTF-8?q?=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D0=B5=20=D1=81=D1=81=D1=8B?= =?UTF-8?q?=D0=BB=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/ADT/Crawling/CrawlingSystem.cs | 14 +------------- Content.Server/ADT/Crawling/CrawlingSystem.cs | 11 +---------- .../ADT/Crawling/SharedCrawlingSystem.cs | 4 +--- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/Content.Client/ADT/Crawling/CrawlingSystem.cs b/Content.Client/ADT/Crawling/CrawlingSystem.cs index 5c2909377c5..20ab8719a1a 100644 --- a/Content.Client/ADT/Crawling/CrawlingSystem.cs +++ b/Content.Client/ADT/Crawling/CrawlingSystem.cs @@ -1,24 +1,12 @@ -using Content.Shared.DoAfter; -using Content.Shared.Explosion; -using Content.Shared.Input; -using Robust.Shared.Input.Binding; -using Content.Shared.Standing; -using Robust.Shared.Serialization; -using Content.Shared.Stunnable; -using Robust.Shared.Player; -using Content.Shared.Movement.Systems; -using Content.Shared.Alert; using Content.Shared.ADT.Crawling; using DrawDepth = Content.Shared.DrawDepth.DrawDepth; using Robust.Client.GameObjects; -using Robust.Shared.Prototypes; namespace Content.Client.ADT.Crawling; + public sealed partial class CrawlingSystem : SharedCrawlingSystem { [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - [Dependency] private readonly IPrototypeManager _proto = default!; - public override void Initialize() { base.Initialize(); diff --git a/Content.Server/ADT/Crawling/CrawlingSystem.cs b/Content.Server/ADT/Crawling/CrawlingSystem.cs index 0aa29fc39c5..904046e1c48 100644 --- a/Content.Server/ADT/Crawling/CrawlingSystem.cs +++ b/Content.Server/ADT/Crawling/CrawlingSystem.cs @@ -1,16 +1,7 @@ -using Content.Shared.DoAfter; -using Content.Shared.Explosion; -using Content.Shared.Input; -using Robust.Shared.Input.Binding; -using Content.Shared.Standing; -using Robust.Shared.Serialization; -using Content.Shared.Stunnable; -using Robust.Shared.Player; -using Content.Shared.Movement.Systems; -using Content.Shared.Alert; using Content.Shared.ADT.Crawling; namespace Content.Server.ADT.Crawling; + public sealed partial class CrawlingSystem : SharedCrawlingSystem { } diff --git a/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs b/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs index 8296958c65f..c43eadfddda 100644 --- a/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs +++ b/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs @@ -8,10 +8,9 @@ using Robust.Shared.Player; using Content.Shared.Movement.Systems; using Content.Shared.Alert; -using Robust.Shared.Physics.Systems; -using System.Numerics; namespace Content.Shared.ADT.Crawling; + public abstract class SharedCrawlingSystem : EntitySystem { [Dependency] private readonly StandingStateSystem _standing = default!; @@ -19,7 +18,6 @@ public abstract class SharedCrawlingSystem : EntitySystem [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!; [Dependency] private readonly AlertsSystem _alerts = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - [Dependency] private readonly SharedPhysicsSystem _physics = default!; public override void Initialize() { base.Initialize(); From 95b616f8ca038a93a7f9dd34d5878e1bb1e5079b Mon Sep 17 00:00:00 2001 From: FaDeOkno Date: Wed, 21 Aug 2024 21:53:14 +0400 Subject: [PATCH 3/3] bonk --- .../ADT/Crawling/SharedCrawlingSystem.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs b/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs index c43eadfddda..daabf082645 100644 --- a/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs +++ b/Content.Shared/ADT/Crawling/SharedCrawlingSystem.cs @@ -8,6 +8,12 @@ using Robust.Shared.Player; using Content.Shared.Movement.Systems; using Content.Shared.Alert; +using Content.Shared.Climbing.Components; +using Content.Shared.Popups; +using Robust.Shared.Physics.Systems; +using Robust.Shared.Map.Components; +using Content.Shared.Climbing.Systems; +using Content.Shared.Climbing.Events; namespace Content.Shared.ADT.Crawling; @@ -18,6 +24,9 @@ public abstract class SharedCrawlingSystem : EntitySystem [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!; [Dependency] private readonly AlertsSystem _alerts = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly EntityLookupSystem _lookup = default!; + [Dependency] private readonly BonkSystem _bonk = default!; + public override void Initialize() { base.Initialize(); @@ -68,6 +77,15 @@ private void OnDoAfter(EntityUid uid, CrawlerComponent component, CrawlStandupDo { if (args.Cancelled) return; + + foreach (var item in _lookup.GetEntitiesInRange(Transform(uid).Coordinates, 0.25f)) + { + if (HasComp(item)) + { + _bonk.TryBonk(uid, item, source: uid); + return; + } + } _standing.Stand(uid); } private void OnStandUp(EntityUid uid, CrawlerComponent component, StandAttemptEvent args)