Esempio n. 1
0
        public void RemoveActor(Actor actor)
        {
            if (!cells.TryGetValue(WorldCell.GetCoord(gridCoordinates, actor.Position.Offset), out WorldCell cell))
            {
                return;
            }

            cell.RemoveActor(actor);
        }
Esempio n. 2
0
        public void RelocateActor(Actor actor, Vector3 newPosition)
        {
            Vector2G curCellCoordinates = WorldCell.GetCoord(gridCoordinates, actor.Position.Offset);
            Vector2G newCellCoordinates = WorldCell.GetCoord(gridCoordinates, newPosition);

            if (curCellCoordinates != newCellCoordinates)
            {
                if (!cells.TryGetValue(curCellCoordinates, out WorldCell curCell))
                {
                    return;
                }

                if (!cells.TryGetValue(newCellCoordinates, out WorldCell newCell))
                {
                    return;
                }

                curCell.RemoveActor(actor);
                newCell.AddActor(actor);
            }
        }