Exemplo n.º 1
0
        private bool CanPassThroughDiagonally(int x, int y, byte elevation, LayoutBlockPassage diagonalPassage,
                                              BlocksetBlockBehavior blockedCardinal1, BlocksetBlockBehavior blockedCardinal2, BlocksetBlockBehavior blockedDiagonal)
        {
            // Get the x/y/map of the block
            Map.GetXYMap(x, y, out int outX, out int outY, out Map outMap);
            Map.Layout.Block block = outMap.GetBlock_InBounds(outX, outY);
            // Check occupancy permission
            if ((block.Passage & diagonalPassage) == 0)
            {
                return(false);
            }
            // Check block behaviors
            BlocksetBlockBehavior blockBehavior = block.BlocksetBlock.Behavior;

            if (blockBehavior == blockedCardinal1 || blockBehavior == blockedCardinal2 || blockBehavior == blockedDiagonal)
            {
                return(false);
            }
            // Check if we can pass through objs at the position (only checks current elevation, not the target elevation or any other elevations)
            if (CollidesWithAny_InBounds(outMap, outX, outY, elevation))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
 public Block(int x, int y, EndianBinaryReader r)
 {
     X             = x;
     Y             = y;
     Elevations    = r.ReadByte();
     Passage       = r.ReadEnum <LayoutBlockPassage>();
     BlocksetBlock = Blockset.LoadOrGet(r.ReadInt32()).Blocks[r.ReadInt32()];
 }
Exemplo n.º 3
0
                public Block(Layout parent, EndianBinaryReader r)
                {
                    Parent = parent;

                    Elevations    = r.ReadByte();
                    Passage       = r.ReadEnum <LayoutBlockPassage>();
                    BlocksetBlock = Blockset.LoadOrGet(r.ReadInt32()).Blocks[r.ReadInt32()];
                }
Exemplo n.º 4
0
        // Southwest/Southeast/Northwest/Northeast
        private bool CanMoveTo_Diagonal(int targetX, int targetY, bool allowSurf, LayoutBlockPassage neighbor1Passage, int neighbor1X, int neighbor1Y, LayoutBlockPassage neighbor2Passage, int neighbor2X, int neighbor2Y,
                                        BlocksetBlockBehavior blockedCurrentCardinal1, BlocksetBlockBehavior blockedCurrentCardinal2, BlocksetBlockBehavior blockedCurrentDiagonal,
                                        BlocksetBlockBehavior blockedTargetCardinal1, BlocksetBlockBehavior blockedTargetCardinal2, BlocksetBlockBehavior blockedTargetDiagonal,
                                        BlocksetBlockBehavior blockedNeighbor1, BlocksetBlockBehavior blockedNeighbor2)
        {
            // Current block - return false if we are blocked
            Position p = Pos;

            Map.Layout.Block      curBlock    = Map.GetBlock_InBounds(p.X, p.Y);
            BlocksetBlockBehavior curBehavior = curBlock.BlocksetBlock.Behavior;

            if (curBehavior == blockedCurrentCardinal1 || curBehavior == blockedCurrentCardinal2 || curBehavior == blockedCurrentDiagonal)
            {
                return(false);
            }
            // Target block - return false if we are blocked
            Map.GetXYMap(targetX, targetY, out int targetOutX, out int targetOutY, out Map targetOutMap);
            Map.Layout.Block targetBlock = targetOutMap.GetBlock_InBounds(targetOutX, targetOutY);
            if ((targetBlock.Passage & LayoutBlockPassage.AllowOccupancy) == 0)
            {
                return(false);
            }
            // Check block behaviors
            BlocksetBlockBehavior targetBehavior = targetBlock.BlocksetBlock.Behavior;

            if ((!allowSurf && Overworld.IsSurfable(targetBehavior)) ||
                targetBehavior == blockedTargetCardinal1 || targetBehavior == blockedTargetCardinal2 || targetBehavior == blockedTargetDiagonal)
            {
                return(false);
            }
            // Check elevation
            byte curElevation     = p.Elevation;
            byte targetElevations = targetBlock.Elevations;

            if (!ElevationCheck(curBehavior, targetBehavior, curElevation, targetElevations))
            {
                return(false);
            }
            byte newElevation = Overworld.GetElevationIfMovedTo(curElevation, targetElevations);

            // Check if we can pass through objs at the position
            if (CollidesWithAny_InBounds(targetOutMap, targetOutX, targetOutY, newElevation))
            {
                return(false);
            }
            // Target's neighbors - check if we can pass through them diagonally
            if (!CanPassThroughDiagonally(neighbor1X, neighbor1Y, curElevation, neighbor1Passage, blockedCurrentCardinal1, blockedTargetCardinal2, blockedNeighbor1) ||
                !CanPassThroughDiagonally(neighbor2X, neighbor2Y, curElevation, neighbor2Passage, blockedTargetCardinal1, blockedCurrentCardinal2, blockedNeighbor2))
            {
                return(false);
            }
            return(true);
        }