Exemple #1
0
        private void AddEntity(GridAction action)
        {
            Debug.Assert(action.Entity.Map == null);

            GetGrid(action.Position).AddEntity(action);

            uint guid = entityCounter.Dequeue();

            entities.Add(guid, action.Entity);
            action.Entity.OnAddToMap(this, guid, action.Position);

            log.Trace($"Added entity {action.Entity.Guid} to map {Entry.Id}.");
        }
Exemple #2
0
        public void RelocateEntity(GridAction action)
        {
            MapCell oldCell = GetCell(action.Entity.Position);
            MapCell newCell = GetCell(action.Position);

            // new position is in the same cell, no need to transfer entity to another cell
            if (newCell.Vector == oldCell.Vector)
            {
                return;
            }

            oldCell.RemoveEntity(action.Entity);
            newCell.AddEntity(action.Entity);
        }
Exemple #3
0
        private void RelocateEntity(GridAction action)
        {
            Debug.Assert(action.Entity.Map != null);

            MapGrid newGrid = GetGrid(action.Position);
            MapGrid oldGrid = GetGrid(action.Entity.Position);

            if (newGrid.Vector != oldGrid.Vector)
            {
                oldGrid.RemoveEntity(action.Entity);
                newGrid.AddEntity(action);
            }
            else
            {
                oldGrid.RelocateEntity(action);
            }

            action.Entity.OnRelocate(action.Position);
        }
Exemple #4
0
 public void AddEntity(GridAction action)
 {
     GetCell(action.Position).AddEntity(action.Entity);
 }