/// <summary>
 /// Restores all users to their original prefabs.
 /// </summary>
 public void RestoreCharacterPrefabsAndKill()
 {
     foreach (string name in originalBodyNames.Keys)
     {
         PlayerCharacterMasterController player = FrogtownShared.GetPlayerWithName(name);
         if (player != null)
         {
             if (originalBodyNames.TryGetValue(name, out string oldBodyName))
             {
                 var prefab = BodyCatalog.FindBodyPrefab(oldBodyName);
                 if (prefab != null)
                 {
                     FrogtownShared.ChangePrefab(name, prefab);
                     player.master.Invoke("TrueKill", 0.1f);
                 }
             }
         }
     }
 }
        private bool OnCharCommand(string userName, string[] pieces)
        {
            if (!modDetails.enabled)
            {
                return(false);
            }

            if (pieces.Length >= 2)
            {
                int prefabIndex = -1;
                if (!Int32.TryParse(pieces[1], out prefabIndex))
                {
                    prefabIndex = BodyCatalog.FindBodyIndexCaseInsensitive(pieces[1]);
                }
                if (prefabIndex != -1)
                {
                    GameObject prefab = BodyCatalog.GetBodyPrefab(prefabIndex);

                    if (prefab != null)
                    {
                        if (FrogtownShared.ChangePrefab(userName, prefab))
                        {
                            FrogtownShared.SendChat(userName + " morphed into " + prefab.name);
                        }
                        else
                        {
                            FrogtownShared.SendChat(userName + " couldn't morph into " + prefab.name);
                        }
                    }
                    else
                    {
                        FrogtownShared.SendChat("Prefab not found");
                    }
                }
            }

            return(true);
        }
        private void CharacterMasterOnBodyDeathPostfix(CharacterMaster instance)
        {
            if (gameover)
            {
                return;
            }
            PlayerCharacterMasterController player = instance.GetComponent <PlayerCharacterMasterController>();

            if (player != null)
            {
                if (!instance.preventGameOver)
                {
                    if (modDetails.enabled)
                    {
                        var name = player.networkUser.GetNetworkPlayerName().GetResolvedName();
                        originalBodyNames.Add(name, player.master.bodyPrefab.name);
                        var prefab = BodyCatalog.FindBodyPrefab("Drone2Body");
                        FrogtownShared.ChangePrefab(name, prefab);
                    }
                    //Still log they are a bot incase the mod was disabled in the middle of the round, so that the game can end properly.
                    botPlayers.Add(player.networkUser.GetNetworkPlayerName().GetResolvedName());
                }
            }
        }