Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Spatison committed Oct 27, 2024
1 parent 63eef2d commit c501b8d
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Content.Shared/Projectiles/EmbeddableProjectileComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
13 changes: 12 additions & 1 deletion Content.Shared/Projectiles/SharedProjectileSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using System.Numerics;
using Content.Shared._White.Penetrated;
using Content.Shared._White.Projectile;
Expand All @@ -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;
Expand Down Expand Up @@ -37,7 +39,8 @@ public override void Initialize()
SubscribeLocalEvent<EmbeddableProjectileComponent, ProjectileHitEvent>(OnEmbedProjectileHit);
SubscribeLocalEvent<EmbeddableProjectileComponent, ThrowDoHitEvent>(OnEmbedThrowDoHit);
SubscribeLocalEvent<EmbeddableProjectileComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
SubscribeLocalEvent<EmbeddableProjectileComponent, ActivateInWorldEvent>(OnEmbedActivate, before: new[] {typeof(ActivatableUISystem)}); // WD EDI
SubscribeLocalEvent<EmbeddableProjectileComponent, ActivateInWorldEvent>(OnEmbedActivate, before: new[] {typeof(ActivatableUISystem)}); // WD EDIT
SubscribeLocalEvent<EmbeddableProjectileComponent, PreventCollideEvent>(OnPreventCollision); // WD EDIT
}

private void OnEmbedThrowDoHit(EntityUid uid, EmbeddableProjectileComponent component, ThrowDoHitEvent args)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions Content.Shared/Throwing/ThrownItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Objects/Fun/darts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- 0.10,-0.20
density: 20
mask:
- ThrownItem # WD EDIT
- ItemMask
restitution: 0.3
friction: 0.2
- type: Sprite
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Objects/Materials/shards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
bounds: "-0.2,-0.2,0.2,0.2"
density: 30
mask:
- ThrownItem # WD EDIT
- ItemMask
- type: DamageOtherOnHit
damage:
types:
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Objects/Misc/tiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
- -0.25,0.25
density: 20
mask:
- ThrownItem
- ItemMask
restitution: 0.3
friction: 0.2
# WD EDIT END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- 0.30,0.40
density: 20
mask:
- ThrownItem # WD EDIT
- ItemMask
restitution: 0.3
friction: 0.2
- type: Sharp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- type: EmbeddableProjectile
offset: 0.15,0.15
deleteOnRemove: true
preventCollide: true
- type: DespawnOnLandItem
- type: ThrowingItemModifier
- type: PointLight
Expand Down

0 comments on commit c501b8d

Please sign in to comment.