private void ProcessChunks(List <Chunk> chunksToProcess)
    {
        switch (workState.workState)
        {
        case WorkState.FILL:
            VoxelDataController.GenerateDataForChunks(chunksToProcess);
            break;

        case WorkState.MESH:
            VoxelDataController.GenerateMeshForChunks(chunksToProcess);
            break;
        }
    }
Exemplo n.º 2
0
        public static IVoxelDataController CreateVoxelDataController(MapRoot map, Coordinate coordinate, int type, int playerIndex, Dictionary <int, VoxelAbilities>[] allAbilities)
        {
            IVoxelDataController dataController = new VoxelDataController(map, coordinate, type, playerIndex, allAbilities);

            return(dataController);
        }
Exemplo n.º 3
0
        private bool TryToMove(bool checkTarget, PathFinderTask task, Coordinate from, Coordinate next, out Coordinate result, out VoxelData resultData)
        {
            resultData = null;

            MapCell cell = task.Map.Get(next.Row, next.Col, next.Weight);

            int type   = task.ControlledData.Type;
            int weight = task.ControlledData.Weight;
            int height = task.ControlledData.Height;

            MapCell targetCell;

            if (checkTarget)
            {
                VoxelData targetData = cell.GetById(task.TargetId);
                if (targetData != null)
                {
                    next.Altitude = targetData.Altitude;
                    CmdResultCode canMove = VoxelDataController.CanMove(task.ControlledData, task.Abilities, task.Map, task.MapSize, from, next, false, false, false, out targetCell);
                    if (canMove == CmdResultCode.Success)
                    {
                        resultData = targetData;
                        result     = next;
                        return(true);
                    }
                }
            }

            //Change altitude if failed with target coordinate
            VoxelData target;
            VoxelData beneath = cell.GetDefaultTargetFor(type, weight, task.PlayerIndex, false, out target);

            if (beneath == null)
            {
                result = from;
                return(false);
            }

            // This will allow bomb movement
            bool isLastStep = task.Waypoints[task.Waypoints.Length - 1].MapPos == next.MapPos;

            if (isLastStep)
            {
                //Try target coordinate first
                next = task.Waypoints[task.Waypoints.Length - 1];

                //last step is param false -> force CanMove to check next coordinate as is
                CmdResultCode canMove = VoxelDataController.CanMove(task.ControlledData, task.Abilities, task.Map, task.MapSize, from, next, false, false, false, out targetCell);
                if (canMove == CmdResultCode.Success)
                {
                    result = next;
                    return(true);
                }
            }

            if (target != beneath) //this will allow bombs to move over spawners
            {
                if (!isLastStep && target != null && !(target.IsCollapsableBy(type, weight) || target.IsAttackableBy(task.ControlledData)))
                {
                    result = from;
                    return(false);
                }
            }

            next.Altitude = beneath.Altitude + beneath.Height;

            //last step param is false -> force CanMove to check next coordinate as is
            CmdResultCode canMoveResult = VoxelDataController.CanMove(task.ControlledData, task.Abilities, task.Map, task.MapSize, from, next, false, false, false, out targetCell);

            if (canMoveResult != CmdResultCode.Success)
            {
                result = from;
                return(false);
            }

            result = next;
            return(true);
        }