From c501b8d6b8e2d654b2e9bdd12d5cf72e31fc14bb Mon Sep 17 00:00:00 2001 From: Spatison <137375981+Spatison@users.noreply.github.com> Date: Sun, 27 Oct 2024 15:25:21 +0300 Subject: [PATCH] fix --- .../Projectiles/EmbeddableProjectileComponent.cs | 3 +++ .../Projectiles/SharedProjectileSystem.cs | 13 ++++++++++++- Content.Shared/Throwing/ThrownItemSystem.cs | 4 ---- Resources/Prototypes/Entities/Objects/Fun/darts.yml | 2 +- .../Entities/Objects/Materials/shards.yml | 2 +- .../Prototypes/Entities/Objects/Misc/tiles.yml | 2 +- .../Entities/Objects/Weapons/Melee/spear.yml | 2 +- .../_White/Entities/Objects/Weapons/Melee/spear.yml | 1 + 8 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Content.Shared/Projectiles/EmbeddableProjectileComponent.cs b/Content.Shared/Projectiles/EmbeddableProjectileComponent.cs index 4c9bdc5c89..65cade2ad0 100644 --- a/Content.Shared/Projectiles/EmbeddableProjectileComponent.cs +++ b/Content.Shared/Projectiles/EmbeddableProjectileComponent.cs @@ -51,5 +51,8 @@ public sealed partial class EmbeddableProjectileComponent : Component // WD EDIT START [DataField] public DamageSpecifier Damage = new(); + + [DataField] + public bool PreventCollide; // WD EDIT END } diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index c5f024b424..f8921d61b9 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -1,3 +1,4 @@ +using System.Linq; using System.Numerics; using Content.Shared._White.Penetrated; using Content.Shared._White.Projectile; @@ -6,6 +7,7 @@ using Content.Shared.DoAfter; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; +using Content.Shared.Physics; using Content.Shared.Throwing; using Content.Shared.UserInterface; using Robust.Shared.Audio.Systems; @@ -37,7 +39,8 @@ public override void Initialize() SubscribeLocalEvent(OnEmbedProjectileHit); SubscribeLocalEvent(OnEmbedThrowDoHit); SubscribeLocalEvent(OnAttemptPacifiedThrow); - SubscribeLocalEvent(OnEmbedActivate, before: new[] {typeof(ActivatableUISystem)}); // WD EDI + SubscribeLocalEvent(OnEmbedActivate, before: new[] {typeof(ActivatableUISystem)}); // WD EDIT + SubscribeLocalEvent(OnPreventCollision); // WD EDIT } private void OnEmbedThrowDoHit(EntityUid uid, EmbeddableProjectileComponent component, ThrowDoHitEvent args) @@ -135,6 +138,14 @@ private void OnEmbedActivate(EntityUid uid, EmbeddableProjectileComponent compon args.Handled = true; } + private void OnPreventCollision(EntityUid uid, EmbeddableProjectileComponent component, ref PreventCollideEvent args) + { + // Opaque collision mask doesn't work for EmbeddableProjectileComponent + if (component.PreventCollide && TryComp(args.OtherEntity, out FixturesComponent? fixtures) && + fixtures.Fixtures.All(fix => (fix.Value.CollisionLayer & (int) CollisionGroup.Opaque) == 0)) + args.Cancelled = true; + } + private bool AttemptEmbedRemove(EntityUid uid, EntityUid user, EmbeddableProjectileComponent? component = null) { if (!Resolve(uid, ref component, false) diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index 3748cbe30d..7615b8e86c 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -25,7 +25,6 @@ public sealed class ThrownItemSystem : EntitySystem [Dependency] private readonly SharedGravitySystem _gravity = default!; private const string ThrowingFixture = "throw-fixture"; - private const string Fixture1 = "fix1"; // WD EDIT public override void Initialize() { @@ -67,9 +66,6 @@ private void HandleCollision(EntityUid uid, ThrownItemComponent component, ref S return; // WD EDIT START - if (args.OurFixtureId != Fixture1) - return; - if (component.Processed.Contains(args.OtherEntity)) return; // WD EDIT END diff --git a/Resources/Prototypes/Entities/Objects/Fun/darts.yml b/Resources/Prototypes/Entities/Objects/Fun/darts.yml index fbda9c4a09..4c7ae68420 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/darts.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/darts.yml @@ -21,7 +21,7 @@ - 0.10,-0.20 density: 20 mask: - - ThrownItem # WD EDIT + - ItemMask restitution: 0.3 friction: 0.2 - type: Sprite diff --git a/Resources/Prototypes/Entities/Objects/Materials/shards.yml b/Resources/Prototypes/Entities/Objects/Materials/shards.yml index eae8f16d70..5e0b8890cc 100644 --- a/Resources/Prototypes/Entities/Objects/Materials/shards.yml +++ b/Resources/Prototypes/Entities/Objects/Materials/shards.yml @@ -41,7 +41,7 @@ bounds: "-0.2,-0.2,0.2,0.2" density: 30 mask: - - ThrownItem # WD EDIT + - ItemMask - type: DamageOtherOnHit damage: types: diff --git a/Resources/Prototypes/Entities/Objects/Misc/tiles.yml b/Resources/Prototypes/Entities/Objects/Misc/tiles.yml index 414d91410c..300633d5d5 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/tiles.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/tiles.yml @@ -54,7 +54,7 @@ - -0.25,0.25 density: 20 mask: - - ThrownItem + - ItemMask restitution: 0.3 friction: 0.2 # WD EDIT END diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/spear.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/spear.yml index c0af07cd61..776d165503 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/spear.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/spear.yml @@ -22,7 +22,7 @@ - 0.30,0.40 density: 20 mask: - - ThrownItem # WD EDIT + - ItemMask restitution: 0.3 friction: 0.2 - type: Sharp diff --git a/Resources/Prototypes/_White/Entities/Objects/Weapons/Melee/spear.yml b/Resources/Prototypes/_White/Entities/Objects/Weapons/Melee/spear.yml index 5c5c14b489..1cfc479ec6 100644 --- a/Resources/Prototypes/_White/Entities/Objects/Weapons/Melee/spear.yml +++ b/Resources/Prototypes/_White/Entities/Objects/Weapons/Melee/spear.yml @@ -35,6 +35,7 @@ - type: EmbeddableProjectile offset: 0.15,0.15 deleteOnRemove: true + preventCollide: true - type: DespawnOnLandItem - type: ThrowingItemModifier - type: PointLight