新机械体
This commit is contained in:
@@ -6,6 +6,7 @@ namespace WulaFallenEmpire
|
||||
public class Skyfaller_PrefabSpawner : Skyfaller
|
||||
{
|
||||
public string prefabDefName;
|
||||
private Faction prefabFaction; // 缓存派系信息
|
||||
|
||||
protected override void SpawnThings()
|
||||
{
|
||||
@@ -23,8 +24,30 @@ namespace WulaFallenEmpire
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取派系信息
|
||||
Faction faction = GetPrefabFaction();
|
||||
|
||||
// Correct parameter order based on compiler error: prefabDef, map, position, rotation
|
||||
PrefabUtility.SpawnPrefab(prefabDef, base.Map, base.Position, base.Rotation);
|
||||
PrefabUtility.SpawnPrefab(prefabDef, base.Map, base.Position, base.Rotation, faction);
|
||||
}
|
||||
|
||||
private Faction GetPrefabFaction()
|
||||
{
|
||||
// 如果已经缓存了派系信息,直接返回
|
||||
if (prefabFaction != null)
|
||||
return prefabFaction;
|
||||
|
||||
// 检查是否有 CompSkyfallerFaction 组件
|
||||
var factionComp = this.TryGetComp<CompSkyfallerFaction>();
|
||||
if (factionComp != null)
|
||||
{
|
||||
prefabFaction = factionComp.GetFactionForPrefab();
|
||||
return prefabFaction;
|
||||
}
|
||||
|
||||
// 如果没有组件,默认使用玩家派系
|
||||
prefabFaction = Faction.OfPlayer;
|
||||
return prefabFaction;
|
||||
}
|
||||
|
||||
public override void ExposeData()
|
||||
@@ -33,4 +56,4 @@ namespace WulaFallenEmpire
|
||||
Scribe_Values.Look(ref prefabDefName, "prefabDefName");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user