新机械体
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class CompProperties_SkyfallerFaction : CompProperties
|
||||
{
|
||||
public FactionDef factionDef;
|
||||
public bool usePlayerFactionIfNull = true; // 如果 factionDef 为 null 时使用玩家派系
|
||||
|
||||
public CompProperties_SkyfallerFaction()
|
||||
{
|
||||
compClass = typeof(CompSkyfallerFaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class CompSkyfallerFaction : ThingComp
|
||||
{
|
||||
public CompProperties_SkyfallerFaction Props => (CompProperties_SkyfallerFaction)props;
|
||||
|
||||
public Faction GetFactionForPrefab()
|
||||
{
|
||||
// 如果指定了派系定义,使用该派系
|
||||
if (Props.factionDef != null)
|
||||
{
|
||||
Faction faction = Find.FactionManager.FirstFactionOfDef(Props.factionDef);
|
||||
if (faction != null)
|
||||
return faction;
|
||||
}
|
||||
|
||||
// 如果没有指定派系定义,根据设置决定
|
||||
if (Props.usePlayerFactionIfNull)
|
||||
{
|
||||
return Faction.OfPlayer;
|
||||
}
|
||||
|
||||
// 如果都不满足,返回 null(使用默认行为)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user