Exemplo n.º 1
0
		public void AddRemove()
		{
			var events = new EventHandlers<String>(this);

			Boolean firstAdded = events.Add<AEventArgs>("a", AEventHandler);
			Assert.IsTrue(firstAdded);
			firstAdded = events.Add<AEventArgs>("a", AEventHandler);
			Assert.IsFalse(firstAdded);

			firstAdded = events.Add<BEventArgs>("b", BEventHandler);
			Assert.IsTrue(firstAdded);
			firstAdded = events.Add<BEventArgs>("b", BEventHandler);
			Assert.IsFalse(firstAdded);


			Boolean lastRemoved = events.Remove<BEventArgs>("b", BEventHandler);
			Assert.IsFalse(lastRemoved);
			lastRemoved = events.Remove<BEventArgs>("b", BEventHandler);
			Assert.IsTrue(lastRemoved);

			lastRemoved = events.Remove<AEventArgs>("a", AEventHandler);
			Assert.IsFalse(lastRemoved);
			lastRemoved = events.Remove<AEventArgs>("a", AEventHandler);
			Assert.IsTrue(lastRemoved);
		}
Exemplo n.º 2
0
		public static int Main ()
		{
			EventHandlers handlers = new EventHandlers ();
			handlers.Handler = handlers.DoSomethingEventHandler;

			Console.WriteLine ("Is handlers.Handler == handlers.DoSomethingEventHandler (instance)?");
			Console.WriteLine ("Expected: True");
			Console.Write ("Actual:   ");
			bool instanceEqual = handlers.Handler == handlers.DoSomethingEventHandler;
			Console.WriteLine (instanceEqual);
			Console.WriteLine ();

			handlers.Handler = EventHandlers.DoNothingEventHandler;
			Console.WriteLine ("Is handlers.Handler == EventHandlers.DoNothingEventHandler (static)?");
			Console.WriteLine ("Expected: True");
			Console.Write ("Actual:   ");
			bool staticEqual = handlers.Handler == EventHandlers.DoNothingEventHandler;
			Console.WriteLine (staticEqual);

			if (instanceEqual)
				if (staticEqual)
					return 0; // instance passed, static passed
				else
					return 1; // instance passed, static failed
			else
				if (staticEqual)
					return 2; // instance failed, static passed
				else
					return 3; // instance failed, static failed
		}
Exemplo n.º 3
0
		public WebBrowser(IWebBrowserContainer container)
		{
			m_Container = container;
			m_Events = new EventHandlers<EventKey>(this);

			var webBrowser = XpcomHelper.CreateInstance<nsIWebBrowser>(Xpcom.NS_WEBBROWSER_CONTRACTID);
			this.AssignWebBrowser(webBrowser);

			Container.GotFocus += ContainerGotFocus;
			Container.LostFocus += ContainerLostFocus;
			Container.SizeChanged += ContainerSizeChanged;
		}
Exemplo n.º 4
0
		public void Contravariance()
		{
			var events = new EventHandlers<String>(this);

			Boolean firstAdded = events.Add<AEventArgs>("v", AEventHandler);
			Assert.IsTrue(firstAdded);
			firstAdded = events.Add<AEventArgs>("v", AEventHandler);
			Assert.IsFalse(firstAdded);

			var e = new BEventArgs();
			events.Raise("v", e);
			Assert.IsTrue(e.Handled);
		}
Exemplo n.º 5
0
		public void UnknownEventArgs()
		{
			var events = new EventHandlers<String>(this);

			Boolean firstAdded = events.Add<AEventArgs>("v", AEventHandler);
			Assert.IsTrue(firstAdded);
			firstAdded = events.Add<AEventArgs>("v", AEventHandler);
			Assert.IsFalse(firstAdded);

			EventArgs e = new AEventArgs();
			events.Raise("v", e);
			Assert.IsTrue(((AEventArgs)e).Handled);

			e = new BEventArgs();
			events.Raise("v", e);
			Assert.IsTrue(((BEventArgs)e).Handled);
		}
Exemplo n.º 6
0
 private void UnBindEvents()
 {
     EventHandlers
     .Remove <CurrencyExchangeRateSet>(this)
     .Remove <CurrencyExchangeRateRemoved>(this);
 }
Exemplo n.º 7
0
 public void Dispose()
 {
     EventHandlers.Remove <UserPropertyChanged>(this);
 }
Exemplo n.º 8
0
        public void RemoveMethodHandler()
        {
            var eventClass = new EventClass();
            var eventHandlers = new EventHandlers();
            eventClass.Foo += eventHandlers.M1;
            eventClass.Foo += eventHandlers.M2;
            eventClass.OnFoo();

            AssertEquals(eventHandlers.m1, "M1");
            AssertEquals(eventHandlers.m2, "M2");

            eventHandlers.m1 = null;
            eventHandlers.m2 = null;
            eventClass.Foo -= eventHandlers.M1;
            eventClass.OnFoo();

            AssertEquals(eventHandlers.m2, "M2");
            AssertTrue((eventHandlers.m1 == null));
        }
Exemplo n.º 9
0
 private static extern void Discord_Initialize([MarshalAs(UnmanagedType.LPStr)] string applicationID,
                                               ref EventHandlers handlers,
                                               int autoRegister,
                                               [MarshalAs(UnmanagedType.LPStr)] string optionalSteamId);
Exemplo n.º 10
0
 public void Dispose()
 {
     EventHandlers.Remove <ApiVersionChanged>(this);
 }
Exemplo n.º 11
0
 public static void SpawnPluginRole(ReferenceHub player)
 {
     EventHandlers.SpawnSCP181(player);
 }
Exemplo n.º 12
0
 public static extern void UpdateHandlers(ref EventHandlers handlers);
Exemplo n.º 13
0
 public static void SpawnPlayer(Player player, bool full = true)
 {
     EventHandlers.SpawnPlayer(player, full);
 }
Exemplo n.º 14
0
 public static void SpawnSquad(int size)
 {
     EventHandlers.CreateSquad(size);
 }
Exemplo n.º 15
0
	public Movie(LWF lwf, Movie parent, int objId, int instId, int matrixId = 0,
			int colorTransformId = 0, bool attached = false,
			MovieEventHandlers handler = null, string n = null)
		: base(lwf, parent,
			attached ? Type.ATTACHEDMOVIE : Type.MOVIE, objId, instId)
	{
		m_data = lwf.data.movies[objId];
		m_matrixId = matrixId;
		m_colorTransformId = colorTransformId;
		m_totalFrames = m_data.frames;

		if (!String.IsNullOrEmpty(n))
			m_name = n;
		m_instanceHead = null;
		m_instanceTail = null;
		m_currentFrameInternal = -1;
		m_execedFrame = -1;
		m_animationPlayedFrame = -1;
		m_lastControlOffset = -1;
		m_lastControls = -1;
		m_lastHasButton = false;
		m_lastControlAnimationOffset = -1;
		m_skipped = false;
		m_postLoaded = false;
		m_active = true;
		m_visible = true;
		m_playing = true;
		m_jumped = false;
		m_overriding = false;
		m_attachMovieExeced = false;
		m_attachMoviePostExeced = false;
		m_movieExecCount = -1;
		m_postExecCount = -1;
		m_blendMode = (int)Constant.BLEND_MODE_NORMAL;
		m_requestedCalculateBounds = false;
		m_calculateBoundsCallbacks = new CalculateBoundsCallbacks();

		m_property = new Property(lwf);

		m_matrix0 = new Matrix();
		m_matrix1 = new Matrix();
		m_matrixForAttachedLWFs = new Matrix();
		m_colorTransform0 = new ColorTransform();
		m_colorTransform1 = new ColorTransform();
		m_colorTransformForAttachedLWFs = new ColorTransform();

		m_displayList = new Object[m_data.depths];

		m_eventHandlers = new EventHandlers();
		m_handler = new MovieEventHandlers();
		m_handler.Add(lwf.GetMovieEventHandlers(this));
		m_handler.Add(handler);

#if LWF_USE_LUA
		m_isRoot = objId == lwf.data.header.rootMovieId;
		if (m_isRoot) {
			if (parent == null)
				lwf.CallFunctionLua("Init", this);
			lwf.GetFunctionsLua(objId, out m_rootLoadFunc,
				out m_rootPostLoadFunc, out m_rootUnloadFunc,
					out m_rootEnterFrameFunc, true);
		}
		lwf.GetFunctionsLua(objId, out m_loadFunc, out m_postLoadFunc,
			out m_unloadFunc, out m_enterFrameFunc, false);

		if (m_isRoot && !String.IsNullOrEmpty(m_rootLoadFunc))
			lwf.CallFunctionLua(m_rootLoadFunc, this);
		if (m_loadFunc != String.Empty)
			lwf.CallFunctionLua(m_loadFunc, this);
#endif

		PlayAnimation(ClipEvent.LOAD);
		if (!m_handler.Empty())
			m_handler.Call(EventType.LOAD, this);

		lwf.ExecMovieCommand();
	}
Exemplo n.º 16
0
 public SumoServer()
 {
     EventHandlers.Add("Sumo:Hello", new Action <Player>(PlayerJoined));
     EventHandlers.Add("Sumo:ImOut", new Action <Player>(PlayerDied));
     EventHandlers.Add("playerDropped", new Action <Player>(PlayerDied));
 }
Exemplo n.º 17
0
 public void UnsubscribeFromEvent(uint eventType)
 {
     NativeCore.UnsubscribeFromEvent(this, eventType);
     EventHandlers.Remove(eventType);
 }
Exemplo n.º 18
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!((CommandSender)sender).CheckPermission("at.reg"))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            if (arguments.Count < 1)
            {
                response = "Usage:\nreg ((player id / name) or (all / *)) ((doors) or (all))" +
                           "\nreg clear" +
                           "\nreg list" +
                           "\nreg health (value)" +
                           "\nreg time (value)";
                return(false);
            }

            switch (arguments.At(0))
            {
            case "clear":
                if (arguments.Count != 1)
                {
                    response = "Usage: reg clear";
                    return(false);
                }

                foreach (Player Ply in Plugin.RgnHubs.Keys)
                {
                    if (Ply.ReferenceHub.TryGetComponent(out RegenerationComponent RgCom))
                    {
                        UnityEngine.Object.Destroy(RgCom);
                    }
                }

                response = "Regeneration has been removed from everyone";
                return(true);

            case "list":
                if (arguments.Count != 1)
                {
                    response = "Usage: regen list";
                    return(false);
                }

                StringBuilder PlayerLister = new StringBuilder(Plugin.RgnHubs.Count != 0 ? "Players with regeneration on:\n" : "No players currently online have regeneration on");
                if (Plugin.RgnHubs.Count == 0)
                {
                    response = PlayerLister.ToString();
                    return(true);
                }

                foreach (Player Ply in Plugin.RgnHubs.Keys)
                {
                    PlayerLister.Append(Ply.Nickname);
                    PlayerLister.Append(", ");
                }

                response = PlayerLister.ToString().Substring(0, PlayerLister.ToString().Length - 2);
                return(true);

            case "heal":
                if (arguments.Count != 2)
                {
                    response = "Usage: reg heal (value)";
                    return(false);
                }

                if (!float.TryParse(arguments.At(1), out float healvalue) || healvalue < 0.05)
                {
                    response = $"Invalid value for healing: {arguments.At(1)}";
                    return(false);
                }

                Plugin.HealthGain = healvalue;
                response          = $"Players with regeneration will heal {healvalue} HP per interval";
                return(true);

            case "time":
                if (arguments.Count != 2)
                {
                    response = "Usage: reg time (value)";
                    return(false);
                }

                if (!float.TryParse(arguments.At(1), out float healtime) || healtime < 0.05)
                {
                    response = $"Invalid value for healing time interval: {arguments.At(1)}";
                    return(false);
                }

                Plugin.HealthInterval = healtime;
                response = $"Players with regeneration will heal every {healtime} seconds";
                return(true);

            case "*":
            case "all":
                if (arguments.Count != 1)
                {
                    response = "Usage: reg (all / *)";
                    return(false);
                }

                foreach (Player Ply in Player.List)
                {
                    if (!Ply.ReferenceHub.TryGetComponent(out RegenerationComponent _))
                    {
                        Ply.ReferenceHub.gameObject.AddComponent <RegenerationComponent>();
                    }
                }

                response = "Everyone on the server can regenerate health now";
                return(true);

            default:
                if (arguments.Count != 1)
                {
                    response = "Usage: reg (player id / name)";
                    return(false);
                }

                Player Pl = Player.Get(arguments.At(0));
                if (Pl == null)
                {
                    response = $"Player not found: {arguments.At(0)}";
                    return(false);
                }

                if (!Pl.ReferenceHub.TryGetComponent(out RegenerationComponent rgnComponent))
                {
                    Pl.GameObject.AddComponent <RegenerationComponent>();
                    response = $"Regeneration is on for {Pl.Nickname}";
                }
                else
                {
                    UnityEngine.Object.Destroy(rgnComponent);
                    response = $"Regeneration is off for {Pl.Nickname}";
                }
                return(true);
            }
        }
Exemplo n.º 19
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!((CommandSender)sender).CheckPermission("at.ik"))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            if (arguments.Count < 1)
            {
                response = "Usage:\ninstakill ((player id / name) or (all / *))" +
                           "\ninstakill clear" +
                           "\ninstakill list" +
                           "\ninstakill remove (player id / name)";
                return(false);
            }

            switch (arguments.At(0))
            {
            case "clear":
                if (arguments.Count != 1)
                {
                    response = "Usage: instakill clear";
                    return(false);
                }

                foreach (Player Ply in Plugin.IkHubs.Keys)
                {
                    if (Ply.ReferenceHub.TryGetComponent(out InstantKillComponent IkCom))
                    {
                        UnityEngine.Object.Destroy(IkCom);
                    }
                }

                response = "Instant killing has been removed from everyone";
                return(true);

            case "list":
                if (arguments.Count != 1)
                {
                    response = "Usage: instakill clear";
                    return(false);
                }

                StringBuilder PlayerLister = new StringBuilder(Plugin.IkHubs.Count != 0 ? "Players with instant killing on:\n" : "No players currently online have instant killing on");
                if (Plugin.IkHubs.Count == 0)
                {
                    response = PlayerLister.ToString();
                    return(true);
                }

                foreach (Player Ply in Plugin.IkHubs.Keys)
                {
                    PlayerLister.Append(Ply.Nickname);
                    PlayerLister.Append(", ");
                }

                response = PlayerLister.ToString().Substring(0, PlayerLister.ToString().Length - 2);
                return(true);

            case "remove":
                if (arguments.Count != 2)
                {
                    response = "Usage: instakill remove (player id / name)";
                    return(false);
                }

                Player Pl = Player.Get(arguments.At(1));
                if (Pl == null)
                {
                    response = $"Player not found: {arguments.At(1)}";
                    return(false);
                }

                if (Pl.ReferenceHub.TryGetComponent(out InstantKillComponent IkComponent))
                {
                    Plugin.IkHubs.Remove(Pl);
                    UnityEngine.Object.Destroy(IkComponent);
                    response = $"Instant killing is off for {Pl.Nickname} now";
                }
                else
                {
                    response = $"Player {Pl.Nickname} does not have the ability to instantly kill others";
                }
                return(true);

            case "*":
            case "all":
                if (arguments.Count != 1)
                {
                    response = "Usage: instakill all / *";
                    return(false);
                }

                foreach (Player Ply in Player.List)
                {
                    if (!Ply.ReferenceHub.TryGetComponent(out InstantKillComponent _))
                    {
                        Ply.ReferenceHub.gameObject.AddComponent <InstantKillComponent>();
                    }
                }

                response = "Everyone on the server can instantly kill other users now";
                return(true);

            default:
                if (arguments.Count != 1)
                {
                    response = "Usage: instakill (player id / name)";
                    return(false);
                }

                Player Plyr = Player.Get(arguments.At(0));
                if (Plyr == null)
                {
                    response = $"Player not found: {arguments.At(0)}";
                    return(false);
                }

                if (!Plyr.ReferenceHub.TryGetComponent(out InstantKillComponent ikComponent))
                {
                    Plyr.GameObject.AddComponent <InstantKillComponent>();
                    response = $"Instant killing is on for {Plyr.Nickname}";
                }
                else
                {
                    UnityEngine.Object.Destroy(ikComponent);
                    response = $"Instant killing is off for {Plyr.Nickname}";
                }
                return(true);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Main()
 {
     SetTrain();
     EventHandlers.Add(GetCurrentResourceName() + ":GetTrainNetworkHandle", new Action(SetTrain));
     Tick += ManageTrainStops;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainServer()
        {
            #region command
            RegisterCommand("vmenuserver", new Action <int, List <object>, string>(async(int source, List <object> args, string rawCommand) =>
            {
                if (args != null)
                {
                    if (args.Count > 0)
                    {
                        if (args[0].ToString().ToLower() == "debug")
                        {
                            DebugMode = !DebugMode;
                            if (source < 1)
                            {
                                Debug.WriteLine($"Debug mode is now set to: {DebugMode}.");
                            }
                            else
                            {
                                Players[source].TriggerEvent("chatMessage", $"vMenu Debug mode is now set to: {DebugMode}.");
                            }
                            return;
                        }
                        else if (args[0].ToString().ToLower() == "unban" && (source < 1))
                        {
                            if (args.Count() > 1 && !string.IsNullOrEmpty(args[1].ToString()))
                            {
                                string name   = args[1].ToString().Trim();
                                name          = name.Replace("\"", "");
                                name          = BanManager.GetSafePlayerName(name);
                                var bans      = await BanManager.GetBanList();
                                var banRecord = bans.Find(b => { return(b.playerName == name); });
                                if (banRecord.playerName != null)
                                {
                                    if (await BanManager.RemoveBan(banRecord))
                                    {
                                        Debug.WriteLine("Player has been successfully unbanned.");
                                    }
                                    else
                                    {
                                        Debug.WriteLine("Could not unban the player, are you sure this player is actually banned?");
                                    }
                                }
                                else
                                {
                                    Debug.WriteLine($"Could not find a banned player by the name of '{name}'.");
                                }
                                bans = null;
                            }
                            else
                            {
                                Debug.WriteLine("You did not specify a player to unban, you must enter the FULL playername. Usage: vmenuserver unban \"playername\"");
                            }
                            return;
                        }
                        else if (args[0].ToString().ToLower() == "weather")
                        {
                            if (args.Count < 2 || string.IsNullOrEmpty(args[1].ToString()))
                            {
                                Debug.WriteLine("[vMenu] Invalid command syntax. Use 'vmenuserver weather <weatherType>' instead.");
                            }
                            else
                            {
                                string wtype = args[1].ToString().ToUpper();
                                if (weatherTypes.Contains(wtype))
                                {
                                    TriggerEvent("vMenu:UpdateServerWeather", wtype, blackout, dynamicWeather);
                                    Debug.WriteLine($"[vMenu] Weather is now set to: {wtype}");
                                }
                                else if (wtype.ToLower() == "dynamic")
                                {
                                    if (args.Count == 3 && !string.IsNullOrEmpty(args[2].ToString()))
                                    {
                                        if ((args[2].ToString().ToLower() ?? $"{dynamicWeather}") == "true")
                                        {
                                            TriggerEvent("vMenu:UpdateServerWeather", currentWeather, blackout, true);
                                            Debug.WriteLine("[vMenu] Dynamic weather is now turned on.");
                                        }
                                        else if ((args[2].ToString().ToLower() ?? $"{dynamicWeather}") == "false")
                                        {
                                            TriggerEvent("vMenu:UpdateServerWeather", currentWeather, blackout, false);
                                            Debug.WriteLine("[vMenu] Dynamic weather is now turned off.");
                                        }
                                        else
                                        {
                                            Debug.WriteLine("[vMenu] Invalid command usage. Correct syntax: vmenuserver weather dynamic <true|false>");
                                        }
                                    }
                                    else
                                    {
                                        Debug.WriteLine("[vMenu] Invalid command usage. Correct syntax: vmenuserver weather dynamic <true|false>");
                                    }
                                }
                                else
                                {
                                    Debug.WriteLine("[vMenu] This weather type is not valid!");
                                }
                            }
                        }
                        else if (args[0].ToString().ToLower() == "time")
                        {
                            if (args.Count == 2)
                            {
                                if (args[1].ToString().ToLower() == "freeze")
                                {
                                    TriggerEvent("vMenu:UpdateServerTime", currentHours, currentMinutes, !freezeTime);
                                    Debug.WriteLine($"Time is now {(freezeTime ? "frozen" : "not frozen")}.");
                                }
                                else
                                {
                                    Debug.WriteLine("Invalid syntax. Use: ^5vmenuserver time <freeze|<hour> <minute>>^7 instead.");
                                }
                            }
                            else if (args.Count > 2)
                            {
                                if (int.TryParse(args[1].ToString(), out int hour))
                                {
                                    if (int.TryParse(args[2].ToString(), out int minute))
                                    {
                                        if (hour >= 0 && hour < 24)
                                        {
                                            if (minute >= 0 && minute < 60)
                                            {
                                                TriggerEvent("vMenu:UpdateServerTime", hour, minute, freezeTime);
                                                Debug.WriteLine($"Time is now {(hour < 10 ? ("0" + hour.ToString()) : hour.ToString())}:{(minute < 10 ? ("0" + minute.ToString()) : minute.ToString())}.");
                                            }
                                            else
                                            {
                                                Debug.WriteLine("Invalid minute provided. Value must be between 0 and 59.");
                                            }
                                        }
                                        else
                                        {
                                            Debug.WriteLine("Invalid hour provided. Value must be between 0 and 23.");
                                        }
                                    }
                                    else
                                    {
                                        Debug.WriteLine("Invalid syntax. Use: ^5vmenuserver time <freeze|<hour> <minute>>^7 instead.");
                                    }
                                }
                                else
                                {
                                    Debug.WriteLine("Invalid syntax. Use: ^5vmenuserver time <freeze|<hour> <minute>>^7 instead.");
                                }
                            }
                            else
                            {
                                Debug.WriteLine("Invalid syntax. Use: ^5vmenuserver time <freeze|<hour> <minute>>^7 instead.");
                            }
                        }
                        else if (args[0].ToString().ToLower() == "ban" && source < 1)  // only do this via server console (server id < 1)
                        {
                            if (args.Count > 3)
                            {
                                Player p = null;

                                bool findByServerId = args[1].ToString().ToLower() == "id";
                                string identifier   = args[2].ToString().ToLower();

                                if (findByServerId)
                                {
                                    if (Players.Any(player => player.Handle == identifier))
                                    {
                                        p = Players.Single(pl => pl.Handle == identifier);
                                    }
                                    else
                                    {
                                        Debug.WriteLine("[vMenu] Could not find this player, make sure they are online.");
                                        return;
                                    }
                                }
                                else
                                {
                                    if (Players.Any(player => player.Name.ToLower() == identifier.ToLower()))
                                    {
                                        p = Players.Single(pl => pl.Name.ToLower() == identifier.ToLower());
                                    }
                                    else
                                    {
                                        Debug.WriteLine("[vMenu] Could not find this player, make sure they are online.");
                                        return;
                                    }
                                }

                                string reason = "Banned by staff for:";
                                args.GetRange(3, args.Count - 3).ForEach(arg => reason += " " + arg);

                                if (p != null)
                                {
                                    var ban = new BanManager.BanRecord()
                                    {
                                        bannedBy    = "Server Console",
                                        bannedUntil = new DateTime(3000, 1, 1),
                                        banReason   = reason,
                                        identifiers = p.Identifiers.ToList(),
                                        playerName  = BanManager.GetSafePlayerName(p.Name)
                                    };

                                    if (await BanManager.AddBan(ban))
                                    {
                                        BanManager.BanLog($"[vMenu] Player {p.Name}^7 has been banned by Server Console for [{reason}].");
                                        TriggerEvent("vMenu:BanSuccessful", JsonConvert.SerializeObject(ban).ToString());
                                        string timeRemaining = BanManager.GetRemainingTimeMessage(ban.bannedUntil.Subtract(DateTime.Now));
                                        p.Drop($"You are banned from this server. Ban time remaining: {timeRemaining}. Banned by: {ban.bannedBy}. Ban reason: {ban.banReason}. Additional information: {vMenuShared.ConfigManager.GetSettingsString(vMenuShared.ConfigManager.Setting.vmenu_default_ban_message_information)}.");
                                    }
                                    else
                                    {
                                        // ban failed
                                        Debug.WriteLine("[vMenu] Banning player failed, reason unknown.");
                                    }
                                }
                                else
                                {
                                    Debug.WriteLine("[vMenu] Player not found, could not ban player.");
                                }
                            }
                            else
                            {
                                Debug.WriteLine("[vMenu] Not enough arguments, syntax: ^5vmenuserver ban <id|name> <server id|username> <reason>^7.");
                            }
                        }
                        else if (args[0].ToString().ToLower() == "help")
                        {
                            Debug.WriteLine("Available commands:");
                            Debug.WriteLine("(server console only): vmenuserver ban <id|name> <server id|username> <reason>");
                            Debug.WriteLine("(server console only): vmenuserver unban <\"player name\">");
                            Debug.WriteLine("vmenuserver weather <new weather type | dynamic <true | false>>");
                            Debug.WriteLine("vmenuserver time <freeze|<hour> <minute>>");
                        }
                        else if (args[0].ToString().ToLower() == "migrate" && source < 1)
                        {
                            BanManager.MigrateBansToDatabase();
                        }
                        else
                        {
                            Debug.WriteLine($"vMenu is currently running version: {Version}. Try ^5vmenuserver help^7 for info.");
                        }
                    }
                    else
                    {
                        Debug.WriteLine($"vMenu is currently running version: {Version}. Try ^5vmenuserver help^7 for info.");
                    }
                }
                else
                {
                    Debug.WriteLine($"vMenu is currently running version: {Version}. Try ^5vmenuserver help^7 for info.");
                }
            }), true);
            #endregion

            // name check
            if (GetCurrentResourceName() != "vMenu")
            {
                Exception InvalidNameException = new Exception("\r\n\r\n^1[vMenu] INSTALLATION ERROR!\r\nThe name of the resource is not valid. " +
                                                               "Please change the folder name from '^3" + GetCurrentResourceName() + "^1' to '^2vMenu^1' (case sensitive) instead!\r\n\r\n\r\n^7");
                try
                {
                    throw InvalidNameException;
                }
                catch (Exception e)
                {
                    Debug.Write(e.Message);
                }
            }
            else
            {
                // Add event handlers.
                EventHandlers.Add("vMenu:SummonPlayer", new Action <Player, int>(SummonPlayer));
                EventHandlers.Add("vMenu:KillPlayer", new Action <Player, int>(KillPlayer));
                EventHandlers.Add("vMenu:KickPlayer", new Action <Player, int, string>(KickPlayer));
                EventHandlers.Add("vMenu:RequestPermissions", new Action <Player>(vMenuShared.PermissionsManager.SetPermissionsForPlayer));
                EventHandlers.Add("vMenu:UpdateServerWeather", new Action <string, bool, bool>(UpdateWeather));
                EventHandlers.Add("vMenu:UpdateServerWeatherCloudsType", new Action <bool>(UpdateWeatherCloudsType));
                EventHandlers.Add("vMenu:UpdateServerTime", new Action <int, int, bool>(UpdateTime));
                //EventHandlers.Add("vMenu:DisconnectSelf", new Action<Player>(DisconnectSource));
                EventHandlers.Add("vMenu:ClearArea", new Action <float, float, float>(ClearAreaNearPos));
                EventHandlers.Add("vMenu:GetPlayerIdentifiers", new Action <int, NetworkCallbackDelegate>((TargetPlayer, CallbackFunction) =>
                {
                    List <string> data = new List <string>();
                    Players[TargetPlayer].Identifiers.ToList().ForEach(e =>
                    {
                        if (!e.Contains("ip:"))
                        {
                            data.Add(e);
                        }
                    });
                    CallbackFunction(JsonConvert.SerializeObject(data));
                }));
                EventHandlers.Add("vMenu:GetOutOfCar", new Action <Player, int, int>(GetOutOfCar));
                EventHandlers.Add("vMenu:SendMessageToPlayer", new Action <Player, int, string>(SendPrivateMessage));
                EventHandlers.Add("vMenu:PmsDisabled", new Action <Player, string>(NotifySenderThatDmsAreDisabled));
                EventHandlers.Add("vMenu:SaveTeleportLocation", new Action <Player, string>(AddTeleportLocation));
                EventHandlers.Add("vMenu:DumpLanguages", new Action <Player, string>(DumpLanguages));

                // check addons file for errors
                string addons = LoadResourceFile(GetCurrentResourceName(), "config/addons.json") ?? "{}";
                try
                {
                    JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(addons);
                    // If the above crashes, then the json is invalid and it'll throw warnings in the console.
                }
                catch (JsonReaderException ex)
                {
                    Debug.WriteLine($"\n\n^1[vMenu] [ERROR] ^7Your addons.json file contains a problem! Error details: {ex.Message}\n\n");
                }

                // check if permissions are setup (correctly)
                if (!GetSettingsBool(Setting.vmenu_use_permissions))
                {
                    Debug.WriteLine("^3[vMenu] [WARNING] vMenu is set up to ignore permissions!\nIf you did this on purpose then you can ignore this warning.\nIf you did not set this on purpose, then you must have made a mistake while setting up vMenu.\nPlease read the vMenu documentation (^5https://docs.vespura.com/vmenu^3).\nMost likely you are not executing the permissions.cfg (correctly).^7");
                }

                // manage weather and time sync stuff for first setup.
                dynamicWeather = GetSettingsBool(Setting.vmenu_enable_dynamic_weather);
                if (GetSettingsInt(Setting.vmenu_dynamic_weather_timer) != -1)
                {
                    dynamicWeatherMinutes = GetSettingsInt(Setting.vmenu_dynamic_weather_timer);
                }

                string defaultWeather = GetSettingsString(Setting.vmenu_default_weather);

                if (!string.IsNullOrEmpty(defaultWeather))
                {
                    if (weatherTypes.Contains(defaultWeather))
                    {
                        currentWeather = defaultWeather;
                    }
                }

                currentHours   = GetSettingsInt(Setting.vmenu_default_time_hour);
                currentHours   = (currentHours >= 0 && currentHours < 24) ? currentHours : 9;
                currentMinutes = GetSettingsInt(Setting.vmenu_default_time_min);
                currentMinutes = (currentMinutes >= 0 && currentMinutes < 60) ? currentMinutes : 0;

                minuteClockSpeed = GetSettingsInt(Setting.vmenu_ingame_minute_duration);
                minuteClockSpeed = (minuteClockSpeed > 0) ? minuteClockSpeed : 2000;

                // Start the loops
                Tick += WeatherLoop;
                Tick += TimeLoop;

                if (GetSettingsBool(Setting.vmenu_bans_use_database) && !string.IsNullOrEmpty(LoadResourceFile(GetCurrentResourceName(), "bans.json")))
                {
                    Log("^3You have setup vMenu to use the SQLite database for storing banned players, however you also have a bans.json file!\nPlease check your configuration and only use ONE of these methods at a time.\nIf you no longer want to use the bans.json file, feel free to delete it after migrating to the database!^7", LogLevel.warning);
                }
            }
        }
Exemplo n.º 22
0
 public Playable(Plugin plugin)
 {
     Methods       = new Methods(plugin);
     EventHandlers = new EventHandlers(plugin);
 }
Exemplo n.º 23
0
 public DamageEvents()
 {
     EventHandlers.Add("gameEventTriggered", new Action <string, List <Object> >(GameEventTriggered));
     if (GetResourceMetadata(GetCurrentResourceName(), "enable_debug_prints_for_events", 0).ToLower() == "true")
     {
         EventHandlers.Add(eventName + ":VehicleDestroyed", new Action <int, int, uint, bool, int>((a, b, c, d, e) =>
         {
             Debug.WriteLine("event: VehicleDestroyed");
             Debug.WriteLine($"vehicle: {a}");
             Debug.WriteLine($"attacker: {b}");
             Debug.WriteLine($"weapon hash: {c}");
             Debug.WriteLine($"was melee damage?: {d}");
             Debug.WriteLine($"vehicle damage flag: {e}");
         }));
         EventHandlers.Add(eventName + ":PedKilledByVehicle", new Action <int, int>((a, b) =>
         {
             Debug.WriteLine("event: PedKilledByVehicle");
             Debug.WriteLine($"victim: {a}");
             Debug.WriteLine($"vehicle: {b}");
         }));
         EventHandlers.Add(eventName + ":PedKilledByPlayer", new Action <int, int, uint, bool>((a, b, c, d) =>
         {
             Debug.WriteLine("event: PedKilledByPlayer");
             Debug.WriteLine($"victim: {a}");
             Debug.WriteLine($"player: {b}");
             Debug.WriteLine($"weapon hash: {c}");
             Debug.WriteLine($"was melee damage?: {d}");
         }));
         EventHandlers.Add(eventName + ":PedKilledByPed", new Action <int, int, uint, bool>((a, b, c, d) =>
         {
             Debug.WriteLine("event: PedKilledByPed");
             Debug.WriteLine($"victim: {a}");
             Debug.WriteLine($"attacker: {b}");
             Debug.WriteLine($"weapon hash: {c}");
             Debug.WriteLine($"was melee damage?: {d}");
         }));
         EventHandlers.Add(eventName + ":PedDied", new Action <int, int, uint, bool>((a, b, c, d) =>
         {
             Debug.WriteLine("event: PedDied");
             Debug.WriteLine($"victim: {a}");
             Debug.WriteLine($"attacker: {b}");
             Debug.WriteLine($"weapon hash: {c}");
             Debug.WriteLine($"was melee damage?: {d}");
         }));
         EventHandlers.Add(eventName + ":EntityKilled", new Action <int, int, uint, bool>((a, b, c, d) =>
         {
             Debug.WriteLine("event: EntityKilled");
             Debug.WriteLine($"victim: {a}");
             Debug.WriteLine($"attacker: {b}");
             Debug.WriteLine($"weapon hash: {c}");
             Debug.WriteLine($"was melee damage?: {d}");
         }));
         EventHandlers.Add(eventName + ":VehicleDamaged", new Action <int, int, uint, bool, int>((a, b, c, d, e) =>
         {
             Debug.WriteLine("event: VehicleDamaged");
             Debug.WriteLine($"vehicle: {a}");
             Debug.WriteLine($"attacker: {b}");
             Debug.WriteLine($"weapon hash: {c}");
             Debug.WriteLine($"was melee damage?: {d}");
             Debug.WriteLine($"vehicle damage flag: {e}");
         }));
         EventHandlers.Add(eventName + ":EntityDamaged", new Action <int, int, uint, bool>((a, b, c, d) =>
         {
             Debug.WriteLine("event: EntityDamaged");
             Debug.WriteLine($"victim: {a}");
             Debug.WriteLine($"attacker: {b}");
             Debug.WriteLine($"weapon hash: {c}");
             Debug.WriteLine($"was melee damage?: {d}");
         }));
     }
 }
Exemplo n.º 24
0
 public virtual void InvokeEvent(INetworkMgr <IChannelNetworkComponent> sender, bool sig) => EventHandlers?.Invoke(sender, sig);
Exemplo n.º 25
0
 public static void Initialize(string appID, EventHandlers handlers)
 {
     Discord_Initialize(appID, ref handlers, 1, String.Empty);
 }
Exemplo n.º 26
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (arguments.Count != 1)
            {
                response = "Usage: id ((player id / name) or (all / *))";
                return(false);
            }

            switch (arguments.At(0))
            {
            case "*":
            case "all":
                StringBuilder Builder = StringBuilderPool.Shared.Rent();
                if (Player.List.Count() == 0)
                {
                    Builder.AppendLine("There are no players currently online in the server");
                    string msg = Builder.ToString();
                    StringBuilderPool.Shared.Return(Builder);
                    response = msg;
                    return(true);
                }
                else
                {
                    Builder.AppendLine("List of ID's on the server:");
                    foreach (Player Ply in Player.List)
                    {
                        Builder.Append(Ply.Nickname);
                        Builder.Append(" - ");
                        Builder.Append(Ply.UserId);
                        Builder.Append(" - ");
                        Builder.AppendLine(Ply.Id.ToString());
                    }
                    string msg = Builder.ToString();
                    StringBuilderPool.Shared.Return(Builder);
                    response = msg;
                    return(true);
                }

            default:
                Player Pl;
                if (String.IsNullOrWhiteSpace(arguments.At(0)))
                {
                    if (!(sender is PlayerCommandSender plysend))
                    {
                        response = "You must be in-game to run this command if you specify yourself!";
                        return(false);
                    }

                    Pl = Player.Get(plysend.ReferenceHub);
                }
                else
                {
                    Pl = Player.Get(arguments.At(0));
                    if (Pl == null)
                    {
                        response = "Player not found";
                        return(false);
                    }
                }

                response = $"{Pl.Nickname} - {Pl.UserId} - {Pl.Id}";
                return(true);
            }
        }
Exemplo n.º 27
0
 public void On(string eventName, EventHandler handler)
 {
     EventHandlers.Add(eventName, handler);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Triggering test event
 /// Will notify event handlers
 /// </summary>
 /// <typeparam name="T">Information type</typeparam>
 /// <param name="getAction">Event handle method</param>
 /// <param name="info">Information</param>
 public void TriggerEvent <T>(Func <ITestEventHandler, Action <T> > getAction, T info)
 {
     EventHandlers.ForEach(h => getAction(h)(info));
 }
Exemplo n.º 29
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            if (!((CommandSender)sender).CheckPermission("at.dummy"))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            Player Sender = Player.Get(((CommandSender)sender).Nickname);

            if (arguments.Count < 1)
            {
                response = "Usage:\ndummy ((player id / name) or (all / *)) (RoleType) (x value) (y value) (z value)" +
                           "\ndummy clear (player id / name) (minimum index) (maximum index)" +
                           "\ndummy clearall" +
                           "\ndummy count (player id / name) ";
                return(false);
            }

            switch (arguments.At(0))
            {
            case "clear":
                if (arguments.Count != 4)
                {
                    response = "Usage: dummy clear (player id / name) (minimum index) (maximum index)\nNote: Minimum < Maximum, you can remove from a range of dummies a user spawns";
                    return(false);
                }

                Player Ply = Player.Get(arguments.At(1));
                if (Ply == null)
                {
                    response = $"Player not found: {arguments.At(1)}";
                    return(false);
                }

                if (!int.TryParse(arguments.At(2), out int Min) && Min < 0)
                {
                    response = $"Invalid value for minimum index: {arguments.At(2)}";
                    return(false);
                }

                if (!int.TryParse(arguments.At(3), out int Max) && Max < 0)
                {
                    response = $"Invalid value for maximum index: {arguments.At(3)}";
                    return(false);
                }

                if (Max < Min)
                {
                    response = $"{Max} is not greater than {Min}";
                    return(false);
                }

                if (!Plugin.DumHubs.TryGetValue(Ply, out List <GameObject> objs))
                {
                    response = $"{Ply.Nickname} has not spawned in any dummies in";
                    return(false);
                }

                if (Min > objs.Count)
                {
                    response = $"{Min} (minimum) is higher than the number of dummies {Ply.Nickname} spawned! (Which is {objs.Count})";
                    return(false);
                }

                if (Max > objs.Count)
                {
                    response = $"{Max} (maximum) is higher than the number of dummies {Ply.Nickname} spawned! (Which is {objs.Count})";
                    return(false);
                }

                Min = Min == 0 ? 0 : Min - 1;
                Max = Max == 0 ? 0 : Max - 1;

                for (int i = Min; i <= Max; i++)
                {
                    UnityEngine.Object.Destroy(objs.ElementAt(i));
                    objs[i] = null;
                }
                objs.RemoveAll(r => r == null);

                response = $"All dummies from {Min + 1} to {Max + 1} have been cleared from Player {Ply.Nickname}";
                return(true);

            case "clearall":
                if (arguments.Count != 1)
                {
                    response = "Usage: dummy clearall";
                    return(false);
                }

                foreach (KeyValuePair <Player, List <GameObject> > Dummy in Plugin.DumHubs)
                {
                    foreach (GameObject Dum in Dummy.Value)
                    {
                        UnityEngine.Object.Destroy(Dum);
                    }
                    Dummy.Value.Clear();
                }

                Plugin.DumHubs.Clear();
                response = $"All spawned dummies have now been removed";
                return(true);

            case "count":
                if (arguments.Count != 2)
                {
                    response = "Usage: dummy count (player id / name)";
                    return(false);
                }

                Player Plyr = Player.Get(arguments.At(1));
                if (Plyr == null)
                {
                    response = $"Player not found: {arguments.At(1)}";
                    return(false);
                }

                if (!Plugin.DumHubs.TryGetValue(Plyr, out List <GameObject> obj) || obj.Count == 0)
                {
                    response = $"{Plyr.Nickname} has not spawned in any dummies in";
                    return(false);
                }

                response = $"{Plyr.Nickname} has spawned in {(obj.Count != 1 ? $"{obj.Count} dummies" : $"{obj.Count} dummy")}";
                return(true);
Exemplo n.º 30
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     EventHandlers.Add(ChadderUI.Source.db.LocalUser, (s, e) => InvalidateData());
 }
Exemplo n.º 31
0
 public VehicleSpawner()
 {
     EventHandlers.Add("onClientResourceStart", new Action <string>(GiveVehicle));
     EventHandlers.Add("simpleEvent", new Action <string>(ServerCallback));
     EventHandlers.Add("returnVehicle", new Action <string, float, float, float, float>(ReturnVehicle));
 }
Exemplo n.º 32
0
        protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            EventHandlers.LogCommandUsed((CommandSender)sender, EventHandlers.FormatArguments(arguments, 0));
            MoveType Value = MoveType.Move;

            if (!((CommandSender)sender).CheckPermission("at.tut"))
            {
                response = "You do not have permission to use this command";
                return(false);
            }

            switch (arguments.Count)
            {
            case 0:
            case 1:
                if (arguments.Count == 0)
                {
                    Ply = Player.Get(((CommandSender)sender).Nickname);
                }
                else
                {
                    if (String.IsNullOrWhiteSpace(arguments.At(0)))
                    {
                        response = "Please do not try to put a space as tutorial";
                        return(false);
                    }

                    Ply = Player.Get(arguments.At(0));
                    if (Ply == null)
                    {
                        response = $"Player not found: {arguments.At(0)}";
                        return(false);
                    }
                }

                Value = MoveType.Move;
                DoTutorialFunction(Ply, Value, out response);
                return(true);

            case 2:
                if (String.IsNullOrWhiteSpace(arguments.At(0)))
                {
                    response = "Please do not try to put a space as tutorial";
                    return(false);
                }

                Ply = Player.Get(arguments.At(0));
                if (Ply == null)
                {
                    response = $"Player not found: {arguments.At(0)}";
                    return(false);
                }

                if (!Enum.TryParse(arguments.At(1), true, out MoveType Type))
                {
                    response = $"Invalid value for move type: {arguments.At(1)}";
                    return(false);
                }
                Value = Type;
                DoTutorialFunction(Ply, Value, out response);
                return(true);

            default:
                response = "Usage: tutorial (optional: id / name) (optional: stay / move)";
                return(false);
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainServer()
        {
            RegisterCommand("vmenuserver", new Action <dynamic, List <dynamic>, string>((dynamic source, List <dynamic> args, string rawCommand) =>
            {
                if (args != null)
                {
                    if (args.Count > 0)
                    {
                        if (args[0].ToString().ToLower() == "debug")
                        {
                            DebugMode = !DebugMode;
                            if (source == 0)
                            {
                                Debug.WriteLine($"Debug mode is now set to: {DebugMode}.");
                            }
                            else
                            {
                                new PlayerList()[source].TriggerEvent("chatMessage", $"vMenu Debug mode is now set to: {DebugMode}.");
                            }
                        }
                    }
                    else
                    {
                        Debug.WriteLine($"vMenu is currently running version: {Version}.");
                    }
                }
            }), true);

            if (GetCurrentResourceName() != "vMenu")
            {
                Exception InvalidNameException = new Exception("\r\n\r\n[vMenu] INSTALLATION ERROR!\r\nThe name of the resource is not valid. " +
                                                               "Please change the folder name from '" + GetCurrentResourceName() + "' to 'vMenu' (case sensitive) instead!\r\n\r\n\r\n");
                try
                {
                    throw InvalidNameException;
                }
                catch (Exception e)
                {
                    Debug.Write(e.Message);
                }
            }
            else
            {
                // Add event handlers.
                EventHandlers.Add("vMenu:SummonPlayer", new Action <Player, int>(SummonPlayer));
                EventHandlers.Add("vMenu:KillPlayer", new Action <Player, int>(KillPlayer));
                EventHandlers.Add("vMenu:KickPlayer", new Action <Player, int, string>(KickPlayer));
                EventHandlers.Add("vMenu:RequestPermissions", new Action <Player>(SendPermissionsAsync));
                EventHandlers.Add("vMenu:UpdateServerWeather", new Action <string, bool, bool>(UpdateWeather));
                EventHandlers.Add("vMenu:UpdateServerWeatherCloudsType", new Action <bool>(UpdateWeatherCloudsType));
                EventHandlers.Add("vMenu:UpdateServerTime", new Action <int, int, bool>(UpdateTime));
                EventHandlers.Add("vMenu:DisconnectSelf", new Action <Player>(DisconnectSource));

                string addons = LoadResourceFile(GetCurrentResourceName(), "addons.json") ?? LoadResourceFile(GetCurrentResourceName(), "config/addons.json") ?? "{}";
                var    json   = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(addons);

                if (json.ContainsKey("vehicles"))
                {
                    foreach (var modelName in json["vehicles"])
                    {
                        Log("Addon vehicle loaded: " + modelName);
                        addonVehicles.Add(modelName);
                    }
                }

                if (json.ContainsKey("peds"))
                {
                    foreach (var modelName in json["peds"])
                    {
                        Log("Addon ped loaded:" + modelName);
                        addonPeds.Add(modelName);
                    }
                }

                if (json.ContainsKey("weapons"))
                {
                    foreach (var modelName in json["weapons"])
                    {
                        Log("Addon weapon loaded:" + modelName);
                        addonWeapons.Add(modelName);
                    }
                }

                if ((GetConvar("vMenuDisableDynamicWeather", "false") ?? "false").ToLower() == "true")
                {
                    dynamicWeather = false;
                }
                Tick += WeatherLoop;
                Tick += TimeLoop;
            }
        }
Exemplo n.º 34
0
        protected override void OnInitialized()
        {
            base.OnInitialized();

            EventHandlers.Add <StoryEntriesChanged>(this);
        }
Exemplo n.º 35
0
 public Data()
 {
     EventHandlers.Add("Sync:Client:Data:Get", new Action <int, dynamic>(GetServer));
     EventHandlers.Add("Sync:Client:Data:GetAll", new Action <int, dynamic>(GetAllServer));
     EventHandlers.Add("Sync:Client:Data:Has", new Action <int, bool>(HasServer));
 }
Exemplo n.º 36
0
 public void Dispose()
 {
     EventHandlers.Remove <StoryEntriesChanged>(this);
 }
Exemplo n.º 37
0
 public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);
Exemplo n.º 38
0
        void Player_OnMovement(object sender, EventHandlers.PlayerMovementEventArgs e)
        {
            var distance = 0f;
            switch (e.Player.EntityType)
            {
                case EntityType.Generator:
                    var gen = (PowerGenerator)e.Player;
                    distance = Vector2.Distance(e.NewLocation, gen.Gunner.Location);
                    break;
                case EntityType.Gunner:
                    var gun = (Gunner)e.Player;
                    distance = Vector2.Distance(e.NewLocation, gun.Generator.Location);
                    break;
            }

            if (distance > MaxPlayerDistance)
            {
                e.Handled = true;
                e.NewLocation = e.CurrentLocation;
            }
        }