@@ -48,13 +48,13 @@ public sealed partial class EmbeddableProjectileComponent : Component
|
|||||||
public SoundSpecifier? Sound;
|
public SoundSpecifier? Sound;
|
||||||
|
|
||||||
// WD START
|
// WD START
|
||||||
[AutoNetworkedField]
|
[ViewVariables, AutoNetworkedField]
|
||||||
public bool PreventEmbedding;
|
public bool PreventEmbedding;
|
||||||
|
|
||||||
[AutoNetworkedField]
|
[ViewVariables, AutoNetworkedField]
|
||||||
public bool Penetrate;
|
public bool Penetrate;
|
||||||
|
|
||||||
[AutoNetworkedField]
|
[ViewVariables, AutoNetworkedField]
|
||||||
public EntityUid? PenetratedUid;
|
public EntityUid? PenetratedUid;
|
||||||
// WD END
|
// WD END
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
// WD EDIT START
|
// WD EDIT START
|
||||||
if (args.Handled || !TryComp<PhysicsComponent>(uid, out var physics) || physics.BodyType != BodyType.Static)
|
if (args.Handled || !TryComp<PhysicsComponent>(uid, out var physics) || physics.BodyType != BodyType.Static)
|
||||||
|
{
|
||||||
|
FreePenetrated(component);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
|
||||||
@@ -66,6 +69,10 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
|||||||
if (component.DeleteOnRemove)
|
if (component.DeleteOnRemove)
|
||||||
{
|
{
|
||||||
QueueDel(uid);
|
QueueDel(uid);
|
||||||
|
// WD START
|
||||||
|
FreePenetrated(component);
|
||||||
|
RaiseLocalEvent(uid, new EmbedRemovedEvent());
|
||||||
|
// WD END
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,12 +90,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WD START
|
// WD START
|
||||||
if (component.PenetratedUid != null)
|
FreePenetrated(component);
|
||||||
{
|
|
||||||
_penetratedSystem.FreePenetrated(component.PenetratedUid.Value);
|
|
||||||
component.PenetratedUid = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
RaiseLocalEvent(uid, new EmbedRemovedEvent());
|
RaiseLocalEvent(uid, new EmbedRemovedEvent());
|
||||||
// WD END
|
// WD END
|
||||||
|
|
||||||
@@ -121,6 +123,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
|||||||
_transform.SetLocalPosition(args.Target,
|
_transform.SetLocalPosition(args.Target,
|
||||||
xform.LocalPosition + Transform(uid).LocalRotation.RotateVec(new Vector2(0.5f, 0.5f)), xform);
|
xform.LocalPosition + Transform(uid).LocalRotation.RotateVec(new Vector2(0.5f, 0.5f)), xform);
|
||||||
Dirty(uid, component);
|
Dirty(uid, component);
|
||||||
|
Dirty(args.Target, penetrated);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,12 +210,14 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
|||||||
private void OnEntityTerminating(EntityUid uid, EmbeddableProjectileComponent component,
|
private void OnEntityTerminating(EntityUid uid, EmbeddableProjectileComponent component,
|
||||||
ref EntityTerminatingEvent args)
|
ref EntityTerminatingEvent args)
|
||||||
{
|
{
|
||||||
FreePenetrated(component);
|
if (!_netManager.IsClient)
|
||||||
|
FreePenetrated(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRemove(EntityUid uid, EmbeddableProjectileComponent component, ComponentRemove args)
|
private void OnRemove(EntityUid uid, EmbeddableProjectileComponent component, ComponentRemove args)
|
||||||
{
|
{
|
||||||
FreePenetrated(component);
|
if (!_netManager.IsClient)
|
||||||
|
FreePenetrated(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FreePenetrated(EmbeddableProjectileComponent component)
|
private void FreePenetrated(EmbeddableProjectileComponent component)
|
||||||
@@ -223,7 +228,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
|||||||
_penetratedSystem.FreePenetrated(component.PenetratedUid.Value);
|
_penetratedSystem.FreePenetrated(component.PenetratedUid.Value);
|
||||||
component.PenetratedUid = null;
|
component.PenetratedUid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLand(EntityUid uid, EmbeddableProjectileComponent component, ref LandEvent args)
|
private void OnLand(EntityUid uid, EmbeddableProjectileComponent component, ref LandEvent args)
|
||||||
{
|
{
|
||||||
if (component.PenetratedUid == null)
|
if (component.PenetratedUid == null)
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.White.Crossbow;
|
namespace Content.Shared.White.Crossbow;
|
||||||
|
|
||||||
[RegisterComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class PenetratedComponent : Component
|
public sealed partial class PenetratedComponent : Component
|
||||||
{
|
{
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||||
public EntityUid? ProjectileUid;
|
public EntityUid? ProjectileUid;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||||
public bool IsPinned;
|
public bool IsPinned;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,19 +23,27 @@ public sealed class PenetratedSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
if (component is {ProjectileUid: not null, IsPinned: true})
|
if (component is {ProjectileUid: not null, IsPinned: true})
|
||||||
_projectile.AttemptEmbedRemove(component.ProjectileUid.Value, uid);
|
_projectile.AttemptEmbedRemove(component.ProjectileUid.Value, uid);
|
||||||
|
else if (component.ProjectileUid == null && TryComp(uid, out PhysicsComponent? physics) &&
|
||||||
|
physics.BodyType == BodyType.Static)
|
||||||
|
FreePenetrated(uid, component, physics);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FreePenetrated(EntityUid uid, PenetratedComponent? penetrated = null)
|
public void FreePenetrated(EntityUid uid, PenetratedComponent? penetrated = null, PhysicsComponent? physics = null)
|
||||||
{
|
{
|
||||||
|
var xform = Transform(uid);
|
||||||
|
_transform.AttachToGridOrMap(uid, xform);
|
||||||
|
|
||||||
|
if (Resolve(uid, ref physics, false))
|
||||||
|
{
|
||||||
|
_physics.SetBodyType(uid, BodyType.KinematicController, body: physics, xform: xform);
|
||||||
|
_physics.WakeBody(uid, body: physics);
|
||||||
|
}
|
||||||
|
|
||||||
if (!Resolve(uid, ref penetrated, false))
|
if (!Resolve(uid, ref penetrated, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var xform = Transform(uid);
|
|
||||||
TryComp<PhysicsComponent>(uid, out var physics);
|
|
||||||
_physics.SetBodyType(uid, BodyType.Dynamic, body: physics, xform: xform);
|
|
||||||
_transform.AttachToGridOrMap(uid, xform);
|
|
||||||
penetrated.ProjectileUid = null;
|
penetrated.ProjectileUid = null;
|
||||||
penetrated.IsPinned = false;
|
penetrated.IsPinned = false;
|
||||||
_physics.WakeBody(uid, body: physics);
|
Dirty(uid, penetrated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user