// Construit un joueur dans le WorldState passé en paramètre, le place // dans la cellule appropriée si possible et renvoie une référence si tout s'est bien passé. static public Entity BuildPlayer(WorldState.WorldState world, uint ID, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot, float size, float height) { Debugger.Log("Building entity ID " + ID); Entity newEntity = EntitiesManager.GetEntityFromID(ID); if (!newEntity.Destroyed) // Cet ID est déjà prit par une entité en vie ! { return(null); } newEntity.Destroyed = false; // Destruction des components existants newEntity.Reset(); // Assignation du WorldState à l'entité newEntity.SetWorldState(world); // Placement de l'entité sur une cellule. CellSystem cellSystem = world.GetData <CellSystem>(); if (cellSystem != null) { Cell cell = cellSystem.GetCellFromPosition(pos.z, pos.x); if (cell != null) { cell.AddEntity(newEntity); } newEntity.AddComponent(typeof(EntitySynchroniserComponent)); newEntity.AddComponent(typeof(EntityMover)); newEntity.AddComponent(typeof(SpellComponent)); newEntity.AddComponent(typeof(HumorsComponent)); SerializableVector3 newPos = new SerializableVector3(pos.x, pos.y + size, pos.z); newEntity.Position = newPos; newEntity.Rotation = rot; newEntity.Height = height; newEntity.Size = size; return(newEntity); } // Si ce code est atteint, c'est qu'il y a eu un problème lors de la création de l'entité. return(null); }
static public Entity BuildEntity(WorldState.WorldState world, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot, float size, float height) { return(BuildEntity(world, EntitiesManager.GetNextID(), pos, rot, size, height)); }