コード例 #1
0
ファイル: Survival.cs プロジェクト: TheMegaPVP/ClassiCubeSVL
        void SpawnItem(BlockID item, byte count, Vector3 pos)
        {
            if (!game.Server.IsSinglePlayer)
            {
                game.SurvInv.TryAddItem((sbyte)count, item);
                return;
            }
            int id = game.Entities.NextFreeID();

            if (id == -1)
            {
                AddToHotbar(item, count);
                return;
            }
            EntityItem newEnt = new EntityItem(game);

            newEnt.ItemId    = item;
            newEnt.ItemCount = (sbyte)count;
            newEnt.SetLocation(LocationUpdate.MakePos(pos, false), false);
            game.Entities.List[id] = newEnt;
        }
コード例 #2
0
        public override void Execute(string[] args)
        {
            if (args.Length != 2 && args.Length != 3)
            {
                game.Chat.Add("Unspecified error");
            }
            else
            {
                BlockID    id   = 5;
                EntityItem Item = new EntityItem(game);
                if (!BlockID.TryParse(args[1], out id))
                {
                    game.Chat.Add("Unspecified error");
                    return;
                }

                Item.ItemId = id;
                float   x   = game.LocalPlayer.Position.X;
                float   z   = game.LocalPlayer.Position.Z;
                Vector3 pos = Respawn.FindSpawnPosition(game, x, z, Item.Size);
                Item.SetLocation(LocationUpdate.MakePos(pos, false), false);
                game.Entities.List[200] = Item;
            }
        }