PsyOps

TestMapInfo.cs

Dec 24th, 2015
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using BattleCore;
  7. using BattleCore.Events;
  8. using BattleCorePsyOps;
  9.  
  10. namespace zxvf
  11. {
  12.     // Add the attribute and the base class
  13.     [Behavior("MapInfo", "true", "0.01", "zxvf", "Module for testing MapData.")]
  14.     public class TestMapInfo:BotEventListener
  15.     {
  16.         public TestMapInfo()
  17.         {
  18.             // Create a timed event at bot load - 1 second
  19.             RegisterTimedEvent("BotLoad",1000, LoadBot);
  20.             RegisterCommand("!minfo", getMapInfo);
  21.             RegisterCommand("!tileid", getTileID);
  22.         }
  23.  
  24.         ShortChat msg = new ShortChat();
  25.         MapInfo m_MyMap;
  26.  
  27.         public void LoadBot()
  28.         {
  29.             // Destroy timed event so it only fires once
  30.             RemoveTimedEvent("BotLoad");
  31.             // ask core for bot info with mapdata attached
  32.             Game(new BotInfoRequest());
  33.         }
  34.  
  35.         public void getMapInfo(ChatEvent e)
  36.         {
  37.             string[] info = m_MyMap.MapPrintOut();
  38.  
  39.             for (int i = 0; i < info.Length; i += 1)
  40.             {
  41.                 Game(msg.arena(info[i]));
  42.             }
  43.         }
  44.         public void getTileID(ChatEvent e)
  45.         {
  46.             string[] Data = e.Message.Split(' ');
  47.             int x, y;
  48.  
  49.             if (Int32.TryParse(Data[1],out x) && (Int32.TryParse(Data[2],out y)))
  50.                 Game(msg.pm(e.PlayerName, "Tile ID for [" + x + "][" + y + "] is: [" + m_MyMap.GetTileID((ushort)x, (ushort)y) + "]."));
  51.             else
  52.                 Game(msg.pm(e.PlayerName,"Error parsing info."));
  53.         }
  54.  
  55.         // Grab the incoming event per your request just above this line
  56.         public void MonitorIncomingBotInfo(object sender, BotInfoRequest e)
  57.         {
  58.             m_MyMap =  new MapInfo(e.MapData);
  59.  
  60.             // Grab botname and mapdata here
  61.             Game(msg.arena("BotName[ " + e.BotName + " ] Level Name [ "+e.MapFile+" ]  MapInfoLength[ " + e.MapData.Length + " ]"));
  62.         }
  63.  
  64.         public override void Dispose()
  65.         {
  66.             throw new NotImplementedException();
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment