Table of Contents

Class Prefabs

Namespace
PolyMod.Managers
Assembly
PolyMod.dll

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

List<ImprovementPrefabInfo>

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

List<ResourcePrefabInfo>

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

List<UnitPrefabInfo>

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

__result Unit

Set to the UI override prefab, or to the usual unit prefab.

unitType UnitData.Type

The unit type.

tribe TribeType

The tribe.

skin SkinType

The 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

__result bool

Set to true when PolyMod.Managers.Prefabs.unitUIOverridesNew contains the key, otherwise false.

unitType UnitData.Type

The unit type.

tribe TribeType

The tribe.

skin SkinType

The 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

__result Unit

Set to the unit prefab that PolyMod.Managers.Prefabs.ResolveUnitPrefab(Polytopia.Data.UnitData.Type, PolytopiaBackendBase.Common.TribeType, PolytopiaBackendBase.Common.SkinType) gives.

type UnitData.Type

The unit type.

tribe TribeType

The tribe.

skin SkinType

The 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

visualSetting SkinVisualsReference.VisualPart

The visual part that the original method configured.

isImprovement bool

The 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.