public static void AttachAnimalToNetwork(AnimalSpawnZone zone, GameObject gameObject) { AnimalDespawner animalDespawner = gameObject.GetComponent <AnimalDespawner>(); if (!animalDespawner) { animalDespawner = gameObject.AddComponent <AnimalDespawner>(); } animalDespawner.SpawnedFromZone = zone; animalDespawner.DespawnRadius = 70f; animalDespawner.UpdateRate = 1f; if (BoltNetwork.isServer) { BoltEntity boltEntity = gameObject.AddComponent <BoltEntity>(); BoltEntity component = gameObject.GetComponent <CoopAnimalServer>().NetworkContainerPrefab.GetComponent <BoltEntity>(); using (BoltEntitySettingsModifier boltEntitySettingsModifier = component.ModifySettings()) { using (BoltEntitySettingsModifier boltEntitySettingsModifier2 = boltEntity.ModifySettings()) { boltEntitySettingsModifier2.clientPredicted = boltEntitySettingsModifier.clientPredicted; boltEntitySettingsModifier2.persistThroughSceneLoads = boltEntitySettingsModifier.persistThroughSceneLoads; boltEntitySettingsModifier2.allowInstantiateOnClient = boltEntitySettingsModifier.allowInstantiateOnClient; boltEntitySettingsModifier2.prefabId = boltEntitySettingsModifier.prefabId; boltEntitySettingsModifier2.updateRate = boltEntitySettingsModifier.updateRate; boltEntitySettingsModifier2.serializerId = boltEntitySettingsModifier.serializerId; } } BoltNetwork.Attach(gameObject); } }
private void Die() { AnimalDespawner component = base.GetComponent <AnimalDespawner>(); if (component && component.SpawnedFromZone) { component.SpawnedFromZone.MaxAnimalsTotal--; component.SpawnedFromZone.AddSpawnBackTimes.Enqueue(Time.time + component.SpawnedFromZone.DelayAfterKillTime * GameSettings.Animals.RespawnDelayRatio); } if (this.spawnFunctions.lizard) { EventRegistry.Animal.Publish(TfEvent.KilledLizard, base.gameObject); this.scene.maxLizardAmount--; } if (this.spawnFunctions.rabbit) { EventRegistry.Animal.Publish(TfEvent.KilledRabbit, base.gameObject); this.scene.maxRabbitAmount -= 2; } if (this.spawnFunctions.turtle) { EventRegistry.Animal.Publish(TfEvent.KilledTurtle, base.gameObject); this.scene.maxTurtleAmount--; if (this.spawnFunctions.controller) { this.spawnFunctions.controller.addToSpawnDelay(120f); } } if (this.spawnFunctions.tortoise) { EventRegistry.Animal.Publish(TfEvent.KilledTurtle, base.gameObject); this.scene.maxTortoiseAmount--; } if (this.spawnFunctions.raccoon) { EventRegistry.Animal.Publish(TfEvent.KilledRaccoon, base.gameObject); this.scene.maxRaccoonAmount--; } if (this.spawnFunctions.deer) { EventRegistry.Animal.Publish(TfEvent.KilledDeer, base.gameObject); this.scene.maxDeerAmount--; } base.CancelInvoke("HitPoison"); base.CancelInvoke("disablePoison"); base.CancelInvoke("HitFire"); if (this.Trapped && this.Trap) { this.Trap.SendMessageUpwards("setAnimalAsDead", SendMessageOptions.DontRequireReceiver); } this.Trap = null; this.Trapped = false; if (!this.spawnFunctions.deer && !this.Fire) { this.PlayEvent(this.DieEvent); } this.ai.goRagdoll(); this.resetHealth(); }
private void Die() { AnimalDespawner component = base.GetComponent <AnimalDespawner>(); if (component && component.SpawnedFromZone) { component.SpawnedFromZone.MaxAnimalsTotal--; component.SpawnedFromZone.AddSpawnBackTimes.Enqueue(Time.time + component.SpawnedFromZone.DelayAfterKillTime); } if (this.spawnFunctions.lizard) { GameStats.LizardKilled.Invoke(); this.scene.maxLizardAmount--; } if (this.spawnFunctions.rabbit) { GameStats.RabbitKilled.Invoke(); this.scene.maxRabbitAmount -= 2; } if (this.spawnFunctions.turtle) { GameStats.TurtleKilled.Invoke(); this.scene.maxTurtleAmount--; if (this.spawnFunctions.controller) { this.spawnFunctions.controller.addToSpawnDelay(120f); } } if (this.spawnFunctions.tortoise) { GameStats.TurtleKilled.Invoke(); this.scene.maxTortoiseAmount--; } if (this.spawnFunctions.raccoon) { GameStats.RaccoonKilled.Invoke(); this.scene.maxRaccoonAmount--; } if (this.spawnFunctions.deer) { GameStats.DeerKilled.Invoke(); this.scene.maxDeerAmount--; } if (this.Fire) { if (this.Fire.activeSelf) { this.ai.goBurntRagdoll(); } this.Fire.SetActive(false); } base.CancelInvoke("HitPoison"); base.CancelInvoke("disablePoison"); base.CancelInvoke("HitFire"); if (!this.spawnFunctions.deer && !this.Fire) { this.PlayEvent(this.DieEvent); } this.ai.goRagdoll(); this.resetHealth(); }