示例#1
0
        IEnumerator TeleportWithWait(PLPlayer player, PlayerPos info, int inID)
        {
            yield return(new WaitForEndOfFrame());

            while (PulsarModLoader.Utilities.HelperMethods.GetPlayerFromPlayerID(inID).GetPawn() == null || PulsarModLoader.Utilities.HelperMethods.GetPlayerFromPlayerID(inID).GetPawn().transform?.position == null)
            {
                yield return(new WaitForEndOfFrame());
            }
            int pause = 0;

            while (pause < 5)
            {
                yield return(new WaitForEndOfFrame());

                pause++;
            }
            player.photonView.RPC("NetworkTeleportToSubHub", PhotonTargets.All, new object[]
            {
                info.hubid,
                info.ttiid
            });
            player.photonView.RPC("RecallPawnToPos", PhotonTargets.All, new object[]
            {
                info.pos
            });
            Plugin.pos.Remove(player.GetClassID());
#if DEBUG
            PulsarPluginLoader.Utilities.Logger.Info($"Apply for {inID}");
#endif
        }
示例#2
0
 private static void Postfix(ref List <PLPlayer> ___LocalCachedPlayerByClass)
 {
     for (int i = 0; i < 5; i++)
     {
         int      playerid = Global.roleleads[i];
         PLPlayer RoleLead = PLServer.Instance.GetPlayerFromPlayerID(playerid);
         if (RoleLead != null && RoleLead.GetClassID() == i)
         {
             ___LocalCachedPlayerByClass[i] = RoleLead;
         }
     }
 }
示例#3
0
        public override void Execute(string arguments)
        {
            string   arg1    = arguments.Split(' ')[0].ToLower();
            string   message = arguments.Substring(arg1.Length);
            PLPlayer player  = null;

            switch (arg1)
            {
            case "c":
            case "captain":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(0);
                break;

            case "p":
            case "pilot":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(1);
                break;

            case "s":
            case "scientist":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(2);
                break;

            case "w":
            case "weapons":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(3);
                break;

            case "e":
            case "engineer":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(4);
                break;

            default:
                foreach (PLPlayer p in PLServer.Instance.AllPlayers)
                {
                    if (p != null && p.GetPlayerName().ToLower().StartsWith(arg1))
                    {
                        player = p;
                        break;
                    }
                }
                break;
            }

            if (player != null)
            {
                if (!player.IsBot)
                {
                    Messaging.Echo(PLNetworkManager.Instance.LocalPlayer.GetPhotonPlayer(), $"<color=#a0a0a0>You whisper to</color> [&%~[C{player.GetClassID()} {player.GetPlayerName()} ]&%~]<color=#a0a0a0>: {message}</color>");
                    PrivateMessage.SendMessage(player.GetPhotonPlayer(), message);
                }
                else
                {
                    Messaging.Notification("Can't send messages to bots");
                }
            }
            else
            {
                Messaging.Notification("Could not find the specified player");
            }
        }
示例#4
0
        private static bool Prefix(PLServer __instance, ref int playerID, ref int classID, PhotonMessageInfo pmi)
        {
            //runs vanilla if client isn't hosting
            if (!PhotonNetwork.isMasterClient)
            {
                return(true);
            }

            //fails if client not trying to be class -1 through 4
            if (classID < -1 || classID > 4)
            {
                return(false);
            }

            //Protect Players from bad actors changing other player's classes.
            PLPlayer playerForPhotonPlayer = PLServer.GetPlayerForPhotonPlayer(pmi.sender);

            if (playerForPhotonPlayer != null && playerForPhotonPlayer.GetPlayerID() != playerID)
            {
                return(false);
            }

            PLPlayer PlayerFromID = __instance.GetPlayerFromPlayerID(playerID);

            if (PlayerFromID != null)
            {
                //stop if player is already in the specified class
                if (PlayerFromID.GetClassID() == classID)
                {
                    return(false);
                }
                Global.Generateplayercount();
                if (CanJoinClass(classID))
                {
                    //sends the classchangemessage, sets the player to the class id
                    PlayerFromID.SetClassID(classID);
                    AccessTools.Method(__instance.GetType(), "ClassChangeMessage", null, null).Invoke(__instance, new object[] { PlayerFromID.GetPlayerName(false), classID });
                }
                else //Couldn't become role, send available options.
                {
                    string options = "";
                    for (int classid = 0; classid < 5; classid++)
                    {
                        if (CanJoinClass(classid))
                        {
                            options += $"{PLPlayer.GetClassNameFromID(classid)}\n";
                        }
                    }
                    if (string.IsNullOrEmpty(options))
                    {
                        Messaging.Centerprint("There are no slots available. Ask the host to change this or leave.", PlayerFromID, "ROL", PLPlayer.GetClassColorFromID(classID), EWarningType.E_NORMAL);
                        Messaging.Notification($"Player {PlayerFromID.GetPlayerName()} Is trying to join as {PLPlayer.GetClassNameFromID(classID)}. There are no Roles available.");
                    }
                    else
                    {
                        Messaging.Centerprint("That slot is full, choose another one. options on the left", PlayerFromID, "ROL", PLPlayer.GetClassColorFromID(classID), EWarningType.E_NORMAL);
                        Messaging.Notification(options, PlayerFromID, playerID, 10000 + PLServer.Instance.GetEstimatedServerMs());
                        Messaging.Notification($"Player {PlayerFromID.GetPlayerName()} Is trying to join as {PLPlayer.GetClassNameFromID(classID)}");
                    }
                }
            }
            return(false);
        }
        public override void HandleRPC(object[] arguments, PhotonMessageInfo sender)
        {
            PLPlayer player  = PLServer.GetPlayerForPhotonPlayer(sender.sender);
            string   name    = player.GetPlayerName();
            string   message = (string)arguments[0];

            Messaging.Echo(PLNetworkManager.Instance.LocalPlayer.GetPhotonPlayer(), $"[&%~[C{player.GetClassID()} {name} ]&%~] <color=#a0a0a0>whispers to you: {message}</color>");
        }