Compare commits
1 Commits
ed-31-08-2
...
ed-12-08-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dc363ee4b |
10
Content.Shared/_CP14/MagicRitual/CP14RitualCondition.cs
Normal file
10
Content.Shared/_CP14/MagicRitual/CP14RitualCondition.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Shared._CP14.MagicRitual;
|
||||
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
[MeansImplicitUse]
|
||||
public abstract partial class CP14RitualCondition
|
||||
{
|
||||
public abstract void Check(IEntityManager entManager, EntityUid ritual);
|
||||
}
|
||||
11
Content.Shared/_CP14/MagicRitual/CP14RitualEffect.cs
Normal file
11
Content.Shared/_CP14/MagicRitual/CP14RitualEffect.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._CP14.MagicRitual;
|
||||
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
[MeansImplicitUse]
|
||||
public abstract partial class CP14RitualEffect
|
||||
{
|
||||
public abstract void Effect(IEntityManager entMan, IPrototypeManager protoMan, EntityUid ritual);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._CP14.MagicRitual.Components;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class CP14RitualNodeComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public List<CP14RitualEdge> Edges = new();
|
||||
}
|
||||
|
||||
|
||||
[DataDefinition]
|
||||
public sealed partial class CP14RitualEdge
|
||||
{
|
||||
[DataField(required: true)]
|
||||
public EntProtoId TargetNode = default!;
|
||||
|
||||
[DataField]
|
||||
public List<CP14RitualCondition> Conditions = new();
|
||||
}
|
||||
29
Content.Shared/_CP14/MagicRitual/Effects/ChangeNode.cs
Normal file
29
Content.Shared/_CP14/MagicRitual/Effects/ChangeNode.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared._CP14.MagicRitual.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Shared._CP14.MagicRitual.Effects;
|
||||
|
||||
public sealed partial class ChangeNode : CP14RitualEffect
|
||||
{
|
||||
[DataField(required: true)]
|
||||
public EntProtoId Proto = default!;
|
||||
|
||||
public override void Effect(IEntityManager entMan, IPrototypeManager protoMan, EntityUid ritual)
|
||||
{
|
||||
if (!protoMan.TryIndex(Proto, out var indexedProto))
|
||||
return;
|
||||
|
||||
var compFactory = IoCManager.Resolve<IComponentFactory>();
|
||||
if (!indexedProto.TryGetComponent<CP14RitualNodeComponent>(out var targetNode, compFactory))
|
||||
{
|
||||
Logger.Error($"Ritual node {indexedProto.ID} does not have a CP14RitualNodeComponent, cannot change node.");
|
||||
return;
|
||||
}
|
||||
|
||||
var origin = entMan.GetComponent<TransformComponent>(ritual).Coordinates;
|
||||
entMan.SpawnAtPosition(Proto, origin);
|
||||
entMan.QueueDeleteEntity(ritual);
|
||||
}
|
||||
}
|
||||
29
Content.Shared/_CP14/MagicRitual/Effects/SpawnEntity.cs
Normal file
29
Content.Shared/_CP14/MagicRitual/Effects/SpawnEntity.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Shared._CP14.MagicRitual.Effects;
|
||||
|
||||
public sealed partial class SpawnEntity : CP14RitualEffect
|
||||
{
|
||||
[DataField(required: true)]
|
||||
public EntProtoId Proto = default!;
|
||||
|
||||
[DataField]
|
||||
public int Count = 1;
|
||||
|
||||
[DataField]
|
||||
public float Offset = 1f;
|
||||
|
||||
public override void Effect(IEntityManager entMan, IPrototypeManager protoMan, EntityUid ritual)
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var origin = entMan.GetComponent<TransformComponent>(ritual).Coordinates;
|
||||
|
||||
for (var i = 0; i < Count; i++)
|
||||
{
|
||||
var spawnPosition = origin.Offset(new Vector2(random.NextFloat(-Offset, Offset), random.NextFloat(-Offset, Offset)));
|
||||
var ent = entMan.SpawnAtPosition(Proto, spawnPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._CP14.MagicRitual.Prototypes;
|
||||
|
||||
[Prototype("ritualGraph")]
|
||||
public sealed partial class CP14RitualGraphPrototype : IPrototype
|
||||
{
|
||||
[IdDataField]
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
[DataField(required: true)]
|
||||
public LocId Name = string.Empty;
|
||||
}
|
||||
Reference in New Issue
Block a user