コード例 #1
0
ファイル: Client.cs プロジェクト: Phlarfl/TSML
        private Voxel AddClick(WorldMaster master, Maker maker, PacketAddVoxel packet)
        {
            int dstHeight = packet.DestinationHeight;
            var voxelType = packet.VoxelType;
            var vert      = new Vert()
            {
                angle  = packet.VertAngle,
                hexPos = packet.HexPos
            };

            if (!vert.full)
            {
                vert = master.grid.GetVertOrIterate(packet.HexPos, null);
            }

            if (!vert.full || !master.graph.IsCoordinateAllowed(vert.hexPos))
            {
                return(null);
            }

            maker.BeginNewAction();
            if (dstHeight == 0)
            {
                voxelType = VoxelType.Ground;
            }

            var result = master.graph.AddVoxel(vert.hexPos, (byte)dstHeight, voxelType, true);

            maker.AddAction(vert.hexPos, (byte)dstHeight, VoxelType.Empty, voxelType);
            maker.EndAction();
            return(result);
        }
コード例 #2
0
ファイル: Client.cs プロジェクト: Phlarfl/TSML
        private Voxel RemoveClick(WorldMaster master, Maker maker, PacketRemoveVoxel packet)
        {
            maker.BeginNewAction();
            Voxel result = null;

            foreach (var voxel in UnityEngine.Object.FindObjectsOfType <Voxel>())
            {
                if (voxel.transform.position.Equals(packet.VoxelPosition))
                {
                    result = voxel;
                    break;
                }
            }
            maker.AddAction(packet.HexPos, result.height, result.type, VoxelType.Empty);
            master.graph.RemoveVoxel(result);
            maker.EndAction();
            return(result);
        }