public void Initial_cell_is_created() { CellSystem cellSystem = World.Active.GetOrCreateSystem <CellSystem>(); Entity currentCellEntity; bool currentCellExists = cellSystem.TryGetSector(cellSystem.currentCellIndex, out currentCellEntity); Assert.IsTrue(currentCellExists); }
Entity CurrentCellEntity() { CellSystem cellSystem = World.Active.GetOrCreateSystem <CellSystem>(); Entity currentCellEntity; cellSystem.TryGetSector(cellSystem.currentCellIndex, out currentCellEntity); return(currentCellEntity); }
// Construit une entité dans le WorldState passé en paramètre, la place // dans la cellule appropriée si possible et renvoi une référence si tout s'est bien passé. public Entity BuildEntity(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); if (World == null) { Debugger.Log("ERREUR : Pas de worldstate !", UnityEngine.Color.red); } // 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); } else { Debugger.Log("ERREUR : Pas de Cell trouvée lors de la création de l'entité " + ID); } } else { Debugger.Log("ERREUR : Pas de CellSystem lors de la création de l'entité " + ID); } newEntity.AddComponent(typeof(EntitySynchroniserComponent)); newEntity.AddComponent(typeof(EntityMover)); newEntity.Position = pos; newEntity.Rotation = rot; newEntity.Height = height; newEntity.Size = size; // Appel du callback if (OnEntityCreated != null) { OnEntityCreated(newEntity); } return(newEntity); }
protected override void OnCreate() { entityManager = World.Active.EntityManager; playerSystem = World.Active.GetOrCreateSystem <PlayerEntitySystem>(); cellSystem = World.Active.GetOrCreateSystem <CellSystem>(); monoBehaviour = GameObject.FindObjectOfType <DebugMonoBehaviour>(); debugWorley = TerrainSettings.CellWorley(); topologyUtil = new TopologyUtil().Construct(); worleyCurrentMarker = CreateCube(float3.zero, new float4(0, 1, 0, 1)); worleyAdjacentMarker = CreateCube(float3.zero, new float4(0, 0, 1, 1)); }
protected override void OnCreate() { entityManager = World.Active.EntityManager; cellSystem = World.Active.GetOrCreateSystem <CellSystem>(); topologyUtil = new TopologyUtil().Construct(); EntityQueryDesc sectorQuery = new EntityQueryDesc { All = new ComponentType[] { typeof(Tags.TerrainEntity), typeof(CellSystem.AdjacentCell), typeof(CellSystem.SectorCell) }, None = new ComponentType[] { typeof(TypeComponent) } }; sectorGroup = GetEntityQuery(sectorQuery); }
protected override void OnCreate() { entityManager = World.Active.EntityManager; cellSystem = World.Active.GetOrCreateSystem <CellSystem>(); topologyUtil = new TopologyUtil().Construct(); EntityQueryDesc topologyQuery = new EntityQueryDesc { All = new ComponentType[] { typeof(WorleyNoise.PointData), typeof(SectorSystem.MasterCell) }, None = new ComponentType[] { typeof(Height) } }; topologyGroup = GetEntityQuery(topologyQuery); }
// 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); }
public void Adjacent_cells_are_created() { CellSystem cellSystem = World.Active.GetOrCreateSystem <CellSystem>(); DynamicBuffer <CellSystem.AdjacentCell> adjacentCells = World.Active.EntityManager.GetBuffer <CellSystem.AdjacentCell>(CurrentCellEntity()); bool noCellsMissing = false; for (int i = 0; i < adjacentCells.Length; i++) { Entity adjacentCellEntity; if (!cellSystem.TryGetSector(adjacentCells[i].index, out adjacentCellEntity)) { noCellsMissing = false; break; } else { noCellsMissing = true; } } Assert.IsTrue(noCellsMissing); }
protected override void OnCreate() { entityManager = World.Active.EntityManager; cellSystem = World.Active.GetOrCreateSystem <CellSystem>(); squareWidth = TerrainSettings.mapSquareWidth; }
// Start is called before the first frame update void Start() { cellSystem = GameObject.Find("System").transform.Find("Cell System").GetComponent <CellSystem>(); wagonSystem = GameObject.Find("Wagon").GetComponent <WagonSystem>(); }