| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- using System.Drawing;
- using Server.MirEnvir;
- namespace Server.MirDatabase
- {
- public class RespawnInfo
- {
- protected static Envir Envir
- {
- get { return Envir.Main; }
- }
- public int MonsterIndex;
- public Point Location;
- public ushort Count, Spread, Delay, RandomDelay;
- public byte Direction;
- public string RoutePath = string.Empty;
- public int RespawnIndex;
- public bool SaveRespawnTime = false;
- public ushort RespawnTicks; //leave 0 if not using this system!
- public RespawnInfo()
- {
- }
- public RespawnInfo(BinaryReader reader, int Version, int Customversion)
- {
- MonsterIndex = reader.ReadInt32();
- Location = new Point(reader.ReadInt32(), reader.ReadInt32());
- Count = reader.ReadUInt16();
- Spread = reader.ReadUInt16();
- Delay = reader.ReadUInt16();
- Direction = reader.ReadByte();
- RoutePath = reader.ReadString();
- if (Version > 67)
- {
- RandomDelay = reader.ReadUInt16();
- RespawnIndex = reader.ReadInt32();
- SaveRespawnTime = reader.ReadBoolean();
- RespawnTicks = reader.ReadUInt16();
- }
- else
- {
- RespawnIndex = ++Envir.RespawnIndex;
- }
- }
- public static RespawnInfo FromText(string text)
- {
- string[] data = text.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
- if (data.Length < 7) return null;
- RespawnInfo info = new RespawnInfo();
- int x,y ;
- if (!int.TryParse(data[0], out info.MonsterIndex)) return null;
- if (!int.TryParse(data[1], out x)) return null;
- if (!int.TryParse(data[2], out y)) return null;
- info.Location = new Point(x, y);
- if (!ushort.TryParse(data[3], out info.Count)) return null;
- if (!ushort.TryParse(data[4], out info.Spread)) return null;
- if (!ushort.TryParse(data[5], out info.Delay)) return null;
- if (!byte.TryParse(data[6], out info.Direction)) return null;
- if (!ushort.TryParse(data[7], out info.RandomDelay)) return null;
- if (!int.TryParse(data[8], out info.RespawnIndex)) return null;
- if (!bool.TryParse(data[9], out info.SaveRespawnTime)) return null;
- if (!ushort.TryParse(data[10], out info.RespawnTicks)) return null;
- return info;
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write(MonsterIndex);
- writer.Write(Location.X);
- writer.Write(Location.Y);
- writer.Write(Count);
- writer.Write(Spread);
- writer.Write(Delay);
- writer.Write(Direction);
- writer.Write(RoutePath);
- writer.Write(RandomDelay);
- writer.Write(RespawnIndex);
- writer.Write(SaveRespawnTime);
- writer.Write(RespawnTicks);
- }
- public override string ToString()
- {
- var monsterName = Envir.MonsterInfoList.Find(o => o.Index == MonsterIndex)?.Name ?? "Unknown";
- return string.Format("Monster: {0} - {1} - {2} - {3} - {4} - {5} - {6} - {7} - {8} - {9} - {10}",
- MonsterIndex,
- monsterName,
- Functions.PointToString(Location),
- Count,
- Spread,
- Delay,
- Direction,
- RandomDelay,
- RespawnIndex,
- SaveRespawnTime,
- RespawnTicks);
- }
- }
- public class RouteInfo
- {
- public Point Location;
- public int Delay;
- public static RouteInfo FromText(string text)
- {
- string[] data = text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- if (data.Length < 2) return null;
- RouteInfo info = new RouteInfo();
- int x, y;
- if (!int.TryParse(data[0], out x)) return null;
- if (!int.TryParse(data[1], out y)) return null;
- info.Location = new Point(x, y);
- if (data.Length <= 2) return info;
- return !int.TryParse(data[2], out info.Delay) ? info : info;
- }
- }
- }
|