Simple Magic Spellbook System (#7823)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
keronshb
2022-05-29 02:29:10 -04:00
committed by GitHub
parent fb29fd5ecb
commit 11f729d024
52 changed files with 1120 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Physics;
/// <summary>
/// Use this to allow a specific UID to prevent collides
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed class PreventCollideComponent : Component
{
public EntityUid Uid;
}
[Serializable, NetSerializable]
public sealed class PreventCollideComponentState : ComponentState
{
public EntityUid Uid;
public PreventCollideComponentState(PreventCollideComponent component)
{
Uid = component.Uid;
}
}

View 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();
}
}

View File

@@ -3,13 +3,14 @@ using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
namespace Content.Shared.Sound
{
[ImplicitDataDefinitionForInheritors]
[ImplicitDataDefinitionForInheritors, Serializable, NetSerializable]
public abstract class SoundSpecifier
{
[ViewVariables(VVAccess.ReadWrite), DataField("params")]
@@ -19,6 +20,7 @@ namespace Content.Shared.Sound
public abstract string GetSound(IRobustRandom? rand = null, IPrototypeManager? proto = null);
}
[Serializable, NetSerializable]
public sealed class SoundPathSpecifier : SoundSpecifier
{
public const string Node = "path";
@@ -47,6 +49,7 @@ namespace Content.Shared.Sound
}
}
[Serializable, NetSerializable]
public sealed class SoundCollectionSpecifier : SoundSpecifier
{
public const string Node = "collection";