public static bool AtZone(WorldZone zone, float x, float y, float z) { return(AtZone(zone.Points, new Vector2(x, z))); }
public static bool AtZone(WorldZone zone, Transform transform) { return(AtZone(zone, transform.position)); }
public static bool AtZone(WorldZone zone, Vector3 position) { return(AtZone(zone, position.x, position.y, position.z)); }
public static bool LoadAsFile() { if (Database == null) { return(false); } Database.Clear(); string[] strArray = File.ReadAllLines(SaveFilePath); WorldZone zone = null; Dictionary <WorldZone, string> dictionary = new Dictionary <WorldZone, string>(); foreach (string str in strArray) { string[] strArray2; float num; float num2; float num3; if (str.StartsWith("[") && str.EndsWith("]")) { zone = null; if (!str.StartsWith("[ZONE ", StringComparison.OrdinalIgnoreCase)) { ConsoleSystem.LogError("Invalid section \"" + str + "\" from zones."); } else { strArray2 = Helper.SplitQuotes(str.Trim(new char[] { '[', ']' }), ' '); if (Database.ContainsKey(strArray2[1])) { zone = Database[strArray2[1]]; } else { zone = new WorldZone(null, 0); Database.Add(strArray2[1], zone); } } } else if (zone != null) { strArray2 = str.Split(new char[] { '=' }); if (strArray2.Length >= 2) { strArray2[1] = strArray2[1].Trim(); if (!string.IsNullOrEmpty(strArray2[1])) { num = 0f; num2 = 0f; num3 = 0f; switch (strArray2[0].ToUpper()) { case "NAME": zone.Name = strArray2[1]; break; case "FLAGS": zone.Flags = strArray2[1].ToEnum <ZoneFlags>(); break; case "INTERNAL": if (!Database.ContainsKey(strArray2[1])) { WorldZone zone2 = new WorldZone(null, 0); Database.Add(strArray2[1], zone2); zone.Internal.Add(zone2); } break; case "CENTER": goto Label_02A7; case "WARP": strArray2 = strArray2[1].Split(new char[] { ',' }); dictionary.Add(zone, strArray2[0].Trim()); if (strArray2.Length > 1) { long.TryParse(strArray2[1], out zone.WarpTime); } break; case "POINT": goto Label_033B; case "SPAWN": goto Label_038F; case "FORBIDDEN.COMMAND": zone.ForbiddenCommand = zone.ForbiddenCommand.Add <string>(strArray2[1]); break; case "ENTER.NOTICE": zone.Notice_OnEnter = strArray2[1]; break; case "LEAVE.NOTICE": zone.Notice_OnLeave = strArray2[1]; break; case "ENTER.MESSAGE": zone.Message_OnEnter = zone.Message_OnEnter.Add <string>(strArray2[1]); break; case "LEAVE.MESSAGE": zone.Message_OnLeave = zone.Message_OnLeave.Add <string>(strArray2[1]); break; } } } } continue; Label_02A7 :; strArray2 = strArray2[1].Split(new char[] { ',' }); if (strArray2.Length > 0) { float.TryParse(strArray2[0], out num); } if (strArray2.Length > 1) { float.TryParse(strArray2[1], out num2); } zone.Center = new Vector2(num, num2); continue; Label_033B :; strArray2 = strArray2[1].Split(new char[] { ',' }); if (strArray2.Length > 0) { float.TryParse(strArray2[0], out num); } if (strArray2.Length > 1) { float.TryParse(strArray2[1], out num2); } zone.Points.Add(new Vector2(num, num2)); continue; Label_038F :; strArray2 = strArray2[1].Split(new char[] { ',' }); if (strArray2.Length > 0) { float.TryParse(strArray2[0], out num); } if (strArray2.Length > 1) { float.TryParse(strArray2[1], out num2); } if (strArray2.Length > 2) { float.TryParse(strArray2[2], out num3); } zone.Spawns.Add(new Vector3(num, num2, num3)); } foreach (WorldZone zone3 in dictionary.Keys) { zone3.WarpZone = Get(dictionary[zone3]); } return(true); }
public static bool AtZone(WorldZone zone, GameObject gameObject) { return(AtZone(zone, gameObject.transform.position)); }
public static bool AtZone(WorldZone zone, PlayerClient player) { return(AtZone(zone, player.lastKnownPosition)); }
public static Vector2 GetCentroid(WorldZone zone) { return(GetCentroid(zone.Points)); }
public static bool AtZone(WorldZone zone, NetUser netUser) { return(AtZone(zone, netUser.playerClient.lastKnownPosition)); }
public static bool AtZone(WorldZone zone, uLink.NetworkPlayer netPlayer) { PlayerClient playerClient; return(PlayerClient.Find(netPlayer, out playerClient) && Zones.AtZone(zone, playerClient.lastKnownPosition)); }
public static bool LoadAsFile() { bool result; if (Zones.Database == null) { result = false; } else { Zones.Database.Clear(); string[] array = File.ReadAllLines(Zones.SaveFilePath); WorldZone worldZone = null; Dictionary <WorldZone, string> dictionary = new Dictionary <WorldZone, string>(); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text = array2[i]; if (text.StartsWith("[") && text.EndsWith("]")) { worldZone = null; if (!text.StartsWith("[ZONE ", StringComparison.OrdinalIgnoreCase)) { ConsoleSystem.LogError("Invalid section \"" + text + "\" from zones."); } else { string[] array3 = Helper.SplitQuotes(text.Trim(new char[] { '[', ']' }), ' '); if (Zones.Database.ContainsKey(array3[1])) { worldZone = Zones.Database[array3[1]]; } else { worldZone = new WorldZone(null, (ZoneFlags)0); Zones.Database.Add(array3[1], worldZone); } } } else if (worldZone != null) { string[] array3 = text.Split(new char[] { '=' }); if (array3.Length >= 2) { array3[1] = array3[1].Trim(); if (!string.IsNullOrEmpty(array3[1])) { float x = 0f; float y = 0f; float z = 0f; string text2 = array3[0].ToUpper(); switch (text2) { case "NAME": worldZone.Name = array3[1]; break; case "FLAGS": worldZone.Flags = array3[1].ToEnum <ZoneFlags>(); break; case "INTERNAL": if (!Zones.Database.ContainsKey(array3[1])) { WorldZone worldZone2 = new WorldZone(null, (ZoneFlags)0); Zones.Database.Add(array3[1], worldZone2); worldZone.Internal.Add(worldZone2); } break; case "CENTER": array3 = array3[1].Split(new char[] { ',' }); if (array3.Length > 0) { float.TryParse(array3[0], out x); } if (array3.Length > 1) { float.TryParse(array3[1], out y); } worldZone.Center = new Vector2(x, y); break; case "WARP": array3 = array3[1].Split(new char[] { ',' }); dictionary.Add(worldZone, array3[0].Trim()); if (array3.Length > 1) { long.TryParse(array3[1], out worldZone.WarpTime); } break; case "POINT": array3 = array3[1].Split(new char[] { ',' }); if (array3.Length > 0) { float.TryParse(array3[0], out x); } if (array3.Length > 1) { float.TryParse(array3[1], out y); } worldZone.Points.Add(new Vector2(x, y)); break; case "SPAWN": array3 = array3[1].Split(new char[] { ',' }); if (array3.Length > 0) { float.TryParse(array3[0], out x); } if (array3.Length > 1) { float.TryParse(array3[1], out y); } if (array3.Length > 2) { float.TryParse(array3[2], out z); } worldZone.Spawns.Add(new Vector3(x, y, z)); break; case "FORBIDDEN.COMMAND": worldZone.ForbiddenCommand = worldZone.ForbiddenCommand.Add(array3[1]); break; case "ENTER.NOTICE": worldZone.Notice_OnEnter = array3[1]; break; case "LEAVE.NOTICE": worldZone.Notice_OnLeave = array3[1]; break; case "ENTER.MESSAGE": worldZone.Message_OnEnter = worldZone.Message_OnEnter.Add(array3[1]); break; case "LEAVE.MESSAGE": worldZone.Message_OnLeave = worldZone.Message_OnLeave.Add(array3[1]); break; } } } } } foreach (WorldZone current in dictionary.Keys) { current.WarpZone = Zones.Get(dictionary[current]); } result = true; } return(result); }