Class GameObjectHelper
Static helper methods to instantiate common types of Daggerfall gameobjects.
Namespace: DaggerfallWorkshop.Utility
Assembly: Assembly-CSharp.dll
Syntax
public static class GameObjectHelper
Properties
| Improve this Doc View SourceEnemyDict
Declaration
public static Dictionary<int, MobileEnemy> EnemyDict { get; }
Property Value
Type | Description |
---|---|
Dictionary<Int32, MobileEnemy> |
Methods
| Improve this Doc View SourceAddAnimalAudioSource(GameObject, Int32)
Declaration
public static void AddAnimalAudioSource(GameObject go, int record)
Parameters
Type | Name | Description |
---|---|---|
GameObject | go | |
Int32 | record |
AddQuestResourceObjects(SiteTypes, Transform, Int32, Boolean, Boolean, Boolean)
Finds SiteLinks matching this interior and walks Place markers to inject quest resources. Some of this handling will be split and relocated for other builders. Just working through the steps in buildings interiors for now. This will be moved to a different setup class later.
Declaration
public static void AddQuestResourceObjects(SiteTypes siteType, Transform parent, int buildingKey = 0, bool enableNPCs = true, bool enableFoes = true, bool enableItems = true)
Parameters
Type | Name | Description |
---|---|---|
SiteTypes | siteType | |
Transform | parent | |
Int32 | buildingKey | |
Boolean | enableNPCs | |
Boolean | enableFoes | |
Boolean | enableItems |
AlignBillboardToGround(GameObject, Vector2, Single)
Declaration
public static void AlignBillboardToGround(GameObject go, Vector2 size, float distance = 2F)
Parameters
Type | Name | Description |
---|---|---|
GameObject | go | |
Vector2 | size | |
Single | distance |
AlignControllerToGround(CharacterController, Single)
Declaration
public static void AlignControllerToGround(CharacterController controller, float distance = 3F)
Parameters
Type | Name | Description |
---|---|---|
CharacterController | controller | |
Single | distance |
AssignAnimatedMaterialComponent(CachedMaterial[], GameObject)
Declaration
public static void AssignAnimatedMaterialComponent(CachedMaterial[] cachedMaterials, GameObject go)
Parameters
Type | Name | Description |
---|---|---|
CachedMaterial[] | cachedMaterials | |
GameObject | go |
ChangeDaggerfallMeshGameObject(DaggerfallMesh, UInt32)
Declaration
public static void ChangeDaggerfallMeshGameObject(DaggerfallMesh dfMesh, uint newModelID)
Parameters
Type | Name | Description |
---|---|---|
DaggerfallMesh | dfMesh | |
UInt32 | newModelID |
CreateBillboardBatchGameObject(Int32, Transform)
Create a billboard batch.
Declaration
public static DaggerfallBillboardBatch CreateBillboardBatchGameObject(int archive, Transform parent = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive this batch is to use. |
Transform | parent | Parent transform. |
Returns
Type | Description |
---|---|
DaggerfallBillboardBatch | Billboard batch GameObject. |
CreateBillboardBatchGameObject(Material, Transform)
Create a billboard batch with custom material/
Declaration
public static DaggerfallBillboardBatch CreateBillboardBatchGameObject(Material material, Transform parent = null)
Parameters
Type | Name | Description |
---|---|---|
Material | material | Custom atlas material. |
Transform | parent | Parent transform. |
Returns
Type | Description |
---|---|
DaggerfallBillboardBatch | Billboard batch GameObject. |
CreateCombinedMeshGameObject(ModelCombiner, String, Transform, Boolean)
Declaration
public static GameObject CreateCombinedMeshGameObject(ModelCombiner combiner, string meshName, Transform parent, bool makeStatic = false)
Parameters
Type | Name | Description |
---|---|---|
ModelCombiner | combiner | |
String | meshName | |
Transform | parent | |
Boolean | makeStatic |
Returns
Type | Description |
---|---|
GameObject |
CreateDaggerfallBillboardGameObject(Int32, Int32, Transform)
Declaration
public static GameObject CreateDaggerfallBillboardGameObject(int archive, int record, Transform parent)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | |
Int32 | record | |
Transform | parent |
Returns
Type | Description |
---|---|
GameObject |
CreateDaggerfallDungeonGameObject(DFLocation, Transform, out GameObject)
Declaration
public static DaggerfallDungeon CreateDaggerfallDungeonGameObject(DFLocation location, Transform parent, out GameObject go)
Parameters
Type | Name | Description |
---|---|---|
DFLocation | location | |
Transform | parent | |
GameObject | go |
Returns
Type | Description |
---|---|
DaggerfallDungeon |
CreateDaggerfallDungeonGameObject(String, Transform, Boolean)
Declaration
public static GameObject CreateDaggerfallDungeonGameObject(string multiName, Transform parent, bool importEnemies = true)
Parameters
Type | Name | Description |
---|---|---|
String | multiName | |
Transform | parent | |
Boolean | importEnemies |
Returns
Type | Description |
---|---|
GameObject |
CreateDaggerfallLocationGameObject(String, Transform)
Declaration
public static GameObject CreateDaggerfallLocationGameObject(string multiName, Transform parent)
Parameters
Type | Name | Description |
---|---|---|
String | multiName | |
Transform | parent |
Returns
Type | Description |
---|---|
GameObject |
CreateDaggerfallMeshGameObject(UInt32, Transform, Boolean, GameObject, Boolean, Boolean)
Adds a single DaggerfallMesh game object to scene.
Declaration
public static GameObject CreateDaggerfallMeshGameObject(uint modelID, Transform parent, bool makeStatic = false, GameObject useExistingObject = null, bool ignoreCollider = false, bool convexCollider = false)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | modelID | ModelID of mesh to add. |
Transform | parent | Optional parent of this object. |
Boolean | makeStatic | Flag to set object static flag. |
GameObject | useExistingObject | Add mesh to existing object rather than create new. |
Boolean | ignoreCollider | Force disable collider. |
Boolean | convexCollider | Make collider convex. |
Returns
Type | Description |
---|---|
GameObject | GameObject. |
CreateDaggerfallTerrainGameObject(Transform)
Declaration
public static GameObject CreateDaggerfallTerrainGameObject(Transform parent)
Parameters
Type | Name | Description |
---|---|---|
Transform | parent |
Returns
Type | Description |
---|---|
GameObject |
CreateDroppedLootContainer(GameObject, UInt64, Int32, Int32)
Creates a loot container for items dropped by the player.
Declaration
public static DaggerfallLoot CreateDroppedLootContainer(GameObject player, ulong loadID, int iconArchive = 216, int iconRecord = -1)
Parameters
Type | Name | Description |
---|---|---|
GameObject | player | Player object, must have PlayerEnterExit and PlayerMotor attached. |
UInt64 | loadID | Unique LoadID for save system. |
Int32 | iconArchive | |
Int32 | iconRecord |
Returns
Type | Description |
---|---|
DaggerfallLoot | DaggerfallLoot. |
CreateEnemy(String, MobileTypes, Vector3, MobileGender, Transform, MobileReactions)
Create an enemy in the world and perform common setup tasks.
Declaration
public static GameObject CreateEnemy(string name, MobileTypes mobileType, Vector3 localPosition, MobileGender mobileGender = MobileGender.Unspecified, Transform parent = null, MobileReactions mobileReaction = MobileReactions.Hostile)
Parameters
Type | Name | Description |
---|---|---|
String | name | |
MobileTypes | mobileType | |
Vector3 | localPosition | |
MobileGender | mobileGender | |
Transform | parent | |
MobileReactions | mobileReaction |
Returns
Type | Description |
---|---|
GameObject |
CreateFoeGameObjects(Vector3, MobileTypes, Int32, MobileReactions, Foe, Boolean)
Creates enemy GameObjects based on spawn count (minimum of 1, maximum of 8). Only use this when live enemy is to be first added to scene. Do not use when linking to site or deserializing. GameObjects created will be disabled, at position specified, parentless, and have a new UID for LoadID. Caller must otherwise complete GameObject setup to suit their needs before enabling.
Declaration
public static GameObject[] CreateFoeGameObjects(Vector3 position, MobileTypes foeType, int spawnCount = 1, MobileReactions reaction = MobileReactions.Hostile, Foe foeResource = null, bool alliedToPlayer = false)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | |
MobileTypes | foeType | |
Int32 | spawnCount | |
MobileReactions | reaction | Foe is hostile by default but can optionally set to passive. |
Foe | foeResource | |
Boolean | alliedToPlayer |
Returns
Type | Description |
---|---|
GameObject[] | GameObject[] array of 1-N foes. Array can be null or empty if create fails. |
CreateFoeSpawner(Boolean, MobileTypes, Int32, Single, Single, Transform, Boolean)
Create a new foe spawner. The spawner will self-destroy once it has emitted foes into world around player.
Declaration
public static GameObject CreateFoeSpawner(bool lineOfSightCheck = true, MobileTypes foeType = MobileTypes.None, int spawnCount = 0, float minDistance = 4F, float maxDistance = 20F, Transform parent = null, bool alliedToPlayer = false)
Parameters
Type | Name | Description |
---|---|---|
Boolean | lineOfSightCheck | Should spawner try to place outside of player's field of view. |
MobileTypes | foeType | Type of foe to spawn. |
Int32 | spawnCount | Number of duplicate foes to spawn. |
Single | minDistance | Minimum distance from player. |
Single | maxDistance | Maximum distance from player. |
Transform | parent | Parent GameObject. If none specified the most suitable parent will be selected automatically. |
Boolean | alliedToPlayer |
Returns
Type | Description |
---|---|
GameObject | FoeSpawner GameObject. |
CreateLootableCorpseMarker(GameObject, GameObject, EnemyEntity, Int32, UInt64)
Creates a loot container for enemies slain by the player.
Declaration
public static DaggerfallLoot CreateLootableCorpseMarker(GameObject player, GameObject enemy, EnemyEntity enemyEntity, int corpseTexture, ulong loadID)
Parameters
Type | Name | Description |
---|---|---|
GameObject | player | Player object, must have PlayerEnterExit attached. |
GameObject | enemy | Enemy object, must have EnemyMotor attached. |
EnemyEntity | enemyEntity | |
Int32 | corpseTexture | Packed corpse texture index from entity summary. |
UInt64 | loadID | Unique LoadID for save system. |
Returns
Type | Description |
---|---|
DaggerfallLoot | DaggerfallLoot. |
CreateLootContainer(LootContainerTypes, InventoryContainerImages, Vector3, Transform, Int32, Int32, UInt64, EnemyEntity, Boolean)
Creates a generic loot container.
Declaration
public static DaggerfallLoot CreateLootContainer(LootContainerTypes containerType, InventoryContainerImages containerImage, Vector3 position, Transform parent, int textureArchive, int textureRecord, ulong loadID = 0UL, EnemyEntity enemyEntity = null, bool adjustPosition = true)
Parameters
Type | Name | Description |
---|---|---|
LootContainerTypes | containerType | Type of container. |
InventoryContainerImages | containerImage | Icon to display in loot UI. |
Vector3 | position | Position to spawn container. |
Transform | parent | Parent GameObject. |
Int32 | textureArchive | Texture archive for billboard containers. |
Int32 | textureRecord | Texture record for billboard containers. |
UInt64 | loadID | Unique LoadID for save system. |
EnemyEntity | enemyEntity | |
Boolean | adjustPosition |
Returns
Type | Description |
---|---|
DaggerfallLoot | DaggerfallLoot. |
CreateRDBBlockGameObject(String, Int32[], Boolean, DFRegion.DungeonTypes, Single, Int32, Int32, DaggerfallRDBBlock, Boolean)
Layout a complete RDB block game object.
Declaration
public static GameObject CreateRDBBlockGameObject(string blockName, int[] textureTable = null, bool allowExitDoors = true, DFRegion.DungeonTypes dungeonType = DFRegion.DungeonTypes.HumanStronghold, float monsterPower = 0.5F, int monsterVariance = 4, int seed = 0, DaggerfallRDBBlock cloneFrom = null, bool importEnemies = true)
Parameters
Type | Name | Description |
---|---|---|
String | blockName | Name of block to create. |
Int32[] | textureTable | Optional texture table for dungeon. |
Boolean | allowExitDoors | Add exit doors to block (for start blocks). |
DFRegion.DungeonTypes | dungeonType | Dungeon type for random encounters. |
Single | monsterPower | |
Int32 | monsterVariance | |
Int32 | seed | Seed for random encounters. |
DaggerfallRDBBlock | cloneFrom | Clone and build on a prefab object template. |
Boolean | importEnemies | Import enemies from game data. |
Returns
Type | Description |
---|---|
GameObject |
CreateRMBBlockGameObject(DFBlock, Int32, Int32, Int32, Int32, Boolean, DaggerfallRMBBlock, DaggerfallBillboardBatch, DaggerfallBillboardBatch, DaggerfallBillboardBatch, TextureAtlasBuilder, DaggerfallBillboardBatch, ClimateNatureSets, ClimateSeason)
Layout RMB block game object from DFBlock data.
Declaration
public static GameObject CreateRMBBlockGameObject(DFBlock blockData, int layoutX, int layoutY, int mapId, int locationIndex, bool addGroundPlane = true, DaggerfallRMBBlock cloneFrom = null, DaggerfallBillboardBatch natureBillboardBatch = null, DaggerfallBillboardBatch lightsBillboardBatch = null, DaggerfallBillboardBatch animalsBillboardBatch = null, TextureAtlasBuilder miscBillboardAtlas = null, DaggerfallBillboardBatch miscBillboardBatch = null, ClimateNatureSets climateNature = ClimateNatureSets.TemperateWoodland, ClimateSeason climateSeason = ClimateSeason.Summer)
Parameters
Type | Name | Description |
---|---|---|
DFBlock | blockData | |
Int32 | layoutX | |
Int32 | layoutY | |
Int32 | mapId | |
Int32 | locationIndex | |
Boolean | addGroundPlane | |
DaggerfallRMBBlock | cloneFrom | |
DaggerfallBillboardBatch | natureBillboardBatch | |
DaggerfallBillboardBatch | lightsBillboardBatch | |
DaggerfallBillboardBatch | animalsBillboardBatch | |
TextureAtlasBuilder | miscBillboardAtlas | |
DaggerfallBillboardBatch | miscBillboardBatch | |
ClimateNatureSets | climateNature | |
ClimateSeason | climateSeason |
Returns
Type | Description |
---|---|
GameObject |
CreateRMBBlockGameObject(String, Int32, Int32, Int32, Int32, Boolean, DaggerfallRMBBlock, DaggerfallBillboardBatch, DaggerfallBillboardBatch, DaggerfallBillboardBatch, TextureAtlasBuilder, DaggerfallBillboardBatch, ClimateNatureSets, ClimateSeason)
Layout RMB block gamne object from name only. This will be missing information like building data and should only be used standalone.
Declaration
public static GameObject CreateRMBBlockGameObject(string blockName, int layoutX, int layoutY, int mapId, int locationIndex, bool addGroundPlane = true, DaggerfallRMBBlock cloneFrom = null, DaggerfallBillboardBatch natureBillboardBatch = null, DaggerfallBillboardBatch lightsBillboardBatch = null, DaggerfallBillboardBatch animalsBillboardBatch = null, TextureAtlasBuilder miscBillboardAtlas = null, DaggerfallBillboardBatch miscBillboardBatch = null, ClimateNatureSets climateNature = ClimateNatureSets.TemperateWoodland, ClimateSeason climateSeason = ClimateSeason.Summer)
Parameters
Type | Name | Description |
---|---|---|
String | blockName | |
Int32 | layoutX | |
Int32 | layoutY | |
Int32 | mapId | |
Int32 | locationIndex | |
Boolean | addGroundPlane | |
DaggerfallRMBBlock | cloneFrom | |
DaggerfallBillboardBatch | natureBillboardBatch | |
DaggerfallBillboardBatch | lightsBillboardBatch | |
DaggerfallBillboardBatch | animalsBillboardBatch | |
TextureAtlasBuilder | miscBillboardAtlas | |
DaggerfallBillboardBatch | miscBillboardBatch | |
ClimateNatureSets | climateNature | |
ClimateSeason | climateSeason |
Returns
Type | Description |
---|---|
GameObject |
FindMultiNameLocation(String, out DFLocation)
Declaration
public static bool FindMultiNameLocation(string multiName, out DFLocation locationOut)
Parameters
Type | Name | Description |
---|---|---|
String | multiName | |
DFLocation | locationOut |
Returns
Type | Description |
---|---|
Boolean |
GetBestParent()
Gets best parent for an object at spawn time. Objects should always be placed to some child object in world rather than directly into root of scene.
Declaration
public static Transform GetBestParent()
Returns
Type | Description |
---|---|
Transform | Best parent transform, or null as fallback. |
GetGoFlatName(Int32, Int32)
Declaration
public static string GetGoFlatName(int textureArchive, int textureRecord)
Parameters
Type | Name | Description |
---|---|---|
Int32 | textureArchive | |
Int32 | textureRecord |
Returns
Type | Description |
---|---|
String |
GetGoModelName(UInt32)
Declaration
public static string GetGoModelName(uint modelID)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | modelID |
Returns
Type | Description |
---|---|
String |
GetMaterialArray(CachedMaterial[])
Declaration
public static Material[] GetMaterialArray(CachedMaterial[] cachedMaterials)
Parameters
Type | Name | Description |
---|---|---|
CachedMaterial[] | cachedMaterials |
Returns
Type | Description |
---|---|
Material[] |
GetSpawnParentTransform()
Gets the most appropriate parent transform based on player context for a freely spawned object. Buildings, exteriors, and dungeons all have different parents.
Declaration
public static Transform GetSpawnParentTransform()
Returns
Type | Description |
---|---|
Transform | Parent transform. |
GetStaticDoors(ref ModelData, Int32, Int32, Matrix4x4)
Gets static door array from door information stored in model data.
Declaration
public static StaticDoor[] GetStaticDoors(ref ModelData modelData, int blockIndex, int recordIndex, Matrix4x4 buildingMatrix)
Parameters
Type | Name | Description |
---|---|---|
ModelData | modelData | Model data for doors. |
Int32 | blockIndex | Block index for RMB doors. |
Int32 | recordIndex | Record index of interior. |
Matrix4x4 | buildingMatrix | Individual building matrix. |
Returns
Type | Description |
---|---|
StaticDoor[] | Array of doors in this model data. |
InstantiatePrefab(GameObject, String, Transform, Vector3)
Instantiate a GameObject from prefab.
Declaration
public static GameObject InstantiatePrefab(GameObject prefab, string name, Transform parent, Vector3 position)
Parameters
Type | Name | Description |
---|---|---|
GameObject | prefab | The source GameObject prefab to clone. |
String | name | Optional name to set. Use string.Empty for default. |
Transform | parent | Optional parent to set. Use null for default. |
Vector3 | position | Optional position to set. Use Vector3.zero for default. |
Returns
Type | Description |
---|---|
GameObject | GameObject. |
IsStaticGeometry(GameObject)
Declaration
public static bool IsStaticGeometry(GameObject go)
Parameters
Type | Name | Description |
---|---|---|
GameObject | go |
Returns
Type | Description |
---|---|
Boolean |
QuaternionFromMatrix(Matrix4x4)
Declaration
public static Quaternion QuaternionFromMatrix(Matrix4x4 m)
Parameters
Type | Name | Description |
---|---|---|
Matrix4x4 | m |
Returns
Type | Description |
---|---|
Quaternion |
RemoveLootContainer(DaggerfallLoot)
Destroys/Disables a loot container. Ignores unsupported or persistent container types. Custom drop containers will be destroyed from world. Fixed containers will be disabled so their empty state continues to be serialized.
Declaration
public static void RemoveLootContainer(DaggerfallLoot loot)
Parameters
Type | Name | Description |
---|---|---|
DaggerfallLoot | loot | DaggerfallLoot. |
TagStaticGeometry(GameObject)
Declaration
public static void TagStaticGeometry(GameObject go)
Parameters
Type | Name | Description |
---|---|---|
GameObject | go |