material aspect support (#1643)
This commit is contained in:
@@ -25,6 +25,7 @@ public abstract partial class CP14SharedMagicSystem
|
||||
{
|
||||
SubscribeLocalEvent<CP14MagicEffectSomaticAspectComponent, CP14CastMagicEffectAttemptEvent>(OnSomaticCheck);
|
||||
SubscribeLocalEvent<CP14MagicEffectVerbalAspectComponent, CP14CastMagicEffectAttemptEvent>(OnVerbalCheck);
|
||||
SubscribeLocalEvent<CP14MagicEffectMaterialAspectComponent, CP14CastMagicEffectAttemptEvent>(OnMaterialCheck);
|
||||
SubscribeLocalEvent<CP14MagicEffectManaCostComponent, CP14CastMagicEffectAttemptEvent>(OnManaCheck);
|
||||
SubscribeLocalEvent<CP14MagicEffectStaminaCostComponent, CP14CastMagicEffectAttemptEvent>(OnStaminaCheck);
|
||||
SubscribeLocalEvent<CP14MagicEffectPacifiedBlockComponent, CP14CastMagicEffectAttemptEvent>(OnPacifiedCheck);
|
||||
@@ -36,7 +37,7 @@ public abstract partial class CP14SharedMagicSystem
|
||||
SubscribeLocalEvent<CP14MagicEffectVerbalAspectComponent, CP14MagicEffectConsumeResourceEvent>(OnVerbalAspectAfterCast);
|
||||
SubscribeLocalEvent<CP14MagicEffectEmotingComponent, CP14StartCastMagicEffectEvent>(OnEmoteStartCast);
|
||||
SubscribeLocalEvent<CP14MagicEffectEmotingComponent, CP14MagicEffectConsumeResourceEvent>(OnEmoteEndCast);
|
||||
|
||||
SubscribeLocalEvent<CP14MagicEffectMaterialAspectComponent, CP14MagicEffectConsumeResourceEvent>(OnMaterialAspectEndCast);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -109,6 +110,27 @@ public abstract partial class CP14SharedMagicSystem
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnMaterialCheck(Entity<CP14MagicEffectMaterialAspectComponent> ent, ref CP14CastMagicEffectAttemptEvent args)
|
||||
{
|
||||
if (ent.Comp.Requirement is null)
|
||||
return;
|
||||
|
||||
HashSet<EntityUid> heldedItems = new();
|
||||
|
||||
foreach (var hand in _hand.EnumerateHands(args.Performer))
|
||||
{
|
||||
var helded = _hand.GetHeldItem(args.Performer, hand);
|
||||
if (helded is not null)
|
||||
heldedItems.Add(helded.Value);
|
||||
}
|
||||
|
||||
if (!ent.Comp.Requirement.CheckRequirement(EntityManager, _proto, heldedItems))
|
||||
{
|
||||
args.PushReason(Loc.GetString("cp14-magic-spell-need-material-component"));
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPacifiedCheck(Entity<CP14MagicEffectPacifiedBlockComponent> ent,
|
||||
ref CP14CastMagicEffectAttemptEvent args)
|
||||
{
|
||||
@@ -214,4 +236,21 @@ public abstract partial class CP14SharedMagicSystem
|
||||
};
|
||||
RaiseLocalEvent(ent, ref ev);
|
||||
}
|
||||
|
||||
private void OnMaterialAspectEndCast(Entity<CP14MagicEffectMaterialAspectComponent> ent, ref CP14MagicEffectConsumeResourceEvent args)
|
||||
{
|
||||
if (ent.Comp.Requirement is null || args.Performer is null)
|
||||
return;
|
||||
|
||||
HashSet<EntityUid> heldedItems = new();
|
||||
|
||||
foreach (var hand in _hand.EnumerateHands(args.Performer.Value))
|
||||
{
|
||||
var helded = _hand.GetHeldItem(args.Performer.Value, hand);
|
||||
if (helded is not null)
|
||||
heldedItems.Add(helded.Value);
|
||||
}
|
||||
|
||||
ent.Comp.Requirement.PostCraft(EntityManager, _proto, heldedItems);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,11 @@ public abstract partial class CP14SharedMagicSystem : EntitySystem
|
||||
sb.Append("\n" + Loc.GetString("cp14-magic-somatic-aspect") + " " + somatic.FreeHandRequired);
|
||||
}
|
||||
|
||||
if (TryComp<CP14MagicEffectMaterialAspectComponent>(ent, out var material) && material.Requirement is not null)
|
||||
{
|
||||
sb.Append("\n" + Loc.GetString("cp14-magic-material-aspect") + " " + material.Requirement.GetRequirementTitle(_proto));
|
||||
}
|
||||
|
||||
if (TryComp<CP14MagicEffectRequiredMusicToolComponent>(ent, out var music))
|
||||
{
|
||||
sb.Append("\n" + Loc.GetString("cp14-magic-music-aspect"));
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using Content.Shared._CP14.Workbench;
|
||||
|
||||
namespace Content.Shared._CP14.MagicSpell.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Requires the caster to hold a specific resource in their hand, which will be spent to use the spell.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SharedMagicSystem))]
|
||||
public sealed partial class CP14MagicEffectMaterialAspectComponent : Component
|
||||
{
|
||||
[DataField(required: true)]
|
||||
public CP14WorkbenchCraftRequirement? Requirement;
|
||||
}
|
||||
@@ -11,10 +11,12 @@ cp14-magic-spell-not-enough-mana-cast-warning-4 = Your head becomes heavy...
|
||||
cp14-magic-type = Type
|
||||
cp14-magic-verbal-aspect = Requires the ability to speak
|
||||
cp14-magic-somatic-aspect = Requires a free hand:
|
||||
cp14-magic-material-aspect = The following material components are required:
|
||||
cp14-magic-music-aspect = You must play a musical instrument
|
||||
|
||||
cp14-magic-spell-need-verbal-component = You can't cast the spell out loud.
|
||||
cp14-magic-spell-need-somatic-component = You don't have your hands free.
|
||||
cp14-magic-spell-need-material-component = You need to hold the material component of the spell in your hands.
|
||||
|
||||
cp14-magic-spell-stamina-not-enough = You don't have the energy to do it.
|
||||
cp14-magic-staminacost = Stamina cost
|
||||
|
||||
@@ -11,10 +11,12 @@ cp14-magic-spell-not-enough-mana-cast-warning-4 = Голова наливает
|
||||
cp14-magic-type = Тип
|
||||
cp14-magic-verbal-aspect = Требуется возможность говорить
|
||||
cp14-magic-somatic-aspect = Требуются свободные руки:
|
||||
cp14-magic-material-aspect = Требуются материальный компонент:
|
||||
cp14-magic-music-aspect = Вы должны играть на музыкальном инструменте
|
||||
|
||||
cp14-magic-spell-need-verbal-component = Вы не можете произнести заклинание вслух.
|
||||
cp14-magic-spell-need-somatic-component = Вам не хватает свободных рук.
|
||||
cp14-magic-spell-need-material-component = Нужно держать материальный компонент заклинания в руках.
|
||||
|
||||
cp14-magic-spell-stamina-not-enough = Вам не хватает сил, чтобы сделать это.
|
||||
cp14-magic-staminacost = Затраты энергии
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
- !type:CP14SpellSpawnEntityOnTarget
|
||||
spawns:
|
||||
- CP14WallSpawnEarthWall
|
||||
- type: CP14MagicEffectMaterialAspect
|
||||
requirement: !type:StackResource
|
||||
stack: CP14Dirt
|
||||
count: 2
|
||||
- type: CP14MagicEffectVerbalAspect
|
||||
startSpeech: "Surgite terram..."
|
||||
endSpeech: "de profundis terrae"
|
||||
|
||||
Reference in New Issue
Block a user