Example #1
0
        /// <summary>
        /// Called when we connect to a server
        /// </summary>
        /// <param name="connection"></param>
        public override void Connected(BoltConnection connection)
        {
            StaticCoroutineRunner.StartStaticCoroutine(MultiplayerPlayerNameManager.DownloadDataFromFirebase());

            ModBotUserIdentifier.Instance.OnLocalClientConnected();
            ModsManager.Instance.PassOnMod.OnClientConnectedToServer();
        }
            public static bool MultiplayerPlayerInfoState_GetOrPrepareSafeDisplayName_Prefix(MultiplayerPlayerInfoState __instance, Action <string> onSafeDisplayNameReceived, ref bool ____isSafeDisplayNameBeingPrepared)
            {
                if (string.IsNullOrEmpty(Accessor.GetPrivateProperty <MultiplayerPlayerInfoState, string>("SafeDisplayName", __instance)))
                {
                    Action <string> singleCallback = null;
                    singleCallback = delegate(string safeDisplayName)
                    {
                        __instance.OnSafeDisplayNamePrepared -= singleCallback;
                        Action <string> onSafeDisplayNameReceived3 = onSafeDisplayNameReceived;
                        if (onSafeDisplayNameReceived3 != null)
                        {
                            onSafeDisplayNameReceived3(MultiplayerPlayerNameManager.GetFullPrefixForPlayfabID(__instance.state.PlayFabID) + MultiplayerPlayerNameManager.GetNameForPlayfabID(__instance.state.PlayFabID, safeDisplayName));
                        }
                    };

                    __instance.OnSafeDisplayNamePrepared += singleCallback;

                    if (____isSafeDisplayNameBeingPrepared)
                    {
                        return(false);
                    }

                    ____isSafeDisplayNameBeingPrepared = true;
                    ProfanityChecker.FilterForProfanities(__instance.state.DisplayName, delegate(string preparedName)
                    {
                        Accessor.SetPrivateProperty("SafeDisplayName", __instance, preparedName);
                        Accessor.SetPrivateField("_isSafeDisplayNameBeingPrepared", __instance, false);

                        EventInfo safeDisplayNamePreparedEvent = typeof(MultiplayerPlayerInfoState).GetEvent("OnSafeDisplayNamePrepared", BindingFlags.Public | BindingFlags.Instance);
                        if (safeDisplayNamePreparedEvent.RaiseMethod != null)
                        {
                            safeDisplayNamePreparedEvent.RaiseMethod.Invoke(__instance, new object[] { Accessor.GetPrivateProperty <MultiplayerPlayerInfoState, string>("SafeDisplayName", __instance) });
                        }
                    });
                }
                else
                {
                    Action <string> onSafeDisplayNameReceived2 = onSafeDisplayNameReceived;
                    if (onSafeDisplayNameReceived2 != null)
                    {
                        onSafeDisplayNameReceived2(MultiplayerPlayerNameManager.GetFullPrefixForPlayfabID(__instance.state.PlayFabID) + MultiplayerPlayerNameManager.GetNameForPlayfabID(__instance.state.PlayFabID, Accessor.GetPrivateProperty <MultiplayerPlayerInfoState, string>("SafeDisplayName", __instance)));
                    }
                }

                return(false);
            }
            public static bool CharacterNameTagManager_updateNameTag_Prefix(Character character)
            {
                if (!GameModeManager.ShouldCreateNameTagsForOtherPlayers())
                {
                    return(false);
                }

                MultiplayerPlayerInfoManager.Instance.TryGetDisplayName(character.state.PlayFabID, delegate(string displayName)
                {
                    if (displayName != null && !character.HasNameTag())
                    {
                        displayName = MultiplayerPlayerNameManager.GetFullPrefixForPlayfabID(character.state.PlayFabID) + MultiplayerPlayerNameManager.GetNameForPlayfabID(character.state.PlayFabID, displayName);
                        CharacterNameTagManager.Instance.StartCoroutine(Accessor.CallPrivateMethod <CharacterNameTagManager, IEnumerator>("addNameTagWithDelay", CharacterNameTagManager.Instance, new object[] { character, displayName }));
                    }
                });

                return(false);
            }
Example #4
0
        /// <summary>
        /// The same as <see cref="Mod.OnCommandRan(string)"/>, but called in Mod-Bot
        /// </summary>
        /// <param name="command"></param>
        public static void OnCommandRan(string command)
        {
            string[] subCommands = command.ToLower().Split(' ');

            if (subCommands[0] == "ignoreallcrashes")
            {
                if (subCommands.Length < 2)
                {
                    debug.Log("Usage: ignoreallcrashes [1 - 0], [on - off], [true, false]");
                    return;
                }

                bool value;
                if (subCommands[1] == "1" || subCommands[1] == "on" || subCommands[1] == "true")
                {
                    value = true;
                }
                else if (subCommands[1] == "0" || subCommands[1] == "off" || subCommands[1] == "false")
                {
                    value = false;
                }
                else
                {
                    debug.Log("Usage: ignoreallcrashes[1 - 0], [on - off], [true, false]");
                    return;
                }

                IgnoreCrashesManager.SetIsIgnoringCrashes(value);
            }

            if (subCommands[0] == "crash")
            {
                DelegateScheduler.Instance.Schedule(Crash, 1f);
            }

            if (subCommands[0] == "unittest")
            {
                if (subCommands.Length > 1)
                {
                    bool foundUnitTest = ModBotUnitTestManager.TryRunUnitTest(subCommands[1]);
                    if (!foundUnitTest)
                    {
                        debug.Log("Unit test failed: Unit test \"" + subCommands[1] + "\" not found", Color.red);
                        return;
                    }
                }

                ModBotUnitTestManager.RunAllUnitTests();
            }

            if (subCommands[0] == "getplayfabids")
            {
                debug.Log("spawned players playfabids: ");
                List <FirstPersonMover> players = CharacterTracker.Instance.GetAllPlayers();
                foreach (FirstPersonMover player in players)
                {
                    string playfabID = player.state.PlayFabID;
                    MultiplayerPlayerInfoManager.Instance.TryGetDisplayName(playfabID, delegate(string displayName)
                    {
                        if (displayName != null)
                        {
                            debug.Log(displayName + ": " + playfabID);
                        }
                    });
                }
            }
            if (subCommands[0] == "redownloaddata")
            {
                StaticCoroutineRunner.StartStaticCoroutine(MultiplayerPlayerNameManager.DownloadDataFromFirebase());
                debug.Log("redownloading data...");
            }
        }