Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Assets/Resources/defaults.ini.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ DungeonShadowDistance=20.0
InteriorShadowDistance=30.0
ExteriorShadowDistance=90.0
EnableTextureArrays=True
EnableObjectCulling=True
RandomDungeonTextures=0

[Effects]
Expand Down
75 changes: 75 additions & 0 deletions Assets/Scenes/DaggerfallUnityGame.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2894,3 +2894,78 @@ PrefabInstance:
objectReference: {fileID: 1769263313}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: bbe5e15c9f6b3dc47bb9485a437750a0, type: 3}
--- !u!114 &69466200359737372
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1834928754549345153}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 43fe9d3db5f70f24bb00284402a4d97e, type: 3}
m_Name:
m_EditorClassIdentifier:
culledObjectsParent: {fileID: 1269490794079082448}
--- !u!4 &357226078190250312
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1834928754549345153}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 14.787919, y: 27.745857, z: 29.176554}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2109761705362116671}
m_Father: {fileID: 0}
m_RootOrder: 23
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1269490794079082448
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2109761705362116671}
m_Layer: 0
m_Name: CulledObjects
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1834928754549345153
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 357226078190250312}
- component: {fileID: 69466200359737372}
m_Layer: 0
m_Name: CulledGameObjectManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2109761705362116671
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1269490794079082448}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 357226078190250312}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
99 changes: 58 additions & 41 deletions Assets/Scripts/ActiveGameObjectDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public GameObjectCache(string name)

// Returns all the active GameObjects in the cache
// If a system calls SetActive(false) on an object without destroying it, it will not be returned here
public IEnumerable<GameObject> GetActiveObjects()
public IEnumerable<GameObject> GetActiveObjects(bool includeInactive = false)
{
cacheLock.EnterReadLock();
try
Expand All @@ -42,7 +42,7 @@ public IEnumerable<GameObject> GetActiveObjects()
// A null check on a GameObject does more than C#'s reference check,
// it also checks if the object has been destroyed
// Like Object.FindObjectsOfType, we should only include active objects
if (activeObject != null && activeObject.activeInHierarchy)
if (activeObject != null && (includeInactive || activeObject.activeInHierarchy))
gameObjects.Add(activeObject);
}
}
Expand All @@ -57,12 +57,12 @@ public IEnumerable<GameObject> GetActiveObjects()

// Returns all the enabled components of active GameObjects in the cache
// If a system calls SetActive(false) on an object without destroying it, it will not be returned here
public IEnumerable<T> GetActiveComponents<T>() where T : MonoBehaviour
public IEnumerable<T> GetActiveComponents<T>(bool includeInactive = false) where T : MonoBehaviour
{
foreach (GameObject gameObject in GetActiveObjects())
foreach (GameObject gameObject in GetActiveObjects(includeInactive))
{
var t = gameObject.GetComponent<T>();
if (t != null && t.isActiveAndEnabled)
if (t != null && (includeInactive || t.isActiveAndEnabled))
yield return t;
}
}
Expand Down Expand Up @@ -201,35 +201,51 @@ public static class ActiveGameObjectDatabase
static GameObjectCache staticNpcCache = new GameObjectCache("Static NPC");
static GameObjectCache actionDoorCache = new GameObjectCache("Action Door");
static GameObjectCache rdbCache = new GameObjectCache("RDB");
static GameObjectCache billboardCache = new GameObjectCache("Billboard");

public static IEnumerable<GameObject> GetActiveBillboardObjects(bool includeInactive = false)
{
return billboardCache.GetActiveObjects(includeInactive);
}

public static IEnumerable<DaggerfallBillboard> GetActiveBillboards(bool includeInactive = false)
{
return billboardCache.GetActiveComponents<DaggerfallBillboard>(includeInactive);
}

public static void RegisterBillboard(GameObject billboard)
{
billboardCache.AddObject(billboard);
}

// Gets all the active enemy GameObjects. Must be registered as Enemy (see below)
public static IEnumerable<GameObject> GetActiveEnemyObjects()
public static IEnumerable<GameObject> GetActiveEnemyObjects(bool includeInactive = false)
{
return enemyCache.GetActiveObjects();
return enemyCache.GetActiveObjects(includeInactive);
}

// Gets all the enabled DaggerfallEntityBehaviour components from active registered enemies
public static IEnumerable<DaggerfallEntityBehaviour> GetActiveEnemyBehaviours()
public static IEnumerable<DaggerfallEntityBehaviour> GetActiveEnemyBehaviours(bool includeInactive = false)
{
return enemyCache.GetActiveComponents<DaggerfallEntityBehaviour>();
return enemyCache.GetActiveComponents<DaggerfallEntityBehaviour>(includeInactive);
}

// Gets all the enabled DaggerfallEnemy components from active registered enemies
public static IEnumerable<DaggerfallEnemy> GetActiveEnemyEntities()
public static IEnumerable<DaggerfallEnemy> GetActiveEnemyEntities(bool includeInactive = false)
{
return enemyCache.GetActiveComponents<DaggerfallEnemy>();
return enemyCache.GetActiveComponents<DaggerfallEnemy>(includeInactive);
}

// Gets all the enabled QuestResourceBehaviour components from active registered enemies
public static IEnumerable<QuestResourceBehaviour> GetActiveEnemyQuestResourceBehaviours()
public static IEnumerable<QuestResourceBehaviour> GetActiveEnemyQuestResourceBehaviours(bool includeInactive = false)
{
return enemyCache.GetActiveComponents<QuestResourceBehaviour>();
return enemyCache.GetActiveComponents<QuestResourceBehaviour>(includeInactive);
}

// Gets all the enabled EnemyMotor components from active registered enemies
public static IEnumerable<EnemyMotor> GetActiveEnemyMotors()
public static IEnumerable<EnemyMotor> GetActiveEnemyMotors(bool includeInactive = false)
{
return enemyCache.GetActiveComponents<EnemyMotor>();
return enemyCache.GetActiveComponents<EnemyMotor>(includeInactive);
}

// Registers an enemy (monster or class) to the enemy cache. Does not have to be active
Expand All @@ -239,15 +255,15 @@ public static void RegisterEnemy(GameObject enemy)
}

// Gets all the active Civilian Mobile GameObjects. Must be registered as Civilian Mobile (see below)
public static IEnumerable<GameObject> GetActiveCivilianMobileObjects()
public static IEnumerable<GameObject> GetActiveCivilianMobileObjects(bool includeInactive = false)
{
return civilianCache.GetActiveObjects();
return civilianCache.GetActiveObjects(includeInactive);
}

// Gets all the enabled DaggerfallEntityBehaviour components from active registered Civilian Mobiles
public static IEnumerable<DaggerfallEntityBehaviour> GetActiveCivilianMobileBehaviours()
public static IEnumerable<DaggerfallEntityBehaviour> GetActiveCivilianMobileBehaviours(bool includeInactive = false)
{
return civilianCache.GetActiveComponents<DaggerfallEntityBehaviour>();
return civilianCache.GetActiveComponents<DaggerfallEntityBehaviour>(includeInactive);
}

// Registers a mobile civilian NPC to the civilian cache. Does not have to be active
Expand All @@ -257,15 +273,15 @@ public static void RegisterCivilianMobile(GameObject civilian)
}

// Gets all the active loot GameObjects. Must be registered as Loot (see below)
public static IEnumerable<GameObject> GetActiveLootObjects()
public static IEnumerable<GameObject> GetActiveLootObjects(bool includeInactive = false)
{
return lootCache.GetActiveObjects();
return lootCache.GetActiveObjects(includeInactive);
}

// Gets all the enabled DaggerfallLoot components from active registered loot
public static IEnumerable<DaggerfallLoot> GetActiveLoot()
public static IEnumerable<DaggerfallLoot> GetActiveLoot(bool includeInactive = false)
{
return lootCache.GetActiveComponents<DaggerfallLoot>();
return lootCache.GetActiveComponents<DaggerfallLoot>(includeInactive);
}

// Registers a loot object to the loot cache. Does not have to be active
Expand All @@ -275,15 +291,15 @@ public static void RegisterLoot(GameObject loot)
}

// Gets all the active Foe Spawner GameObjects. Must be registered as Foe Spawner (see below)
public static IEnumerable<GameObject> GetActiveFoeSpawnerObjects()
public static IEnumerable<GameObject> GetActiveFoeSpawnerObjects(bool includeInactive = false)
{
return foeSpawnerCache.GetActiveObjects();
return foeSpawnerCache.GetActiveObjects(includeInactive);
}

// Gets all the enabled FoeSpawner components from active registered foe spawners
public static IEnumerable<FoeSpawner> GetActiveFoeSpawners()
public static IEnumerable<FoeSpawner> GetActiveFoeSpawners(bool includeInactive = false)
{
return foeSpawnerCache.GetActiveComponents<FoeSpawner>();
return foeSpawnerCache.GetActiveComponents<FoeSpawner>(includeInactive);
}

// Registers a foe spawner object to the foe spawner cache. Does not have to be active
Expand All @@ -293,21 +309,21 @@ public static void RegisterFoeSpawner(GameObject foeSpawner)
}

// Gets all the active Static NPC GameObjects. Must be registered as a Static NPC (see below)
public static IEnumerable<GameObject> GetActiveStaticNPCObjects()
public static IEnumerable<GameObject> GetActiveStaticNPCObjects(bool includeInactive = false)
{
return staticNpcCache.GetActiveObjects();
return staticNpcCache.GetActiveObjects(includeInactive);
}

// Gets all the enabled StaticNPC components from active registered static NPCs
public static IEnumerable<StaticNPC> GetActiveStaticNPCs()
public static IEnumerable<StaticNPC> GetActiveStaticNPCs(bool includeInactive = false)
{
return staticNpcCache.GetActiveComponents<StaticNPC>();
return staticNpcCache.GetActiveComponents<StaticNPC>(includeInactive);
}

// Gets all the enabled QuestResourceBehaviour components from active registered static NPCs
public static IEnumerable<QuestResourceBehaviour> GetActiveStaticNPCQuestResourceBehaviours()
public static IEnumerable<QuestResourceBehaviour> GetActiveStaticNPCQuestResourceBehaviours(bool includeInactive = false)
{
return staticNpcCache.GetActiveComponents<QuestResourceBehaviour>();
return staticNpcCache.GetActiveComponents<QuestResourceBehaviour>(includeInactive);
}

// Registers a static NPC object to the Static NPC cache. Does not have to be active
Expand All @@ -317,15 +333,15 @@ public static void RegisterStaticNPC(GameObject staticNPC)
}

// Gets all the active Action Door GameObjects. Must be registered as Action Door (see below)
public static IEnumerable<GameObject> GetActiveActionDoorObjects()
public static IEnumerable<GameObject> GetActiveActionDoorObjects(bool includeInactive = false)
{
return actionDoorCache.GetActiveObjects();
return actionDoorCache.GetActiveObjects(includeInactive);
}

// Gets all the enabled DaggerfallActionDoor components from active registered doors
public static IEnumerable<DaggerfallActionDoor> GetActiveActionDoors()
public static IEnumerable<DaggerfallActionDoor> GetActiveActionDoors(bool includeInactive = false)
{
return actionDoorCache.GetActiveComponents<DaggerfallActionDoor>();
return actionDoorCache.GetActiveComponents<DaggerfallActionDoor>(includeInactive);
}

// Registers an Action Door object to the Action Door cache. Does not have to be active
Expand All @@ -336,15 +352,15 @@ public static void RegisterActionDoor(GameObject door)
}

// Gets all the active RDB GameObjects. Must be registered as RDB (see below)
public static IEnumerable<GameObject> GetActiveRDBObjects()
public static IEnumerable<GameObject> GetActiveRDBObjects(bool includeInactive = false)
{
return rdbCache.GetActiveObjects();
return rdbCache.GetActiveObjects(includeInactive);
}

// Gets all the enabled DaggerfallStaticDoors components from active registered RDBs
public static IEnumerable<DaggerfallStaticDoors> GetActiveRDBStaticDoors()
public static IEnumerable<DaggerfallStaticDoors> GetActiveRDBStaticDoors(bool includeInactive = false)
{
return rdbCache.GetActiveComponents<DaggerfallStaticDoors>();
return rdbCache.GetActiveComponents<DaggerfallStaticDoors>(includeInactive);
}

// Registers a Daggerfall dungeon block "RDB" game object to the RDB cache. Does not have to be active
Expand All @@ -363,6 +379,7 @@ public static IEnumerable<string> GetCacheDebugLines()
yield return staticNpcCache.GetDebugString();
yield return actionDoorCache.GetDebugString();
yield return rdbCache.GetDebugString();
yield return billboardCache.GetDebugString();
}
}
}
Loading