From 5dad05e0892da7fa8fbefde61b8fdb81b436e580 Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Sun, 25 Feb 2024 19:13:54 +0900 Subject: [PATCH] - tweak: Knife tweaks. (#122) --- .../_White/Other/BlinkSystem}/BlinkSystem.cs | 43 ++++++------------- .../_White/BetrayalDagger/BlinkComponent.cs | 15 +++++++ .../Objects/Weapons/Melee/daggers.yml | 16 +++++-- 3 files changed, 42 insertions(+), 32 deletions(-) rename {Content.Shared/_White/BetrayalDagger => Content.Server/_White/Other/BlinkSystem}/BlinkSystem.cs (53%) diff --git a/Content.Shared/_White/BetrayalDagger/BlinkSystem.cs b/Content.Server/_White/Other/BlinkSystem/BlinkSystem.cs similarity index 53% rename from Content.Shared/_White/BetrayalDagger/BlinkSystem.cs rename to Content.Server/_White/Other/BlinkSystem/BlinkSystem.cs index 6bcd682b19..7bf73c0f1d 100644 --- a/Content.Shared/_White/BetrayalDagger/BlinkSystem.cs +++ b/Content.Server/_White/Other/BlinkSystem/BlinkSystem.cs @@ -1,21 +1,20 @@ +using System.Linq; using System.Numerics; -using Content.Shared.Mobs.Components; +using Content.Shared._White.BetrayalDagger; using Content.Shared.Physics; -using Robust.Shared.Audio.Systems; +using Robust.Server.Audio; +using Robust.Server.GameObjects; using Robust.Shared.Physics; -using Robust.Shared.Physics.Systems; -using Robust.Shared.Serialization; using Robust.Shared.Timing; -using Robust.Shared.Utility; -namespace Content.Shared._White.BetrayalDagger; +namespace Content.Server._White.Other.BlinkSystem; public sealed class BlinkSystem : EntitySystem { [Dependency] private readonly IGameTiming _timing = default!; - [Dependency] private readonly SharedAudioSystem _audio = default!; - [Dependency] private readonly SharedTransformSystem _transform = default!; - [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly AudioSystem _audio = default!; + [Dependency] private readonly TransformSystem _transform = default!; + [Dependency] private readonly PhysicsSystem _physics = default!; public override void Initialize() { @@ -46,36 +45,22 @@ public sealed class BlinkSystem : EntitySystem var coords = _transform.GetWorldPosition(xform); var dir = msg.Direction.Normalized(); - var range = blink.Distance; + var range = MathF.Min(blink.Distance, msg.Direction.Length()); - var ray = new CollisionRay(coords, dir, (int) CollisionGroup.Opaque); - var rayResults = _physics.IntersectRayWithPredicate(xform.MapID, ray, range, - x => x == user || !HasComp(x)).FirstOrNull(); + var ray = new CollisionRay(coords, dir, (int) (CollisionGroup.Impassable | CollisionGroup.InteractImpassable)); + var rayResults = _physics.IntersectRayWithPredicate(xform.MapID, ray, range, x => x == user, false).ToList(); Vector2 targetPos; - if (rayResults != null) + if (rayResults.Count > 0) { - targetPos = rayResults.Value.HitPos - dir; + targetPos = rayResults.MinBy(x => (x.HitPos - coords).Length()).HitPos - dir; } else { - targetPos = coords + (msg.Direction.Length() > range ? dir * range : msg.Direction); + targetPos = coords + (msg.Direction.Length() > blink.Distance ? dir * blink.Distance : msg.Direction); } _transform.SetWorldPosition(user, targetPos); _audio.PlayPvs(blink.BlinkSound, user); } } - -[Serializable, NetSerializable] -public sealed class BlinkEvent : EntityEventArgs -{ - public readonly NetEntity Weapon; - public readonly Vector2 Direction; - - public BlinkEvent(NetEntity weapon, Vector2 direction) - { - Weapon = weapon; - Direction = direction; - } -} diff --git a/Content.Shared/_White/BetrayalDagger/BlinkComponent.cs b/Content.Shared/_White/BetrayalDagger/BlinkComponent.cs index faa2f8eb3f..64163d0284 100644 --- a/Content.Shared/_White/BetrayalDagger/BlinkComponent.cs +++ b/Content.Shared/_White/BetrayalDagger/BlinkComponent.cs @@ -1,4 +1,6 @@ +using System.Numerics; using Robust.Shared.Audio; +using Robust.Shared.Serialization; namespace Content.Shared._White.BetrayalDagger; @@ -19,3 +21,16 @@ public sealed partial class BlinkComponent : Component Params = AudioParams.Default.WithVolume(5f) }; } + +[Serializable, NetSerializable] +public sealed class BlinkEvent : EntityEventArgs +{ + public readonly NetEntity Weapon; + public readonly Vector2 Direction; + + public BlinkEvent(NetEntity weapon, Vector2 direction) + { + Weapon = weapon; + Direction = direction; + } +} diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/daggers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/daggers.yml index 639dcea520..1c5525e876 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/daggers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/daggers.yml @@ -31,7 +31,7 @@ - type: entity name: предательский нож description: Берегите спину. - parent: BaseItem + parent: BaseKnife id: BetrayalKnife components: - type: Sharp @@ -40,14 +40,24 @@ state: icon - type: MeleeWeapon wideAnimationRotation: 180 - attackRate: 1 + attackRate: 1.5 damage: types: - Slash: 30 + Slash: 17.5 soundHit: path: /Audio/Weapons/bladeslice.ogg + - type: EmbeddableProjectile + sound: /Audio/Weapons/star_hit.ogg + - type: ThrowingAngle + angle: 180 + - type: DamageOtherOnHit + damage: + types: + Slash: 20 - type: Item size: Small - type: DisarmMalus + malus: 0.225 - type: Backstab - type: Blink + blinkRate: 0.33