Class Prefabs
The manager that makes custom unit, improvement, and resource prefabs from mod data. It also replaces the unit prefab lookup of PrefabManager.
public static class Prefabs
- Inheritance
-
Prefabs
- Inherited Members
Fields
improvementInfos
The descriptions of the custom improvement prefabs. It contains the items from the mod prefab files and the default items that PolyMod.Managers.Prefabs.CreatePrefabs() adds. PolyMod.Managers.Prefabs.CreatePrefabs() makes one prefab for each item.
public static List<ImprovementPrefabInfo> improvementInfos
Field Value
resourceInfos
The descriptions of the custom resource prefabs. It contains the items from the mod prefab files and the default items that PolyMod.Managers.Prefabs.CreatePrefabs() adds. PolyMod.Managers.Prefabs.CreatePrefabs() makes one prefab for each item.
public static List<ResourcePrefabInfo> resourceInfos
Field Value
unitInfos
The descriptions of the custom unit prefabs from the mod prefab files. PolyMod.Managers.Prefabs.CreatePrefabs() makes one prefab for each item.
public static List<UnitPrefabInfo> unitInfos
Field Value
Methods
GetUnitOrUiOverride(ref Unit, Type, TribeType, SkinType)
Patches PrefabManager.GetUnitOrUiOverride as a prefix.
Replaces the original method with a lookup in the PolyMod unit lookups.
[HarmonyPrefix]
[HarmonyPatch(typeof(PrefabManager), "GetUnitOrUiOverride")]
public static bool GetUnitOrUiOverride(ref Unit __result, UnitData.Type unitType, TribeType tribe, SkinType skin)
Parameters
__resultUnitSet to the UI override prefab, or to the usual unit prefab.
unitTypeUnitData.TypeThe unit type.
tribeTribeTypeThe tribe.
skinSkinTypeThe skin.
Returns
- bool
Always false, so the original method does not run.
Remarks
The method first finds the key in PolyMod.Managers.Prefabs.unitUIOverridesNew. If the key is not there, it uses PolyMod.Managers.Prefabs.ResolveUnitPrefab(Polytopia.Data.UnitData.Type, PolytopiaBackendBase.Common.TribeType, PolytopiaBackendBase.Common.SkinType).
HasUIUnitOverride(ref bool, Type, TribeType, SkinType)
Patches PrefabManager.HasUIUnitOverride as a prefix.
Replaces the original check with a check in PolyMod.Managers.Prefabs.unitUIOverridesNew.
[HarmonyPrefix]
[HarmonyPatch(typeof(PrefabManager), "HasUIUnitOverride")]
public static bool HasUIUnitOverride(ref bool __result, UnitData.Type unitType, TribeType tribe, SkinType skin)
Parameters
__resultboolSet to true when PolyMod.Managers.Prefabs.unitUIOverridesNew contains the key, otherwise false.
unitTypeUnitData.TypeThe unit type.
tribeTribeTypeThe tribe.
skinSkinTypeThe skin.
Returns
- bool
Always false, so the original method does not run.
PrefabManager_GetPrefab(ref Unit, Type, TribeType, SkinType)
Patches PrefabManager.GetPrefab(UnitData.Type, TribeType, SkinType) as a prefix.
Replaces the original method with PolyMod.Managers.Prefabs.ResolveUnitPrefab(Polytopia.Data.UnitData.Type, PolytopiaBackendBase.Common.TribeType, PolytopiaBackendBase.Common.SkinType).
[HarmonyPrefix]
[HarmonyPatch(typeof(PrefabManager), "GetPrefab", new Type[] { typeof(UnitData.Type), typeof(TribeType), typeof(SkinType) })]
public static bool PrefabManager_GetPrefab(ref Unit __result, UnitData.Type type, TribeType tribe, SkinType skin)
Parameters
__resultUnitSet to the unit prefab that PolyMod.Managers.Prefabs.ResolveUnitPrefab(Polytopia.Data.UnitData.Type, PolytopiaBackendBase.Common.TribeType, PolytopiaBackendBase.Common.SkinType) gives.
typeUnitData.TypeThe unit type.
tribeTribeTypeThe tribe.
skinSkinTypeThe skin.
Returns
- bool
Always false, so the original method does not run.
SetupVisualPart(ref VisualPart, bool)
Patches SkinVisualsReference.SetupVisualPart as a postfix.
Does the outline check for the visual part again and sets hasValidOutline.
[HarmonyPostfix]
[HarmonyPatch(typeof(SkinVisualsReference), "SetupVisualPart")]
public static void SetupVisualPart(ref SkinVisualsReference.VisualPart visualSetting, bool isImprovement)
Parameters
visualSettingSkinVisualsReference.VisualPartThe visual part that the original method configured.
isImprovementboolThe value from the original call. The method does not use it.
Remarks
If the outline is not a child of the visual part object, the method uses the first child as the outline.
It does this only when the visual part object has children.
Then it sets hasValidOutline to true only when the outline name is the default sprite name plus _Outline.