暂存坏的
This commit is contained in:
72
Source/WulaFallenEmpire/CompWulaRitualSpot.cs
Normal file
72
Source/WulaFallenEmpire/CompWulaRitualSpot.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
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.
|
||||
/// </summary>
|
||||
public class CompProperties_WulaRitualSpot : CompProperties
|
||||
{
|
||||
public string ritualTag;
|
||||
|
||||
public CompProperties_WulaRitualSpot()
|
||||
{
|
||||
this.compClass = typeof(CompWulaRitualSpot);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The core component for the custom ritual spot. Generates its own gizmos
|
||||
/// by filtering for rituals with a matching tag via a DefModExtension.
|
||||
/// </summary>
|
||||
public class CompWulaRitualSpot : ThingComp
|
||||
{
|
||||
public CompProperties_WulaRitualSpot Props => (CompProperties_WulaRitualSpot)this.props;
|
||||
|
||||
public override IEnumerable<Gizmo> CompGetGizmosExtra()
|
||||
{
|
||||
foreach (Gizmo gizmo in base.CompGetGizmosExtra())
|
||||
{
|
||||
yield return gizmo;
|
||||
}
|
||||
|
||||
// Find all rituals that have our custom mod extension and a matching tag
|
||||
foreach (PsychicRitualDef ritualDef in DefDatabase<PsychicRitualDef>.AllDefsListForReading)
|
||||
{
|
||||
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;
|
||||
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));
|
||||
};
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace WulaFallenEmpire.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(PsychicRitualGizmo), "VisibleRituals")]
|
||||
public static class Patch_PsychicRitualGizmo_VisibleRituals
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
public static List<PsychicRitualDef_InvocationCircle> Postfix(List<PsychicRitualDef_InvocationCircle> __result)
|
||||
{
|
||||
if (__result == null || __result.Count == 0)
|
||||
{
|
||||
return __result;
|
||||
}
|
||||
|
||||
// Create a new list containing only the rituals that DO NOT have our custom tag.
|
||||
// This is a more robust way to ensure our custom rituals are filtered out.
|
||||
return __result.Where(ritualDef =>
|
||||
{
|
||||
var extension = ritualDef.GetModExtension<RitualTagExtension>();
|
||||
// Keep the ritual if it has no extension, or if the extension tag is null/empty.
|
||||
return extension == null || string.IsNullOrEmpty(extension.ritualTag);
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Source/WulaFallenEmpire/RitualTagExtension.cs
Normal file
9
Source/WulaFallenEmpire/RitualTagExtension.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Verse;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class RitualTagExtension : DefModExtension
|
||||
{
|
||||
public string ritualTag;
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,7 @@
|
||||
<Compile Include="CompApparelInterceptor.cs" />
|
||||
<Compile Include="CompCustomUniqueWeapon.cs" />
|
||||
<Compile Include="CompProperties_CustomUniqueWeapon.cs" />
|
||||
<Compile Include="CompWulaRitualSpot.cs" />
|
||||
<Compile Include="CompPsychicScaling.cs" />
|
||||
<Compile Include="CompUseEffect_FixAllHealthConditions.cs" />
|
||||
<Compile Include="CompUseEffect_PassionTrainer.cs" />
|
||||
@@ -108,6 +109,7 @@
|
||||
<Compile Include="PsychicRitual_TechOffering.cs" />
|
||||
<Compile Include="PsychicRitualDef_AddHediff.cs" />
|
||||
<Compile Include="PsychicRitualToil_AddHediff.cs" />
|
||||
<Compile Include="RitualTagExtension.cs" />
|
||||
<Compile Include="Recipe_AdministerWulaMechRepairKit.cs" />
|
||||
<Compile Include="SectionLayer_WulaHull.cs" />
|
||||
<Compile Include="ThingDefExtension_EnergySource.cs" />
|
||||
|
||||
Reference in New Issue
Block a user