static void Prefix(AdventureManager __instance)
 {
     //Event was finished, checks if the temporary event was created and removes it to avoid it from being used by the game
     if (AdventureManager.eventOwners.ContainsKey(__instance))
     {
         AdvModule  advModule    = Array.Find <AdvModule>(AdventureLibrary.modules, (AdvModule o) => o.name == "Slavyan");
         AdvEvent[] advEventList = Array.FindAll <AdvEvent>(advModule.events, (AdvEvent o) => o.name == "Generic Remove Character");
         AdvEvent   advEvent     = null;
         if (advEventList.Length > 0)
         {
             advEvent = advEventList[0];
             List <AdvEvent> list = new List <AdvEvent>(advModule.events);
             if (advModule.events.Contains(advEvent))
             {
                 list.Remove(advEvent);
                 advModule.events = list.ToArray();
             }
         }
     }
 }
        static bool Prefix(Equip __instance)
        {
            if (__instance.name == "Remove Character")
            {
                Dictionary <UIManager.Screen, List <ScreenBase> > openScreensByEnum = Traverse.Create(UIManager.Get()).Field("openScreensByEnum").GetValue <Dictionary <UIManager.Screen, List <ScreenBase> > >();

                //Closes Equip and Navbar to return to HUD
                if (UIManager.Get() != null && openScreensByEnum != null)
                {
                    foreach (KeyValuePair <UIManager.Screen, List <ScreenBase> > keyValuePair in openScreensByEnum)
                    {
                        if (keyValuePair.Value != null && keyValuePair.Value.Count >= 1)
                        {
                            List <ScreenBase> list = new List <ScreenBase>(keyValuePair.Value);
                            foreach (ScreenBase screenBase in list)
                            {
                                if (!(screenBase is TopLayer) && screenBase.name != "HUD(Clone)")
                                {
                                    UIManager.Close(screenBase);
                                }
                            }
                        }
                    }
                }

                //Clones "Giving up people" to simplify it and allow character to be removed without gaining items/rep with the slavyans
                AdvModule  advModule    = Array.Find <AdvModule>(AdventureLibrary.modules, (AdvModule o) => o.name == "Slavyan");
                AdvEvent[] advEventList = Array.FindAll <AdvEvent>(advModule.events, (AdvEvent o) => o.name == "Generic Remove Character");
                AdvEvent   advEvent;
                if (advEventList.GetLength(0) == 0)
                {
                    advEvent        = Array.FindAll <AdvEvent>(advModule.events, (AdvEvent o) => o.name == "Giving up people")[0].Clone();
                    advEvent.module = advModule;
                    advEvent.name   = "Generic Remove Character";
                    Array.Resize <AdvEvent>(ref advModule.events, advModule.events.Length + 1);
                    advModule.events[advModule.events.Length - 1] = advEvent;
                    //advEvent.uniqueID = advModule.GetNextEventIndex(); //Might not be necessary to add ID since it will be removed later
                    UnityEngine.Debug.Log("Equip_ButtonClick_Patch --------------------- making new event " + advEvent.name);
                }
                else
                {
                    //In case the temporary event already exists, but I'm removing them after the event ends
                    advEvent = advEventList[0];
                }

                //Modifies the event to make it more generic and simple
                AdvNode[] nodes = advEvent.nodes;
                foreach (AdvNode node in nodes)
                {
                    if (node is NodeAdventure)
                    {
                        (node as NodeAdventure).story = "You approach your group to decide if anyone should leave.";
                    }
                    List <AdvOutput> outputs = node.outputs;
                    if (outputs != null)
                    {
                        foreach (AdvOutput output in outputs)
                        {
                            if (output.name == "Wish them well and leave.")
                            {
                                output.name = "Send someone away.";
                            }
                            if (output.name == "Actually, ask them to stay with you!")
                            {
                                output.name = "Nevermind.";
                            }
                            if (output.name == "Confirm")
                            {
                                output.targetID = 5;
                            }
                            if (output.name == "Cancel")
                            {
                                output.targetID = 5;
                            }
                        }
                    }
                }

                //Run the new temporary event
                ClientGroupData    selectedGroup = GroupSelectionManager.Get().GetSelectedGroup();
                Thea2.Server.Group group         = null;
                if (selectedGroup != null)
                {
                    group = EntityManager.Get <Thea2.Server.Group>(selectedGroup.GetID(), true);
                }
                AdventureManager adventureManager = AdventureManager.TriggerEvent(group.ownerID, advEvent, group, null, -1, true);

                return(false);
            }

            return(true);
        }