Simple Magic Spellbook System (#7823)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
38
Content.Shared/Physics/SharedPreventCollideSystem.cs
Normal file
38
Content.Shared/Physics/SharedPreventCollideSystem.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Content.Shared.Physics;
|
||||
|
||||
public sealed class SharedPreventCollideSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PreventCollideComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<PreventCollideComponent, ComponentHandleState>(OnHandleState);
|
||||
SubscribeLocalEvent<PreventCollideComponent, PreventCollideEvent>(OnPreventCollide);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, PreventCollideComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new PreventCollideComponentState(component);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, PreventCollideComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not PreventCollideComponentState state)
|
||||
return;
|
||||
|
||||
component.Uid = state.Uid;
|
||||
}
|
||||
|
||||
private void OnPreventCollide(EntityUid uid, PreventCollideComponent component, PreventCollideEvent args)
|
||||
{
|
||||
var otherUid = args.BodyB.Owner;
|
||||
|
||||
if (component.Uid == otherUid)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user