void Update() { // Create new foe list when changed in editor if (FoeType != MobileTypes.None && FoeType != lastFoeType && SpawnCount > 0) { DestroyOldFoeGameObjects(pendingFoeGameObjects); SetFoeGameObjects(GameObjectHelper.CreateFoeGameObjects(Vector3.zero, FoeType, SpawnCount, alliedToPlayer: AlliedToPlayer)); lastFoeType = FoeType; } // Do nothing if no spawns or we are done spawning if (pendingFoeGameObjects == null || !spawnInProgress) { return; } // Clear pending foes if all have been spawned if (spawnInProgress && pendingFoesSpawned >= pendingFoeGameObjects.Length) { spawnInProgress = false; Destroy(gameObject); return; } // Try placing foes near player PlaceFoeFreely(pendingFoeGameObjects, MinDistance, MaxDistance); if (spawnInProgress) { GameManager.Instance.RaiseOnEncounterEvent(); } }
void Update() { // Create new foe list when changed in editor if (FoeType != MobileTypes.None && FoeType != lastFoeType && SpawnCount > 0) { DestroyOldFoeGameObjects(pendingFoeGameObjects); SetFoeGameObjects(GameObjectHelper.CreateFoeGameObjects(Vector3.zero, FoeType, SpawnCount, alliedToPlayer: AlliedToPlayer)); lastFoeType = FoeType; } // Do nothing if no spawns or we are done spawning if (pendingFoeGameObjects == null || !spawnInProgress) { return; } // Clear pending foes if all have been spawned if (spawnInProgress && pendingFoesSpawned >= pendingFoeGameObjects.Length) { spawnInProgress = false; Destroy(gameObject); return; } // Try placing foes near player PlaceFoeFreely(pendingFoeGameObjects, MinDistance, MaxDistance); // Keep breaking rest if spawn in progress if (spawnInProgress && DaggerfallUI.Instance.UserInterfaceManager.TopWindow is DaggerfallRestWindow) { (DaggerfallUI.Instance.UserInterfaceManager.TopWindow as DaggerfallRestWindow).AbortRestForEnemySpawn(); } }
void CreatePendingFoeSpawn() { // Get the Foe resource Foe foe = ParentQuest.GetFoe(foeSymbol); if (foe == null) { SetComplete(); throw new Exception(string.Format("create foe could not find Foe with symbol name {0}", Symbol.Name)); } // Get foe GameObjects pendingFoeGameObjects = GameObjectHelper.CreateFoeGameObjects(Vector3.zero, foe.FoeType, foe.SpawnCount, MobileReactions.Hostile, foe); if (pendingFoeGameObjects == null || pendingFoeGameObjects.Length != foe.SpawnCount) { SetComplete(); throw new Exception(string.Format("create foe attempted to create {0}x{1} GameObjects and failed.", foe.SpawnCount, Symbol.Name)); } // Initiate deployment process // Usually the foe will spawn immediately but can take longer depending on available placement space // This process ensures these foes have all been deployed before starting next cycle spawnInProgress = true; pendingFoesSpawned = 0; }