コード例 #1
1
ファイル: Teleporter.cs プロジェクト: umby24/Hypercube
        public void CreateTeleporter(string name, Vector3S start, Vector3S end, Vector3S dest, byte destLook, byte destRot, HypercubeMap destMap)
        {
            var newtp = new Teleporter {
                Name = name,
                Start = start,
                End = end,
                Dest = dest,
                DestLook = destLook,
                DestRot = destRot,
                DestinationMap = destMap,
            };

            var myTp = _teleporters.Find(o => o.Name == name); // -- Linq is so hacky.. damn.

            if (myTp != null)
                _teleporters.Remove(myTp);

            _teleporters.Add(newtp);

            // -- Save to file as well.
            _porterSettings.SelectGroup(name);
            _porterSettings.Write("StartX", start.X.ToString());
            _porterSettings.Write("StartY", start.Y.ToString());
            _porterSettings.Write("StartZ", start.Z.ToString());
            _porterSettings.Write("EndX", end.X.ToString());
            _porterSettings.Write("EndY", end.Y.ToString());
            _porterSettings.Write("EndZ", end.Z.ToString());
            _porterSettings.Write("DestX", dest.X.ToString());
            _porterSettings.Write("DestY", dest.Y.ToString());
            _porterSettings.Write("DestZ", dest.Z.ToString());
            _porterSettings.Write("DestRot", destRot.ToString());
            _porterSettings.Write("DestLook", destLook.ToString());
            _porterSettings.Write("DestMap", destMap.CWMap.MapName);
            _porterSettings.SaveFile();
        }
コード例 #2
0
        void OnAllPlayersBlockChange_Normal(Player sender, BlockChangeEventArgs args)
        {
            Vector3S v = new Vector3S(args.X, args.Z, args.Y);

            if (store[sender.Level.Name].Contains(v))
            {
                object msg = sender.Level.ExtraData["MessageBlock" + v];
                if (msg != null && msg.GetType() == typeof(string) && ((string)msg).Length > 0)
                {
                    if (((string)msg).StartsWith("c"))
                    {
                        if (removeCommandOnAir && (args.Action == ActionType.Delete || args.Holding == 0))
                        {
                            Remove(sender.Level, v);
                        }
                        else if (protectBlockType)
                        {
                            args.Cancel();
                        }
                    }
                    else
                    {
                        if (removeMessageOnAir && (args.Action == ActionType.Delete || args.Holding == 0))
                        {
                            Remove(sender.Level, v);
                        }
                        else if (protectBlockType)
                        {
                            args.Cancel();
                        }
                    }
                }
            }
        }
コード例 #3
0
        public BotMap(Level l)
        {
            AirMap = new TriBool[l.CWMap.Size.x, l.CWMap.Size.z, l.CWMap.Size.y];//return x + z * Size.x + y * Size.x * Size.z;
            Size   = l.CWMap.Size;
            for (int i = 0; i < l.CWMap.BlockData.Length; i++)
            {
                Vector3S pos = l.IntToPos(i);
                if (isAir(l.GetBlock(i)))
                {
                    AirMap[pos.x, pos.z, pos.y] = true;
                }
                else if (Block.IsOPBlock(l.GetBlock(i)))
                {
                    AirMap[pos.x, pos.z, pos.y] = TriBool.Unknown;
                }
                else
                {
                    AirMap[pos.x, pos.z, pos.y] = false;
                }
            }

            /*for (int x = 0; x < AirMap.GetLength(0); x++) {
             *  for (int z = 0; z < AirMap.GetLength(1); z++) {
             *      for (int y = 0; y < AirMap.GetLength(2); y++) {
             *
             *      }
             *  }
             * }*/
        }
コード例 #4
0
        void CatchBlockTwo(Player sender, BlockChangeEventArgs e)
        {
            e.Cancel();
            sender.OnPlayerBlockChange.Normal -= CatchBlockTwo;

            try {
                BlockInfo raw   = (BlockInfo)sender.ExtraData.GetIfExist <object, object>("Command.Line");
                Vector3S  from  = raw.Pos;
                Vector3S  to    = new Vector3S(e.X, e.Z, e.Y);
                byte      block = raw.Block;

                IEnumerable <Vector3S> path = from.PathTo(to);
                if (sender.Group.MaxBlockChange < path.Count())
                {
                    sender.SendMessage("You are not allowed to change that many blocks");
                    return;
                }
                foreach (var pos in path)
                {
                    if (!sender.Level.IsInBounds(pos))
                    {
                        continue;
                    }
                    BlockQueue.Addblock(sender, (ushort)pos.x, (ushort)pos.y, (ushort)pos.z, block);
                }


                sender.SendMessage(string.Format("Changed {0} blocks in a line", path.Count()));
            }
            catch (Exception er) {
                sender.SendMessage("An Error occurred while trying to make a pretty line");
                Logger.LogError(er);
            }
        }
コード例 #5
0
ファイル: HcMap.cs プロジェクト: umby24/ZBase
        public override string ToString()
        {
            Vector3S mapSize = MapProvider.GetSize();

            return
                ($"{MapProvider.MapName} by {MapProvider.CreatingUser} on {MapProvider.CreatingService}. ({mapSize.X} x {mapSize.Y} x {mapSize.Z})");
        }
コード例 #6
0
ファイル: HcMap.cs プロジェクト: umby24/ZBase
        public void SetSpawn(Vector3S location, byte look, byte rot)
        {
            var spawnLoc = new MinecraftLocation(location, rot, look);

            spawnLoc.SetAsBlockCoords(location);
            MapProvider.SetSpawn(spawnLoc);
        }
コード例 #7
0
        void OnPlayerBigMove_Normal(Player sender, API.Events.MoveEventArgs args)
        {
            string IsFlying = (string)sender.ExtraData["IsFlying"];

            if (IsFlying != null)
            {
                Vector3S lastPos    = (Vector3S)sender.ExtraData["FlyLastPos"];
                Vector3S belowBlock = sender.belowBlock;
                if (IsFlying == "+" && glassesFlatAndMiddle != null)
                {
                    sender.SendReplaceNecessaryBlocksWhere(glassesFlatAndMiddle, lastPos, belowBlock, 0, 20);
                    sender.ExtraData["FlyLastPos"] = belowBlock;
                }
                else if (IsFlying == "water" && fluidCube != null)
                {
                    Vector3S tmp = belowBlock;
                    tmp.y++;
                    sender.SendReplaceNecessaryBlocksWhere(fluidCube, lastPos, tmp, 0, 9);
                    sender.ExtraData["FlyLastPos"] = tmp;
                }
                else
                {
                    sender.SendReplaceNecessaryBlocksWhere(glassesFlat, lastPos, belowBlock, 0, 20);
                    sender.ExtraData["FlyLastPos"] = belowBlock;
                }
            }
        }
コード例 #8
0
        //public void CatchBlock2(Player p, ushort x, ushort z, ushort y, byte NewType, bool placed, object DataPass)
        public void CatchBlock2(Player sender, BlockChangeEventArgs args)
        {
            args.Cancel();
            args.Unregister();
            sender.SendBlockChange(args.X, args.Z, args.Y, sender.Level.GetBlock(args.X, args.Z, args.Y));
            CatchPos cpos = (CatchPos)sender.GetDatapass("CmdMeasure_cpos");
            Vector3S FirstBlock = cpos.FirstBlock;
            ushort   xx, zz, yy;
            int      count = 0;

            for (xx = Math.Min((ushort)(FirstBlock.x), args.X); xx <= Math.Max((ushort)(FirstBlock.x), args.X); ++xx)
            {
                for (zz = Math.Min((ushort)(FirstBlock.z), args.Z); zz <= Math.Max((ushort)(FirstBlock.z), args.Z); ++zz)
                {
                    for (yy = Math.Min((ushort)(FirstBlock.y), args.Y); yy <= Math.Max((ushort)(FirstBlock.y), args.Y); ++yy)
                    {
                        if (cpos.ignore == null || !cpos.ignore.Contains(sender.Level.GetBlock(xx, zz, yy)))
                        {
                            count++;
                        }
                    }
                }
            }
            sender.SendMessage(count + " blocks are between (" + FirstBlock.x + ", " + FirstBlock.z + ", " + FirstBlock.y + ") and (" + args.X + ", " + args.Z + ", " + args.Y + ")");
        }
コード例 #9
0
        public override void Execute(HcMap map, string[] args)
        {
            var sw = new Stopwatch();

            sw.Start();

            Vector3S mapSize = map.GetSize();

            MapSize = mapSize;
            var data = new byte[mapSize.X * mapSize.Y * mapSize.Z];

            for (short x = 0; x < mapSize.X; x++)
            {
                for (short y = 0; y < mapSize.Y; y++)
                {
                    for (short z = 0; z < (mapSize.Z / 2); z++)
                    {
                        data[GetBlockCoords(x, y, z)] = z == (mapSize.Z / 2) - 1 ? _grassBlock : _dirtBlock;
                    }
                }
            }

            map.SetMap(data);

            sw.Stop();
            Chat.SendMapChat($"&cMap created in {sw.Elapsed.TotalSeconds}s.", 0, map);
            map.Resend();
        }
コード例 #10
0
        void OnPlayerMove_Normal(Player sender, MCForge.API.Events.MoveEventArgs args)
        {
            int count = (int)sender.ExtraData["RunCounter"];

            count++;
            sender.ExtraData["RunCounter"] = count;
            if (count % 15 != 0)
            {
                return;
            }
            sender.ExtraData["RunCounter"] = 0;
            Vector3S tmpPos = new Vector3S(args.FromPosition);

            tmpPos.Horizontal = tmpPos.Horizontal.GetMove(320, args.ToPosition.Horizontal);
            if (tmpPos.x < 32 || tmpPos.z < 32 || tmpPos.x > (sender.Level.Size.x - 1) * 32 || tmpPos.z > (sender.Level.Size.z - 1) * 32)
            {
                return;
            }
            Packet pa = new Packet();

            pa.Add(Packet.Types.SendTeleport);
            pa.Add((sbyte)-1);
            pa.Add(tmpPos.x);
            pa.Add((short)(tmpPos.y));
            pa.Add(tmpPos.z);
            pa.Add(sender.Rot);
            sender.oldPos = tmpPos;
            sender.Pos    = tmpPos;
            sender.oldRot = sender.Rot;
            sender.SendPacket(pa);
            args.Cancel();
            count++;
        }
コード例 #11
0
        public void Use(Player p, string[] args)
        {
            string IsFlying = (string)p.ExtraData["IsFlying"];

            if (IsFlying != null)
            {
                p.OnPlayerBigMove.Normal     -= OnPlayerBigMove_Normal;
                p.OnPlayerBlockChange.Normal -= OnPlayerBlockChange_Normal;
                if (IsFlying == "+" && glassesFlatAndMiddle != null)
                {
                    p.ResendBlockChange(glassesFlatAndMiddle, (Vector3S)p.ExtraData["FlyLastPos"]);
                }
                else if (IsFlying == "water" && fluidCube != null)
                {
                    p.ResendBlockChange(fluidCube, (Vector3S)p.ExtraData["FlyLastPos"]);
                }
                else
                {
                    p.ResendBlockChange(glassesFlat, (Vector3S)p.ExtraData["FlyLastPos"]);
                }
                p.ResendBlockChange(glassesFlat, (Vector3S)p.ExtraData["FlyLastPos"]);
                p.ExtraData["IsFlying"] = null;
                p.SendMessage(stopFlyMessage);
                return;
            }
            Vector3S belowBlock = p.belowBlock;

            if (args.Length > 0)
            {
                if (args[0] == "+" && glassesFlatAndMiddle != null)
                {
                    p.ExtraData["IsFlying"] = "+";
                    p.SendBlockChangeWhereAir(glassesFlatAndMiddle, belowBlock, 20);
                    p.ExtraData["FlyLastPos"] = belowBlock;
                }
                else if (args[0].ToLower() == "water" && fluidCube != null)
                {
                    p.ExtraData["IsFlying"] = "water";
                    Vector3S tmp = belowBlock;
                    tmp.y++;
                    p.SendBlockChangeWhereAir(fluidCube, tmp, 9);
                    p.ExtraData["FlyLastPos"] = tmp;
                }
                else
                {
                    p.ExtraData["IsFlying"] = "normal";
                    p.SendBlockChangeWhereAir(glassesFlat, belowBlock, 20);
                    p.ExtraData["FlyLastPos"] = belowBlock;
                }
            }
            else
            {
                p.ExtraData["IsFlying"] = "normal";
                p.SendBlockChangeWhereAir(glassesFlat, belowBlock, 20);
                p.ExtraData["FlyLastPos"] = belowBlock;
            }
            p.OnPlayerBigMove.Normal     += OnPlayerBigMove_Normal;
            p.OnPlayerBlockChange.Normal += OnPlayerBlockChange_Normal;
            p.SendMessage(startFlyMessage);
        }
コード例 #12
0
 void Curse(Player sender)
 {
     if (sender.ExtraData["cursorlocked"] != null && (bool)sender.ExtraData["cursorlocked"])
     {
         return;
     }
     lock (this) {
         sender.ExtraData["cursorlocked"] = true;
         if (sender.ExtraData["Cursor"] != null)
         {
             Vector3S old;
             if (sender.ExtraData["Cursor"].GetType() == typeof(Vector3S))
             {
                 old = (Vector3S)sender.ExtraData["Cursor"];
             }
             else
             {
                 old = new Vector3S();
                 old.FromString((string)sender.ExtraData["Cursor"]);
             }
             sender.SendBlockChange((ushort)old.x, (ushort)old.z, (ushort)old.y, sender.Level.GetBlock(old));
         }
         Vector3S cursor = sender.GetBlockFromView();
         if ((object)cursor != null)
         {
             sender.SendBlockChange((ushort)cursor.x, (ushort)cursor.z, (ushort)cursor.y, 21);
         }
         sender.ExtraData["Cursor"]       = cursor;
         sender.ExtraData["cursorlocked"] = false;
     }
 }
コード例 #13
0
    /* Load saved game state from file */
    public void LoadGame()
    {
        if (File.Exists(Application.persistentDataPath + "/" + saveFileName))
        {
            // clear current world
            worldManager.EmptyWorld();

            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/" + saveFileName, FileMode.Open);
            SaveData        save = (SaveData)bf.Deserialize(file);
            file.Close();

            // recreate chunks
            foreach (KeyValuePair <Vector3S, ChunkData> item in save.chunks)
            {
                Vector3S  chunkPos  = item.Key;
                ChunkData chunkData = item.Value;

                worldManager.chunks[chunkPos.x, chunkPos.y, chunkPos.z].ReCreateChunkFromSave(ref chunkData, chunkPos);
            }

            // position player
            GameObject.FindWithTag("Player").transform.position = new Vector3(save.playerPosition.x, save.playerPosition.y, save.playerPosition.z) + Vector3.one * 0.5f;

            Debug.Log("Loading successful");
        }
        else
        {
            Debug.Log("Loading unsuccessful");
        }

        SwitchModes();
    }
コード例 #14
0
ファイル: Buildmodes.cs プロジェクト: umby24/Hypercube
        static void BoxHandler(NetworkClient client, HypercubeMap map, Vector3S location, byte mode, Block block)
        {
            if (mode != 1)
                return;

            switch (client.CS.MyEntity.BuildState) {
                case 0:
                    client.CS.MyEntity.ClientState.SetCoord(location, 0);
                    client.CS.MyEntity.BuildState = 1;
                    break;
                case 1:
                    var coord1 = client.CS.MyEntity.ClientState.GetCoord(0);
                    var blocks = Math.Abs(location.X - coord1.X)*Math.Abs(location.Y - coord1.Y)*
                                 Math.Abs(location.Z - coord1.Z);
                    var replaceBlock = client.CS.MyEntity.ClientState.GetString(0);

                    if (blocks < 50000) {
                        map.BuildBox(client, coord1.X, coord1.Y, coord1.Z, location.X, location.Y, location.Z, block,
                            String.IsNullOrEmpty(replaceBlock)
                                ? ServerCore.Blockholder.UnknownBlock
                                : ServerCore.Blockholder.GetBlock(replaceBlock), false, 1, true, false);

                        Chat.SendClientChat(client, "§SBox created.");
                    }
                    else
                        Chat.SendClientChat(client, "§EBox too large.");

                    client.CS.MyEntity.SetBuildmode("");
                    break;
            }
        }
コード例 #15
0
        public Vector3S GetBlockFromView()
        {
            double hori    = (Math.PI / 128) * Rot[0];
            double vert    = (Math.PI / 128) * Rot[1];
            double cosHori = Math.Cos(hori);
            double sinHori = Math.Sin(hori);
            double cosVert = Math.Cos(vert);
            double sinVert = Math.Sin(vert);
            double length  = 0.1; //TODO: Adjust length after first possible block is found to the distance (Player.Pos-FirstBlock).Length

            for (double i = 1; i < ((Rot[0] < 64 || Rot[0] > 192) ? Level.Size.z - Pos.z / 32 : Pos.z / 32); i += length)
            {
                double h = i / cosHori;
                double x = -sinHori * h;
                h = h / cosVert;
                double   y   = sinVert * h;
                short    X   = (short)(Math.Round((double)(Pos.x - 16) / 32 + x * ((Rot[0] < 64 || Rot[0] > 192) ? -1 : 1)));
                short    Z   = (short)(Math.Round((double)(Pos.z - 16) / 32 + i * ((Rot[0] < 64 || Rot[0] > 192) ? -1 : 1)));
                short    Y   = (short)(Math.Round((double)(Pos.y - 32) / 32 + y * ((Rot[0] < 64 || Rot[0] > 192) ? -1 : 1)));
                Vector3S ret = new Vector3S(X, Z, Y);
                if (Level.GetBlock(ret) != 0)
                {
                    return(ret);
                }
            }
            return(null);
        }
コード例 #16
0
        protected void BufferAdd(List <Pos> list, Vector3S type)
        {
            Pos pos;

            pos.pos = type;
            list.Add(pos);
        }
コード例 #17
0
    public AnnanaSceneState SetCharPosition(Vector3S value)
    {
        var copy = new AnnanaSceneState(this);

        copy.CharPosition = value;
        return(copy);
    }
コード例 #18
0
 void MoveGlass(Player sender)
 {
     if (sender.ExtraData["cursormoveglasslocked"] != null && (bool)sender.ExtraData["cursormoveglasslocked"])
     {
         return;
     }
     lock (this) {
         sender.ExtraData["cursormovelocked"] = true;
         if (sender.ExtraData["CursorGlassCenter"] != null)
         {
             Vector3S old;
             if (sender.ExtraData["CursorGlassCenter"].GetType() == typeof(Vector3S))
             {
                 old = (Vector3S)sender.ExtraData["CursorGlassCenter"];
             }
             else
             {
                 old = new Vector3S();
                 old.FromString((string)sender.ExtraData["CursorGlassCenter"]);
             }
             sender.ResendBlockChange(surrounder, old);
         }
         Vector3S pos = new Vector3S((ushort)(sender.Pos.x / 32), (ushort)(sender.Pos.z / 32), (ushort)(sender.Pos.y / 32));
         sender.SendBlockChange(surrounder, pos, 20);
         sender.ExtraData["CursorGlassCenter"]     = pos;
         sender.ExtraData["cursormoveglasslocked"] = false;
     }
 }
コード例 #19
0
 void OnAllLevelsLoad_Normal(Level sender, LevelLoadEventArgs args)
 {
     if (sender.ExtraData["MessageBlock"] == null || sender.ExtraData["MessageBlock"].GetType() != typeof(string))
     {
         store[sender.Name] = new List <string>();
     }
     else
     {
         string[]      split = ((string)sender.ExtraData["MessageBlock"]).Split(';');
         List <string> tmp   = new List <string>();
         for (int i = 0; i < split.Length; i++)
         {
             try {
                 Vector3S v = new Vector3S();
                 v.FromHexString(split[i]);
                 if (sender.ExtraData["MessageBlock" + v] != null)
                 {
                     tmp.Add(v);
                 }
             }
             catch { }
         }
         store[sender.Name] = tmp;
     }
 }
コード例 #20
0
    public HubaBusSceneState SetCharPosition(Vector3S value)
    {
        var copy = new HubaBusSceneState(this);

        copy.CharPosition = value;
        return(copy);
    }
コード例 #21
0
        /// <summary>
        /// Create a level with a specified type and a specified size. <remarks>Calls OnLevelsLoad event.</remarks>
        /// </summary>
        /// <param name="size">The size to create the level.</param>
        /// <param name="type">The type of the level you want to create</param>
        /// <param name="name">Name of the level to create</param>
        /// <returns>
        /// returns the level that was created
        /// </returns>
        public static Level CreateLevel(Vector3S size, LevelTypes type, string name = "main")
        {
            Level newlevel = new Level(size)
            {
                Name = name
            };

            switch (type)
            {
            case LevelTypes.Flat:

                var gen = new Generator.LevelGenerator(newlevel);
                for (int i = newlevel.CWMap.Size.z / 2; i >= 0; i--)
                {
                    newlevel.FillPlaneXZ(i, Block.BlockList.DIRT);
                }
                newlevel.FillPlaneXZ(newlevel.CWMap.Size.z / 2, Block.BlockList.GRASS);
                break;

            case LevelTypes.Pixel:
                newlevel.CreatePixelArtLevel();
                break;

            case LevelTypes.Hell:
                var mGen = new Generator.LevelGenerator(newlevel, Generator.GeneratorTemplate.Hell(newlevel));
                mGen.Generate();
                break;
            }
            OnAllLevelsLoad.Call(newlevel, new LevelLoadEventArgs(true));
            return(newlevel);
        }
コード例 #22
0
        protected void BufferAdd(List <Pos> list, Vector3S position)
        {
            Pos pos;

            pos.pos = position;
            list.Add(pos);
        }
コード例 #23
0
 void OnPlayerBlockChange_Normal(Player sender, BlockChangeEventArgs args)
 {
     args.Cancel();
     if (args.Current == 0 && args.Action == ActionType.Delete)
     {
         args.Current = 20;
     }
     sender.OnPlayerBlockChange.Normal -= OnPlayerBlockChange_Normal;
     if (sender.ExtraData["Cursor"] != null)
     {
         Vector3S cursor;
         if (sender.ExtraData["Cursor"].GetType() == typeof(Vector3S))
         {
             cursor = (Vector3S)sender.ExtraData["Cursor"];
         }
         else
         {
             cursor = new Vector3S();
             cursor.FromString((string)sender.ExtraData["Cursor"]);
         }
         if (args.Action == ActionType.Place)
         {
             sender.Click((ushort)cursor.x, (ushort)cursor.z, (ushort)(cursor.y + 1), args.Holding);
         }
         else
         {
             sender.Click((ushort)cursor.x, (ushort)cursor.z, (ushort)(cursor.y), args.Holding, false);
         }
     }
     sender.OnPlayerBlockChange.Normal += OnPlayerBlockChange_Normal;
     Curse(sender);
 }
コード例 #24
0
 // initial constructor - default values
 public AnnanaSceneState(bool initial)
 {
     AlarmPostponed        = true;
     AlarmTurnedOff        = false;
     AngerLevel            = 13;
     AnnanaDress           = "clothes_2";
     BoilerContents        = new HashSet <int>();
     CharPosition          = new Vector3S(10.74f, -0.52f, 0f);
     DidReadFridgeNote     = false;
     ElixirId              = -1;
     FlyAway               = false;
     IsAddressPickedUp     = false;
     IsAddressUsed         = false;
     IsBerryPickedUp       = false;
     IsBerryUsed           = false;
     IsCrystalBallPickedUp = false;
     IsElixirUsed          = false;
     IsEmptyVialPickedUp   = false;
     IsEmptyVialUsed       = false;
     IsFlowerPickedUp      = false;
     IsFlowerUsed          = false;
     IsInside              = false;
     IsLeafPickedUp        = false;
     IsLeafUsed            = false;
     IsOutside             = false;
     IsReadingFridgeNote   = false;
     OwlHasAddress         = false;
     OwlPackage            = -1;
     ReadingVeganBook      = false;
     ReadVeganBook         = false;
 }
コード例 #25
0
        void BlockChange(Player sender, BlockChangeEventArgs e)
        {
            e.Cancel();

            var raw = (BrushData)sender.ExtraData.GetIfExist <object, object> ("BrushData");

            if (raw == null)
            {
                sender.SendMessage("An error occurred while trying to brush");
                sender.OnPlayerBlockChange.Normal -= BlockChange;
                return;
            }

            byte     block = raw.Block != 255 ? raw.Block : e.Holding;
            Vector3S loc   = new Vector3S(e.X, e.Z, e.Y);
            IBrush   b     = (IBrush)Activator.CreateInstance(raw.BrushType);
            var      qq    = b.Draw(loc, raw.Block, raw.Size);

            if (sender.Group.MaxBlockChange < qq.Count())
            {
                sender.SendMessage("You cannot set that many blocks");
                return;
            }

            foreach (var fml in qq)
            {
                sender.SendBlockChange((ushort)fml.x, (ushort)fml.z, (ushort)fml.y, block);
            }

#if DEBUG
            sender.SendMessage(string.Format("Brushed {0} blocks", qq.Count()));
#endif
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PacketPositionAndOrientationUpdate"/> class.
 /// </summary>
 public PacketPositionAndOrientationUpdate(byte ID, Vector3S Location, byte Yaw, byte Pitch)
     : base(PacketIDs.PosAndRotUpdate)
 {
     this.ID       = ID;
     this.Location = Location;
     this.Yaw      = Yaw;
     this.Pitch    = Pitch;
 }
コード例 #27
0
 public static IPacket CreateMapFinal(Vector3S mapSize)
 {
     return(new LevelFinalize {
         SizeX = mapSize.X,
         SizeY = mapSize.Y,
         SizeZ = mapSize.Z
     });
 }
コード例 #28
0
ファイル: Entity.cs プロジェクト: umby24/ClassicBot
 public Entity(string name, sbyte id, short x, short y, short z, byte yaw, byte pitch)
 {
     Location = new Vector3S {X = x, Y = y, Z = z};
     Yaw = yaw;
     Pitch = pitch;
     PlayerId = id;
     Name = name;
 }
コード例 #29
0
ファイル: Player.cs プロジェクト: TheDireMaster/ClassicBot
 public void RefreshLocation(Vector3S location, byte yaw, byte pitch)
 {
     location             = location.AsCopy();
     _thisEntity.Position = location;
     _thisEntity.Yaw      = yaw;
     _thisEntity.Pitch    = pitch;
     RefreshLocation();
 }
コード例 #30
0
 /* Create chunk's geometry from saved file */
 public void ReCreateChunkFromSave(ref ChunkData chunkData, Vector3S chunkPosition)
 {
     for (int i = 0; i < chunkData.blockPositions.Count; i++)
     {
         chunkGrid[chunkData.blockPositions[i].x, chunkData.blockPositions[i].y, chunkData.blockPositions[i].z] = chunkData.blockTypes[i];
     }
     CreateChunkObject(false);
 }
コード例 #31
0
 public TransformS(Transform t)
 {
     if (t == null)
     {
         return;
     }
     pos = t.position; rot = t.rotation; scale = t.localScale;
 }
コード例 #32
0
ファイル: HcMap.cs プロジェクト: umby24/ZBase
        /// <summary>
        /// Determines if the given coordinates are in-bounds of the map.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <returns></returns>
        public bool BlockInBounds(short x, short y, short z)
        {
            Vector3S mapSize = MapProvider.GetSize();
            bool     result1 = (0 <= x && (mapSize.X - 1) >= x) && (0 <= z && (mapSize.Z - 1) >= z);
            bool     result2 = result1 && (0 <= y && (mapSize.Y - 1) >= y);

            return(result2);
        }
コード例 #33
0
        public void CatchBlock2(Player sender, BlockChangeEventArgs args)
        {
            args.Unregister();
            Vector3S FirstBlock  = (Vector3S)sender.GetDatapass("CmdDatapassExample_FirstBlock");
            Vector3S SecondBlock = new Vector3S(args.X, args.Z, args.Y);

            sender.SendMessage("This is where we would initiate a Cuboid!");
        }
コード例 #34
0
ファイル: Entity.cs プロジェクト: umby24/Hypercube
        public Vector3S GetBlockLocation()
        {
            var myLoc = new Vector3S {
                X = (short)(Location.X / 32),
                Y = (short)(Location.Y / 32),
                Z = (short)((Location.Z - 51) / 32),
            };

            return myLoc;
        }
コード例 #35
0
ファイル: Buildmode.cs プロジェクト: umby24/Hypercube
        public void AddBlock(short x, short y, short z)
        {
            var thisPoint = new Vector3S {X = x, Y = y, Z = z};

            if (Blocks.Contains(thisPoint))
                return;

            if (Blocks.Count < MaxResendSize)
                Blocks.Add(thisPoint);
            else {
                Blocks.RemoveAt(0);
                Blocks.Add(thisPoint);
            }
        }
コード例 #36
0
ファイル: Entity.cs プロジェクト: umby24/Hypercube
        public Entity(HypercubeMap map, string name, Vector3S location, byte rot, byte look)
        {
            Name = name;
            Location = location;
            Rot = rot;
            Look = look;
            Map = map;
            Model = "default";
            Visible = true;
            Id = ServerCore.FreeEids.Pop();

            BuildMaterial = ServerCore.Blockholder.GetBlock("");
            Lastmaterial = ServerCore.Blockholder.GetBlock(1);
            ClientState = new BuildState();
            BuildMode = new BmStruct {Name = ""};

            ClientId = (byte)Map.FreeIds.Pop();
        }
コード例 #37
0
ファイル: Buildmodes.cs プロジェクト: umby24/Hypercube
        static void CreateTPHandler(NetworkClient client, HypercubeMap map, Vector3S location, byte mode, Block block)
        {
            if (mode != 1)
                return;

            var state = client.CS.MyEntity.BuildState;

            switch (state) {
                case 0:
                    client.CS.MyEntity.ClientState.SetCoord(location.X, location.Y, location.Z, 1);
                    client.CS.MyEntity.BuildState = 1;
                    return;
                case 1:
                    var destCoord = client.CS.MyEntity.ClientState.GetCoord(0);
                    var destRot = client.CS.MyEntity.ClientState.GetInt(0);
                    var destLook = client.CS.MyEntity.ClientState.GetInt(1);
                    var startCoord = client.CS.MyEntity.ClientState.GetCoord(1);
                    var endCoord = new Vector3S { X = location.X, Y = location.Y, Z = location.Z };
                    var teleName = client.CS.MyEntity.ClientState.GetString(0);
                    var destMap = HypercubeMap.GetMap(client.CS.MyEntity.ClientState.GetString(1));

                    // -- Move things around so the smaller is the start, the larger being the end.
                    if (startCoord.X > location.X) {
                        endCoord.X = startCoord.X;
                        startCoord.X = location.X;
                    }

                    if (startCoord.Y > location.Y) {
                        endCoord.Y = startCoord.Y;
                        startCoord.Y = location.Y;
                    }

                    if (startCoord.Z > location.Z) {
                        endCoord.Z = startCoord.Z;
                        startCoord.Z = location.Z;
                    }

                    client.CS.CurrentMap.Teleporters.CreateTeleporter(teleName, startCoord, endCoord, destCoord, (byte)destLook, (byte)destRot, destMap);
                    Chat.SendClientChat(client, "§STeleporter created.");
                    client.CS.MyEntity.SetBuildmode("");
                    break;
            }
        }
コード例 #38
0
ファイル: Packets.cs プロジェクト: umby24/Hypercube
 public void Read(NetworkClient client)
 {
     PlayerId = client.WSock.ReadSByte();
     Location = new Vector3S {X = client.WSock.ReadShort(), Z = client.WSock.ReadShort(), Y = client.WSock.ReadShort()};
     Yaw = client.WSock.ReadByte();
     Pitch = client.WSock.ReadByte();
 }
コード例 #39
0
ファイル: Buildmode.cs プロジェクト: umby24/Hypercube
 public void SetCoord(Vector3S coord, int index)
 {
     if ((index + 1) > CoordItems.Count) {
         for (var i = 0; i < (index + 1); i++)
             CoordItems.Add(new Vector3S());
     }
     CoordItems.Insert(index, coord);
 }
コード例 #40
0
ファイル: Buildmode.cs プロジェクト: umby24/Hypercube
        public void SetCoord(short x, short y, short z, int index)
        {
            if ((index + 1) > CoordItems.Count) {
                for (var i = 0; i < (index + 1); i++)
                    CoordItems.Add(new Vector3S());
            }

            var myCoord = new Vector3S {X = x, Y = y, Z = z};
            CoordItems.Insert(index, myCoord);
        }
コード例 #41
0
ファイル: AnimationBaker.cs プロジェクト: MaddJhin/Holdout
 public BoneStateSample(Vector3 p,Quaternion r , Vector3 s)
 {
     pos = new Vector3S(p);
     rot = new QuaternionS(r);
     scale = new Vector3S(s);
 }
コード例 #42
0
ファイル: AnimationBaker.cs プロジェクト: MaddJhin/Holdout
 public BoneStateSample(Transform obj)
 {
     pos = new Vector3S(obj.localPosition);
     rot = new QuaternionS(obj.localRotation);
     scale = new Vector3S(obj.localScale);
 }
コード例 #43
0
ファイル: Buildmodes.cs プロジェクト: umby24/Hypercube
        private static void HistoryHandler(NetworkClient client, HypercubeMap map, Vector3S location, byte mode, Block block)
        {
            Chat.SendClientChat(client,
                map.HCSettings.History
                    ? map.History.LookupString(location.X, location.Z, location.Y)
                    : "§EHistory is not enabled on this map.");

            client.CS.MyEntity.SetBuildmode("");
        }
コード例 #44
0
ファイル: Teleporter.cs プロジェクト: umby24/Hypercube
        public Teleporter FindTeleporter(Vector3S location)
        {
            foreach (var tele in _teleporters) {
                if (location.X < tele.Start.X || location.X > tele.End.X)
                    continue;

                if (location.Y < tele.Start.Y || location.Y > tele.End.Y)
                    continue;

                if (location.Z < tele.Start.Z || location.Z > tele.End.Z)
                    continue;

                // -- Teleport the player.
                return tele;
            }

            return null; // -- No teleporter found.
        }
コード例 #45
0
 public void SetData(Vector3 point1, Vector3 point2)
 {
     this.point1 = new Vector3S(point1);
     this.point2 = new Vector3S(point2);
 }
コード例 #46
0
 public LineData(Vector3 point1, Vector3 point2)
 {
     this.point1 = new Vector3S(point1);
     this.point2 = new Vector3S(point2);
 }
コード例 #47
0
 public LineData(Vector3S point1, Vector3S point2)
 {
     this.point1 = point1;
     this.point2 = point2;
 }
コード例 #48
0
ファイル: Entity.cs プロジェクト: umby24/Hypercube
 public void SetBlockPosition(Vector3S blockLoc)
 {
     Location.X = (short)(blockLoc.X * 32);
     Location.Y = (short)(blockLoc.Y * 32);
     Location.Z = (short)((blockLoc.Z * 32) + 51);
 }
コード例 #49
0
ファイル: Entity.cs プロジェクト: umby24/Hypercube
 public EntityStub(int id, byte clientId, bool visible, HypercubeMap cMap, Vector3S location, byte rot, byte look, string model)
 {
     Map = cMap;
     Id = id;
     ClientId = clientId;
     Visible = visible;
     Location = location;
     Rot = rot;
     Look = look;
     Looked = false;
     Changed = false;
     Spawned = false;
     Model = model;
 }
コード例 #50
0
ファイル: D3Map.cs プロジェクト: umby24/Hypercube
        public void LoadMap(string directory, string mapName)
        {
            if (!File.Exists(directory + "/Data-Layer.gz") || !File.Exists(directory + "/Config.txt"))
                return; // -- Not a valid map.

            // -- Load the Config data first..
            var configfile = new Settings("TempD3Config.txt", LoadConfig, directory, false);
            configfile.LoadFile();

            Mapsize = new Vector3S {
                X = (short) configfile.Read("Size_X", 128),
                Y = (short) configfile.Read("Size_Y", 128),
                Z = (short) configfile.Read("Size_Z", 128)
            };

            Spawn = new Vector3S {
                X = (short) float.Parse(configfile.Read("Spawn_X", "1.0")),
                Y = (short) float.Parse(configfile.Read("Spawn_Y", "1.0")),
                Z = (short) float.Parse(configfile.Read("Spawn_Z", "1.0"))
            };

            SpawnRot = (byte)configfile.Read("Spawn_Rot", 0);
            SpawnLook = (byte)configfile.Read("Spawn_Look", 0);

            Motd = configfile.Read("MOTD_Override", "");
            PhysicsStopped = Convert.ToBoolean(configfile.Read("Physic_Stopped", 0));

            // -- Load the block data
            GZip.DecompressFile(directory + "/Data-Layer.gz");
            byte[] allData;

            using (var br = new BinaryReader(new FileStream(directory + "/Data-Layer.gz", FileMode.Open)))
                allData = br.ReadBytes((int)br.BaseStream.Length);

            GZip.CompressFile(directory + "/Data-Layer.gz");

            if (allData.Length != (Mapsize.X * Mapsize.Y * Mapsize.Z) * 4) {
                // -- Size error..
                return;
            }

            Blockdata = new byte[Mapsize.X * Mapsize.Y * Mapsize.Z];
            // -- Converts block data from the D3 array format to the ClassicWorld array format.
            for (var x = 0; x < Mapsize.X; x++) {
                for (var y = 0; y < Mapsize.Y; y++) {
                    for (var z = 0; z < Mapsize.Z; z++)
                        Blockdata[GetIndex(x, y, z)] = allData[GetBlock(x, y, z)];
                }
            }

            // -- Now, Block data will be properly oriented for use in ClassicWorld maps, and we have all the data we need to create a classicworld map.

            var cwMap = new Classicworld(Mapsize.X, Mapsize.Z, Mapsize.Y) {
                BlockData = Blockdata,
                SpawnX = Spawn.X,
                SpawnY = Spawn.Z,
                SpawnZ = Spawn.Y,
                SpawnRotation = SpawnRot,
                SpawnLook = SpawnLook,
                MapName = mapName
            }; // -- Classicworld is in notchian Coordinates.

            cwMap.Save("Maps/" + mapName + ".cw");
            Blockdata = null;
            cwMap.BlockData = null;
            GC.Collect();
            // -- Conversion Complete.
        }