コード例 #1
0
 public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
 {
     try
     {
         LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));
         if (loc == null)
         {
             queue.HandleError(entry, "Invalid location!");
             return;
         }
         EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
         if (entity == null)
         {
             queue.HandleError(entry, "Invalid entity!");
             return;
         }
         PlayerTag player;
         if (entity.TryGetPlayer(out player))
         {
             player.Internal.player.gameObject.AddComponent <LaunchComponent>().LaunchPlayer(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         ZombieTag zombie;
         if (entity.TryGetZombie(out zombie))
         {
             zombie.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched zombie " + TagParser.Escape(zombie.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         AnimalTag animal;
         if (entity.TryGetAnimal(out animal))
         {
             animal.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched animal " + TagParser.Escape(animal.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         ItemEntityTag item;
         if (entity.TryGetItem(out item))
         {
             // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID?
         }
         queue.HandleError(entry, "That entity can't be launched!");
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to launch entity: " + ex.ToString());
     }
 }
コード例 #2
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            try
            {
                LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));
                if (loc == null)
                {
                    queue.HandleError(entry, "Invalid location!");
                    return;
                }
                EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
                if (entity == null)
                {
                    queue.HandleError(entry, "Invalid entity!");
                    return;
                }
                PlayerTag player;
                if (entity.TryGetPlayer(out player))
                {
                    player.Internal.player.sendTeleport(loc.ToVector3(), 0);
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully teleported a player to " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    return;
                }
                ZombieTag zombie;
                if (entity.TryGetZombie(out zombie))
                {
                    zombie.Internal.transform.position = loc.ToVector3();
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully teleported a zombie to " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    return;
                }
                AnimalTag animal;
                if (entity.TryGetAnimal(out animal))
                {
                    animal.Internal.transform.position = loc.ToVector3();
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully teleported an animal to " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    return;
                }
                ItemEntityTag item;
                if (entity.TryGetItem(out item))
                {
                    // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID?

                    /*
                     * Transform transform = item.Internal.transform.parent;
                     * byte x;
                     * byte y;
                     * if (Regions.tryGetCoordinate(transform.position, out x, out y))
                     * {
                     *  ItemRegion region = ItemManager.regions[x, y];
                     *  for (byte i = 0; i < region.models.Count; i+)
                     *  {
                     *      if (region.models[i] == transform)
                     *      {
                     *          ItemManager.regions[x, y].items.RemoveAt(i);
                     *          ItemModelTracker.Untrack(x, y, i);
                     *          ItemManager.manager.channel.send("tellTakeItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                     *          {
                     *              x,
                     *              y,
                     *              loc.ToVector3()
                     *          });
                     *          // Then respawn item at new location
                     *          break;
                     *      }
                     *  }
                     * }
                     */
                }
                queue.HandleError(entry, "That entity can't be teleported!");
            }
            catch (Exception ex) // TODO: Necessity of this?
            {
                queue.HandleError(entry, "Failed to teleport entity: " + ex.ToString());
            }
        }