Torches + Cotton (#1246)

* torches add, wallmount crystals deletion

* cotton

* Update buy.yml

* craftis

* delete elemental quartz

* energy crystal resprite and rewamp

* fix

* Update misc.yml

* а

* delete rituals

* riat

* Update migration.yml

* Delete CP14ClientRitualSystem.cs

* Update statues.yml

* fix

* Update wallmount_lamp.yml

* fix
This commit is contained in:
Ed
2025-04-30 17:28:38 +03:00
committed by GitHub
parent ad2fc18356
commit 2358bc46d6
127 changed files with 520 additions and 2831 deletions

View File

@@ -1,44 +0,0 @@
using System.Text;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Actions;
/// <summary>
/// Adds a key-orb to the ritual.
/// </summary>
public sealed partial class AddOrb : CP14RitualAction
{
[DataField(required: true)]
public Dictionary<EntProtoId, int> Orbs = new();
public override string? GetGuidebookEffectDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
var sb = new StringBuilder();
sb.Append(Loc.GetString("cp14-ritual-effect-add-orb")+ "\n");
foreach (var orb in Orbs)
{
if (!prototype.TryIndex(orb.Key, out var indexedOrb))
continue;
sb.Append(Loc.GetString("cp14-ritual-entry-item", ("name", indexedOrb.Name), ("count", orb.Value)) + "\n");
}
return sb.ToString();
}
public override void Effect(EntityManager entManager, SharedTransformSystem transform, Entity<CP14MagicRitualPhaseComponent> phase)
{
if (phase.Comp.Ritual is null)
return;
var ritual = entManager.System<CP14SharedRitualSystem>();
foreach (var orb in Orbs)
{
for (var i = 0; i < orb.Value; i++)
{
ritual.AddOrbToRitual(phase.Comp.Ritual.Value, orb.Key);
}
}
}
}

View File

@@ -1,75 +0,0 @@
using System.Text;
using Content.Shared.EntityEffects;
using Content.Shared.Whitelist;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Actions;
/// <summary>
/// Filters the nearest X entities by whitelist and applies the specified EntityEffects on them
/// </summary>
public sealed partial class ApplyEntityEffect : CP14RitualAction
{
[DataField]
public float CheckRange = 1f;
[DataField]
public EntityWhitelist? Whitelist;
[DataField]
public LocId? WhitelistDesc;
[DataField(required: true, serverOnly: true)]
public List<EntityEffect> Effects = new();
[DataField]
public int MaxEntities = 1;
public override string? GetGuidebookEffectDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
var sb = new StringBuilder();
sb.Append(Loc.GetString("cp14-ritual-range", ("range", CheckRange)) + "\n");
sb.Append(Loc.GetString("cp14-ritual-effect-apply-effect", ("count", MaxEntities), ("range", CheckRange)) + "\n");
if (WhitelistDesc is not null)
{
sb.Append(Loc.GetString(WhitelistDesc));
sb.Append("\n");
}
foreach (var effect in Effects)
{
sb.Append("- " + effect.GuidebookEffectDescription(prototype, entSys) + "\n");
}
sb.Append("\n");
return sb.ToString();
}
public override void Effect(EntityManager entManager, SharedTransformSystem transform, Entity<CP14MagicRitualPhaseComponent> phase)
{
var lookup = entManager.System<EntityLookupSystem>();
var whitelist = entManager.System<EntityWhitelistSystem>();
var entitiesAround = lookup.GetEntitiesInRange(phase, CheckRange, LookupFlags.Uncontained);
var count = 0;
foreach (var entity in entitiesAround)
{
if (Whitelist is not null && !whitelist.IsValid(Whitelist, entity))
continue;
foreach (var effect in Effects)
{
effect.Effect(new EntityEffectBaseArgs(entity, entManager));
}
entManager.Spawn(VisualEffect, transform.GetMapCoordinates(entity));
count++;
if (count >= MaxEntities)
break;
}
}
}

View File

@@ -1,19 +0,0 @@
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Actions;
[ImplicitDataDefinitionForInheritors]
[MeansImplicitUse]
public abstract partial class CP14RitualAction
{
/// <summary>
/// Effect appearing in place of interacted entities
/// </summary>
[DataField("vfx")]
public EntProtoId? VisualEffect = "CP14DustEffect";
public abstract void Effect(EntityManager entManager, SharedTransformSystem transform, Entity<CP14MagicRitualPhaseComponent> phase);
public abstract string? GetGuidebookEffectDescription(IPrototypeManager prototype, IEntitySystemManager entSys);
}

View File

@@ -1,41 +0,0 @@
using System.Text;
using Content.Shared._CP14.MagicRitual.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Actions;
/// <summary>
/// Removes the orb key from the ritual.
/// </summary>
public sealed partial class ConsumeOrb : CP14RitualAction
{
[DataField(required: true)]
public ProtoId<CP14MagicTypePrototype> MagicType = new();
[DataField(required: true)]
public int Count = 0;
public override string? GetGuidebookEffectDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
if (!prototype.TryIndex(MagicType, out var indexedType))
return null;
var sb = new StringBuilder();
sb.Append(Loc.GetString("cp14-ritual-effect-consume-orb", ("name", Loc.GetString(indexedType.Name)), ("count", Count))+ "\n");
return sb.ToString();
}
public override void Effect(EntityManager entManager, SharedTransformSystem transform, Entity<CP14MagicRitualPhaseComponent> phase)
{
if (phase.Comp.Ritual is null)
return;
var ritual = entManager.System<CP14SharedRitualSystem>();
for (var i = 0; i < Count; i++)
{
ritual.ConsumeOrbType(phase.Comp.Ritual.Value, MagicType);
}
}
}

View File

@@ -1,104 +0,0 @@
using System.Text;
using Content.Shared.Stacks;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Actions;
public sealed partial class ConsumeResource : CP14RitualAction
{
[DataField]
public float CheckRange = 1f;
[DataField]
public Dictionary<EntProtoId, int> RequiredEntities = new ();
[DataField]
public Dictionary<ProtoId<StackPrototype>, int> RequiredStacks = new();
public override string? GetGuidebookEffectDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
var sb = new StringBuilder();
sb.Append(Loc.GetString("cp14-ritual-effect-consume-resource", ("range", CheckRange)) + "\n");
foreach (var entity in RequiredEntities)
{
if (!prototype.TryIndex(entity.Key, out var indexed))
continue;
sb.Append(Loc.GetString("cp14-ritual-entry-item", ("name", indexed.Name), ("count", entity.Value)) + "\n");
}
foreach (var stack in RequiredStacks)
{
if (!prototype.TryIndex(stack.Key, out var indexed))
continue;
sb.Append(Loc.GetString("cp14-ritual-entry-item", ("name", Loc.GetString(indexed.Name)), ("count", stack.Value)) + "\n");
}
return sb.ToString();
}
public override void Effect(EntityManager entManager, SharedTransformSystem transform, Entity<CP14MagicRitualPhaseComponent> phase)
{
var lookup = entManager.System<EntityLookupSystem>();
var stack = entManager.System<SharedStackSystem>();
var entitiesAround = lookup.GetEntitiesInRange(phase, CheckRange, LookupFlags.Uncontained);
foreach (var reqEnt in RequiredEntities)
{
var requiredCount = reqEnt.Value;
foreach (var entity in entitiesAround)
{
if (!entManager.TryGetComponent<MetaDataComponent>(entity, out var metaData))
continue;
if (!entManager.HasComponent<TransformComponent>(entity))
continue;
var entProto = metaData.EntityPrototype;
if (entProto is null)
continue;
if (entProto.ID == reqEnt.Key && requiredCount > 0)
{
if (VisualEffect is not null)
entManager.Spawn(VisualEffect.Value, transform.GetMapCoordinates(entity));
entManager.DeleteEntity(entity);
requiredCount--;
}
}
}
foreach (var reqStack in RequiredStacks)
{
var requiredCount = reqStack.Value;
foreach (var entity in entitiesAround)
{
if (!entManager.TryGetComponent<StackComponent>(entity, out var stackComp))
continue;
if (stackComp.StackTypeId != reqStack.Key)
continue;
var count = (int)MathF.Min(requiredCount, stackComp.Count);
if (stackComp.Count - count <= 0)
entManager.DeleteEntity(entity);
else
stack.SetCount(entity, stackComp.Count - count, stackComp);
requiredCount -= count;
if (VisualEffect is not null)
entManager.Spawn(VisualEffect.Value, transform.GetMapCoordinates(entity));
}
}
}
}

View File

@@ -1,27 +0,0 @@
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Actions;
public sealed partial class EditStability : CP14RitualAction
{
[DataField(required: true)]
public float Mod;
public override void Effect(EntityManager entManager, SharedTransformSystem transform, Entity<CP14MagicRitualPhaseComponent> phase)
{
var ritual = entManager.System<CP14SharedRitualSystem>();
if (phase.Comp.Ritual is not null)
ritual.ChangeRitualStability(phase.Comp.Ritual.Value, Mod);
}
public override string? GetGuidebookEffectDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
return Mod switch
{
> 0 => Loc.GetString("cp14-ritual-effect-stability-add", ("count", Mod * 100)) + "\n",
< 0 => Loc.GetString("cp14-ritual-effect-stability-minus", ("count", -Mod * 100)) + "\n",
_ => null,
};
}
}

View File

@@ -1,44 +0,0 @@
using System.Text;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Actions;
/// <summary>
/// Creates an entity in the coordinates of the ritual.
/// </summary> TODO: EntityTable support?
public sealed partial class SpawnEntity : CP14RitualAction
{
[DataField(required: true)]
public Dictionary<EntProtoId, int> Spawns = new();
[DataField]
public LocId? Name;
public override string? GetGuidebookEffectDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
var sb = new StringBuilder();
sb.Append(Loc.GetString("cp14-ritual-effect-spawn-entity")+ "\n");
foreach (var spawn in Spawns)
{
if (!prototype.TryIndex(spawn.Key, out var indexed))
return null;
sb.Append(Loc.GetString("cp14-ritual-entry-item",
("name", Name is null ? indexed.Name : Loc.GetString(Name)),
("count", spawn.Value)) + "\n");
}
return sb.ToString();
}
public override void Effect(EntityManager entManager, SharedTransformSystem transform, Entity<CP14MagicRitualPhaseComponent> phase)
{
foreach (var spawn in Spawns)
{
for (var i = 0; i < spawn.Value; i++)
{
entManager.Spawn(spawn.Key, transform.GetMapCoordinates(phase));
}
}
}
}

View File

@@ -1,37 +0,0 @@
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual;
/// <summary>
/// Ritual Behavior Controller. Creates and removes entities of magical phases
/// </summary>
[RegisterComponent, Access(typeof(CP14SharedRitualSystem))]
public sealed partial class CP14MagicRitualComponent : Component
{
[DataField(required: true)]
public EntProtoId StartPhase;
[DataField]
public EntityUid? CurrentPhase;
[DataField]
public float Stability = 1f;
[DataField]
public float ActivationTime = 5f;
[DataField]
public string RitualLayerMap = "ritual";
[DataField]
public int MaxOrbCapacity = 3;
[DataField]
public float RitualRadius = 5;
[DataField]
public TimeSpan TriggerTime = TimeSpan.Zero;
[DataField]
public List<EntityUid> Orbs = new();
}

View File

@@ -1,86 +0,0 @@
using Content.Shared.DoAfter;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared._CP14.MagicRitual;
/// <summary>
/// Called out a ritual when any of its phase triggers are activated
/// </summary>
public sealed class CP14RitualTriggerEvent : EntityEventArgs
{
public EntProtoId NextPhase;
public CP14RitualTriggerEvent(EntProtoId phase)
{
NextPhase = phase;
}
}
/// <summary>
/// Called out at a ritual when his stability is altered
/// </summary>
public sealed class CP14RitualStabilityChangedEvent : EntityEventArgs
{
public float OldStability;
public float NewStability;
public CP14RitualStabilityChangedEvent(float oldS, float newS)
{
OldStability = oldS;
NewStability = newS;
}
}
/// <summary>
/// Called on both the ritual and the phase when they link together
/// </summary>
public sealed class CP14RitualPhaseBoundEvent : EntityEventArgs
{
public EntityUid Ritual;
public EntityUid Phase;
public CP14RitualPhaseBoundEvent(EntityUid r, EntityUid p)
{
Ritual = r;
Phase = p;
}
}
/// <summary>
/// Invoked at the ritual holder entity when the ritual is complete and the phase entities have been removed
/// </summary>
public sealed class CP14RitualEndEvent : EntityEventArgs
{
public EntityUid Ritual;
public CP14RitualEndEvent(EntityUid r)
{
Ritual = r;
}
}
/// <summary>
/// Invoked at the ritual holder entity when the ritual begins, and invokes the starting phase
/// </summary>
public sealed class CP14RitualStartEvent : EntityEventArgs
{
public EntityUid Ritual;
public CP14RitualStartEvent(EntityUid r)
{
Ritual = r;
}
}
[Serializable, NetSerializable]
public sealed partial class CP14ActivateRitualDoAfter : SimpleDoAfterEvent
{
}
[Serializable, NetSerializable]
public enum RitualVisuals
{
Color,
Enabled,
}

View File

@@ -1,14 +0,0 @@
using Content.Shared._CP14.MagicRitual.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual;
/// <summary>
/// “Key” in the concept of rituals. An entity that can be a key to a ritual, and holds certain characteristics that can be spent, or by which a phase transition requirement check can be made.
/// </summary>
[RegisterComponent, Access(typeof(CP14SharedRitualSystem))]
public sealed partial class CP14MagicRitualOrbComponent : Component
{
[DataField]
public Dictionary<ProtoId<CP14MagicTypePrototype>, int> Powers = new();
}

View File

@@ -1,41 +0,0 @@
using Content.Shared._CP14.MagicRitual.Actions;
using Content.Shared._CP14.MagicRitual.Requirements;
using Content.Shared._CP14.MagicRitualTrigger;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual;
/// <summary>
/// Magical entity that reacts to world events
/// </summary>
[RegisterComponent, Access(typeof(CP14SharedRitualSystem))]
public sealed partial class CP14MagicRitualPhaseComponent : Component
{
/// <summary>
/// A link to the ritual itself in which this phase is found
/// </summary>
[DataField]
public EntityUid? Ritual;
[DataField]
public Color PhaseColor = Color.White;
[DataField]
public List<RitualPhaseEdge> Edges = new();
/// <summary>
/// by moving to this node, the ritual will end instantly.
/// </summary>
[DataField]
public bool DeadEnd = false;
}
[DataRecord]
public partial record struct RitualPhaseEdge()
{
public EntProtoId Target { get; set; }
public List<CP14RitualTrigger> Triggers { get; set; } = new();
public List<CP14RitualRequirement> Requirements { get; set; } = new();
public List<CP14RitualAction> Actions { get; set; } = new();
}

View File

@@ -1,70 +0,0 @@
using Content.Shared._CP14.MagicRitual.Prototypes;
using Content.Shared.Follower;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual;
public partial class CP14SharedRitualSystem : EntitySystem
{
[Dependency] private readonly FollowerSystem _followerSystem = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly INetManager _net = default!;
public void ChangeRitualStability(EntityUid uid, float dStab, CP14MagicRitualComponent? ritual = null)
{
//if (!Resolve(uid, ref ritual))
// return;
//
//var newS = MathHelper.Clamp01(ritual.Stability + dStab);
//
//var ev = new CP14RitualStabilityChangedEvent(ritual.Stability, newS);
//RaiseLocalEvent(uid, ev);
//
//ritual.Stability = newS;
}
public void AddOrbToRitual(EntityUid uid, EntProtoId orb, CP14MagicRitualComponent? ritual = null)
{
//if (_net.IsClient)
// return;
//
//if (!Resolve(uid, ref ritual))
// return;
//
//if (!_proto.TryIndex(orb, out var indexedOrb))
// return;
//
//if (ritual.Orbs.Count >= ritual.MaxOrbCapacity)
// return;
//
//var spawnedOrb = Spawn(orb, _transform.GetMapCoordinates(uid));
//
//if (!TryComp<CP14MagicRitualOrbComponent>(spawnedOrb, out var orbComp))
//{
// QueueDel(spawnedOrb);
// return;
//}
//
//_followerSystem.StartFollowingEntity(spawnedOrb, uid);
//ritual.Orbs.Add((spawnedOrb, orbComp));
}
public void ConsumeOrbType(EntityUid uid, ProtoId<CP14MagicTypePrototype> magicType, CP14MagicRitualComponent? ritual = null)
{
//if (!Resolve(uid, ref ritual))
// return;
//
//foreach (var orb in ritual.Orbs)
//{
// var powers = orb.Comp.Powers;
// if (!powers.ContainsKey(magicType))
// continue;
//
// ritual.Orbs.Remove(orb);
// QueueDel(orb);
// return;
//}
}
}

View File

@@ -1,19 +0,0 @@
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Requirements;
[ImplicitDataDefinitionForInheritors]
[MeansImplicitUse]
public abstract partial class CP14RitualRequirement
{
/// <summary>
/// If this checks fails, the ritual will lose some of its stability.
/// </summary>
[DataField]
public float FailStabilityCost;
public abstract bool Check(EntityManager entManager, Entity<CP14MagicRitualPhaseComponent> phaseEnt, float stability);
public abstract string? GetGuidebookRequirementDescription(IPrototypeManager prototype, IEntitySystemManager entSys);
}

View File

@@ -1,66 +0,0 @@
using System.Text;
using Content.Shared._CP14.MagicRitual.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Requirements;
/// <summary>
/// Requires specific daytime period
/// </summary>
public sealed partial class RequiredOrbs : CP14RitualRequirement
{
[DataField]
public ProtoId<CP14MagicTypePrototype> MagicType = new();
[DataField]
public int? Min;
[DataField]
public int? Max;
public override string? GetGuidebookRequirementDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
var sb = new StringBuilder();
if (!prototype.TryIndex(MagicType, out var indexedType))
return null;
sb.Append(Loc.GetString("cp14-ritual-required-orbs", ("name", Loc.GetString(indexedType.Name))) + " ");
if (Min is not null && Max is not null)
sb.Append(Loc.GetString("cp14-ritual-required-orbs-item-minmax", ("min", Min), ("max", Max))+ "\n");
else if (Min is not null)
sb.Append(Loc.GetString("cp14-ritual-required-orbs-item-min", ("min", Min))+ "\n");
else if (Max is not null)
sb.Append(Loc.GetString("cp14-ritual-required-orbs-item-min", ("max", Max))+ "\n");
return sb.ToString();
}
public override bool Check(EntityManager entManager, Entity<CP14MagicRitualPhaseComponent> phaseEnt, float stability)
{
//if (phaseEnt.Comp.Ritual is null)
// return false;
//
//if (!entManager.TryGetComponent<CP14MagicRitualComponent>(phaseEnt, out var ritualComp))
// return false;
//
//var count = 0;
//foreach (var orb in ritualComp.Orbs)
//{
// foreach (var power in orb.Comp.Powers)
// {
// if (power.Key == MagicType)
// count += power.Value;
// }
//}
//
//if (Min is not null && Max is not null)
// return count >= Min && count <= Max;
//if (Min is not null)
// return count >= Min;
//if (Max is not null)
// return count <= Max;
//
return false;
}
}

View File

@@ -1,113 +0,0 @@
using System.Text;
using Content.Shared.Stacks;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Requirements;
/// <summary>
/// Requires certain specific entities to be near the ritual. TODO: Replace with Whitelist
/// </summary>
public sealed partial class RequiredResource : CP14RitualRequirement
{
[DataField]
public float CheckRange = 3f;
[DataField]
public Dictionary<EntProtoId, int> RequiredEntities = new ();
[DataField]
public Dictionary<ProtoId<StackPrototype>, int> RequiredStacks = new();
/// <summary>
/// Effect appearing in place of used entities
/// </summary>
[DataField("vfx")]
public EntProtoId? Effect = "CP14DustEffect";
public override string? GetGuidebookRequirementDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
var sb = new StringBuilder();
sb.Append(Loc.GetString("cp14-ritual-required-resource", ("range", CheckRange)) + "\n");
foreach (var entity in RequiredEntities)
{
if (!prototype.TryIndex(entity.Key, out var indexed))
continue;
sb.Append(Loc.GetString("cp14-ritual-entry-item", ("name", indexed.Name), ("count", entity.Value)) + "\n");
}
foreach (var stack in RequiredStacks)
{
if (!prototype.TryIndex(stack.Key, out var indexed))
continue;
sb.Append(Loc.GetString("cp14-ritual-entry-item", ("name", Loc.GetString(indexed.Name)), ("count", stack.Value)) + "\n");
}
return sb.ToString();
}
public override bool Check(EntityManager entManager, Entity<CP14MagicRitualPhaseComponent> phaseEnt, float stability)
{
var _lookup = entManager.System<EntityLookupSystem>();
var _transform = entManager.System<SharedTransformSystem>();
var entitiesAround = _lookup.GetEntitiesInRange(phaseEnt, CheckRange, LookupFlags.Uncontained);
var passed = true;
foreach (var reqEnt in RequiredEntities)
{
var requiredCount = reqEnt.Value;
foreach (var entity in entitiesAround)
{
if (!entManager.TryGetComponent<MetaDataComponent>(entity, out var metaData))
continue;
if (!entManager.TryGetComponent<TransformComponent>(entity, out var xform))
continue;
var entProto = metaData.EntityPrototype;
if (entProto is null)
continue;
if (entProto.ID == reqEnt.Key && requiredCount > 0)
{
if (Effect is not null)
entManager.Spawn(Effect.Value, _transform.GetMapCoordinates(entity));
requiredCount--;
}
}
if (requiredCount > 0)
passed = false;
}
foreach (var reqStack in RequiredStacks)
{
var requiredCount = reqStack.Value;
foreach (var entity in entitiesAround)
{
if (!entManager.TryGetComponent<StackComponent>(entity, out var stack))
continue;
if (stack.StackTypeId != reqStack.Key)
continue;
var count = (int)MathF.Min(requiredCount, stack.Count);
requiredCount -= count;
if (Effect is not null)
entManager.Spawn(Effect.Value, _transform.GetMapCoordinates(entity));
}
if (requiredCount > 0)
passed = false;
}
return passed;
}
}

View File

@@ -1,37 +0,0 @@
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitual.Requirements;
/// <summary>
/// Requires that the stability of the ritual be within specified limits. If the stability is above or below the specified values, the check will fail
/// </summary>
public sealed partial class RequiredStability : CP14RitualRequirement
{
[DataField]
public float Min = 0;
[DataField]
public float Max = 1;
public override string? GetGuidebookRequirementDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
return Min switch
{
> 0 when Max < 1 =>
Loc.GetString("cp14-ritual-required-stability-minmax", ("min", Min*100), ("max", Max*100)),
> 0 => Loc.GetString("cp14-ritual-required-stability-min", ("min", Min*100)),
< 0 => Loc.GetString("cp14-ritual-required-stability-max", ("min", Max*100)),
_ => null,
};
}
public override bool Check(EntityManager entManager, Entity<CP14MagicRitualPhaseComponent> phaseEnt, float stability)
{
if (phaseEnt.Comp.Ritual is null)
return false;
if (!entManager.TryGetComponent<CP14MagicRitualComponent>(phaseEnt, out var ritualComp))
return false;
return !(ritualComp.Stability < Min) && !(ritualComp.Stability > Max);
}
}

View File

@@ -1,17 +0,0 @@
using Content.Shared._CP14.MagicRitual;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitualTrigger;
[ImplicitDataDefinitionForInheritors]
[MeansImplicitUse]
public abstract partial class CP14RitualTrigger
{
[DataField]
public RitualPhaseEdge? Edge = null;
public abstract void Initialize(EntityManager entManager, Entity<CP14MagicRitualPhaseComponent> ritual, RitualPhaseEdge edge);
public abstract string? GetGuidebookTriggerDescription(IPrototypeManager prototype, IEntitySystemManager entSys);
}

View File

@@ -1,5 +0,0 @@
namespace Content.Shared._CP14.MagicRitualTrigger;
public partial class CP14SharedRitualTriggerSystem : EntitySystem
{
}

View File

@@ -1,34 +0,0 @@
using Content.Shared._CP14.MagicRitual;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitualTrigger.Triggers;
/// <summary>
/// triggers when a creature of a certain race dies within range of the ritual.
/// </summary>
public sealed partial class CP14SacrificeSpeciesTrigger : CP14RitualTrigger
{
[DataField]
public float Range = 3f;
[DataField(required: true)]
public ProtoId<SpeciesPrototype> Species = default!;
public override void Initialize(EntityManager entManager, Entity<CP14MagicRitualPhaseComponent> ritual, RitualPhaseEdge edge)
{
entManager.EnsureComponent<CP14RitualSacrificeSpeciesTriggerComponent>(ritual, out var trigger);
trigger.Triggers.Add(this);
Edge = edge;
}
public override string? GetGuidebookTriggerDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
if (!prototype.TryIndex(Species, out var indexedSpecies))
return null;
return Loc.GetString("cp14-ritual-trigger-sacrifice",
("name", Loc.GetString(indexedSpecies.Name)),
("range", Range));
}
}

View File

@@ -1,8 +0,0 @@
namespace Content.Shared._CP14.MagicRitualTrigger.Triggers;
[RegisterComponent]
public sealed partial class CP14RitualSacrificeSpeciesTriggerComponent : Component
{
[DataField]
public HashSet<CP14SacrificeSpeciesTrigger> Triggers = new();
}

View File

@@ -1,34 +0,0 @@
using Content.Shared._CP14.MagicRitual;
using Content.Shared.Whitelist;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitualTrigger.Triggers;
/// <summary>
/// Triggers when a creature passing the whitelist dies within range of the ritual.
/// </summary>
public sealed partial class CP14SacrificeWhitelistTrigger : CP14RitualTrigger
{
[DataField]
public float Range = 3f;
[DataField(required: true)]
public EntityWhitelist Whitelist = default!;
[DataField(required: true)]
public LocId WhitelistDesc = default!;
public override void Initialize(EntityManager entManager, Entity<CP14MagicRitualPhaseComponent> ritual, RitualPhaseEdge edge)
{
entManager.EnsureComponent<CP14RitualSacrificeWhitelistTriggerComponent>(ritual, out var trigger);
trigger.Triggers.Add(this);
Edge = edge;
}
public override string? GetGuidebookTriggerDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
return Loc.GetString("cp14-ritual-trigger-sacrifice",
("name", Loc.GetString(WhitelistDesc)),
("range", Range));
}
}

View File

@@ -1,8 +0,0 @@
namespace Content.Shared._CP14.MagicRitualTrigger.Triggers;
[RegisterComponent]
public sealed partial class CP14RitualSacrificeWhitelistTriggerComponent : Component
{
[DataField]
public HashSet<CP14SacrificeWhitelistTrigger> Triggers = new();
}

View File

@@ -1,28 +0,0 @@
using Content.Shared._CP14.MagicRitual;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitualTrigger.Triggers;
/// <summary>
/// Triggers the phase transition after a certain period of time
/// </summary>
public sealed partial class CP14TimerTrigger : CP14RitualTrigger
{
[DataField]
public float Delay = 10f;
[DataField]
public TimeSpan TriggerTime = TimeSpan.Zero;
public override void Initialize(EntityManager entManager, Entity<CP14MagicRitualPhaseComponent> ritual, RitualPhaseEdge edge)
{
entManager.EnsureComponent<CP14RitualTimerTriggerComponent>(ritual, out var trigger);
trigger.Triggers.Add(this);
Edge = edge;
}
public override string? GetGuidebookTriggerDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
return Loc.GetString("cp14-ritual-trigger-timer-stable", ("time", Delay));
}
}

View File

@@ -1,8 +0,0 @@
namespace Content.Shared._CP14.MagicRitualTrigger.Triggers;
[RegisterComponent]
public sealed partial class CP14RitualTimerTriggerComponent : Component
{
[DataField]
public HashSet<CP14TimerTrigger> Triggers = new();
}

View File

@@ -1,28 +0,0 @@
using Content.Shared._CP14.MagicRitual;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicRitualTrigger.Triggers;
/// <summary>
/// Triggers a phase transition when the Ritual hears a certain message
/// </summary>
public sealed partial class CP14VoiceTrigger : CP14RitualTrigger
{
[DataField]
public string Message = string.Empty;
[DataField]
public int Speakers = 1;
public override void Initialize(EntityManager entManager, Entity<CP14MagicRitualPhaseComponent> ritual, RitualPhaseEdge edge)
{
entManager.EnsureComponent<CP14RitualVoiceTriggerComponent>(ritual, out var trigger);
trigger.Triggers.Add(this);
Edge = edge;
}
public override string? GetGuidebookTriggerDescription(IPrototypeManager prototype, IEntitySystemManager entSys)
{
return Loc.GetString("cp14-ritual-trigger-voice", ("phrase", Message), ("count", Speakers));
}
}

View File

@@ -1,8 +0,0 @@
namespace Content.Shared._CP14.MagicRitualTrigger.Triggers;
[RegisterComponent]
public sealed partial class CP14RitualVoiceTriggerComponent : Component
{
[DataField]
public HashSet<CP14VoiceTrigger> Triggers = new();
}