暂存
This commit is contained in:
@@ -6,16 +6,11 @@ using Verse.AI.Group;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
// NOTE: The PsychicRitualDef_Wula class has been removed as it's no longer needed.
|
||||
// We are now using a DefModExtension for filtering, which is a much cleaner approach.
|
||||
|
||||
/// <summary>
|
||||
/// Custom CompProperties for our ritual spot, with a tag.
|
||||
/// Custom CompProperties for our ritual spot. It no longer needs a tag.
|
||||
/// </summary>
|
||||
public class CompProperties_WulaRitualSpot : CompProperties
|
||||
{
|
||||
public string ritualTag;
|
||||
|
||||
public CompProperties_WulaRitualSpot()
|
||||
{
|
||||
this.compClass = typeof(CompWulaRitualSpot);
|
||||
@@ -24,7 +19,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
/// <summary>
|
||||
/// The core component for the custom ritual spot. Generates its own gizmos
|
||||
/// by filtering for rituals with a matching tag via a DefModExtension.
|
||||
/// by specifically looking for Defs that inherit from our custom PsychicRitualDef_Wula base class.
|
||||
/// </summary>
|
||||
public class CompWulaRitualSpot : ThingComp
|
||||
{
|
||||
@@ -37,35 +32,31 @@ namespace WulaFallenEmpire
|
||||
yield return gizmo;
|
||||
}
|
||||
|
||||
// Find all rituals that have our custom mod extension and a matching tag
|
||||
foreach (PsychicRitualDef ritualDef in DefDatabase<PsychicRitualDef>.AllDefsListForReading)
|
||||
// Find all rituals that are of our custom base class type.
|
||||
foreach (PsychicRitualDef_Wula ritualDef in DefDatabase<PsychicRitualDef_Wula>.AllDefs)
|
||||
{
|
||||
var extension = ritualDef.GetModExtension<RitualTagExtension>();
|
||||
if (extension != null && extension.ritualTag == this.Props.ritualTag)
|
||||
Command_Action command_Action = new Command_Action();
|
||||
command_Action.defaultLabel = ritualDef.LabelCap.Resolve();
|
||||
command_Action.defaultDesc = ritualDef.description;
|
||||
command_Action.icon = ritualDef.uiIcon;
|
||||
command_Action.action = delegate
|
||||
{
|
||||
Command_Action command_Action = new Command_Action();
|
||||
command_Action.defaultLabel = ritualDef.LabelCap;
|
||||
command_Action.defaultDesc = ritualDef.description;
|
||||
command_Action.icon = ritualDef.uiIcon;
|
||||
command_Action.action = delegate
|
||||
{
|
||||
// Mimic vanilla initialization
|
||||
TargetInfo target = new TargetInfo(this.parent);
|
||||
PsychicRitualRoleAssignments assignments = ritualDef.BuildRoleAssignments(target);
|
||||
PsychicRitualCandidatePool candidatePool = ritualDef.FindCandidatePool();
|
||||
ritualDef.InitializeCast(this.parent.Map);
|
||||
Find.WindowStack.Add(new Dialog_BeginPsychicRitual(ritualDef, candidatePool, assignments, this.parent.Map));
|
||||
};
|
||||
// Mimic vanilla initialization
|
||||
TargetInfo target = new TargetInfo(this.parent);
|
||||
PsychicRitualRoleAssignments assignments = ritualDef.BuildRoleAssignments(target);
|
||||
PsychicRitualCandidatePool candidatePool = ritualDef.FindCandidatePool();
|
||||
ritualDef.InitializeCast(this.parent.Map);
|
||||
Find.WindowStack.Add(new Dialog_BeginPsychicRitual(ritualDef, candidatePool, assignments, this.parent.Map));
|
||||
};
|
||||
|
||||
// Corrected check for cooldown and other requirements
|
||||
AcceptanceReport acceptanceReport = Find.PsychicRitualManager.CanInvoke(ritualDef, this.parent.Map);
|
||||
if (!acceptanceReport.Accepted)
|
||||
{
|
||||
command_Action.Disable(acceptanceReport.Reason.CapitalizeFirst());
|
||||
}
|
||||
|
||||
yield return command_Action;
|
||||
// Corrected check for cooldown and other requirements
|
||||
AcceptanceReport acceptanceReport = Find.PsychicRitualManager.CanInvoke(ritualDef, this.parent.Map);
|
||||
if (!acceptanceReport.Accepted)
|
||||
{
|
||||
command_Action.Disable(acceptanceReport.Reason.CapitalizeFirst());
|
||||
}
|
||||
|
||||
yield return command_Action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user