/// <summary> /// Exécutée dès qu'une entité est instanciée dans ce match. /// </summary> void OnEntitySpawned(BloodAndBileEngine.Entity entity) { entity.RegisterOnEntityDestroyedCallback(OnEntityDestroyed); LivingEntities.Add(entity); // Envoi de la commande aux clients ModuleMatch.SendCommandToPlayers("CreateEntity", entity.ID); }
void OnEntityDestroyed(BloodAndBileEngine.Entity entity) { BloodAndBileEngine.Debugger.Log("EntitiesStateModule : Entité " + entity.ID + " détruite !"); LivingEntities.Remove(entity); ModuleMatch.SendCommandToPlayers("KillEntity", entity.ID); PlayerToEntityLink destroyedLink = null; foreach (PlayerToEntityLink link in PlayerControlledEntities) { if (link.Entity == entity) { destroyedLink = link; } } if (destroyedLink != null) { BloodAndBileEngine.Debugger.Log("Destruction de l'entité joueur " + entity.ID, UnityEngine.Color.yellow); PlayerControlledEntities.Remove(destroyedLink); } }