public bool Gift(GameObject who, bool FromDialog) { havePreference(); Inventory part2 = XRLCore.Core.Game.Player.Body.GetPart <Inventory>(); List <XRL.World.GameObject> ObjectChoices = new List <XRL.World.GameObject>(); List <string> ChoiceList = new List <string>(); List <char> HotkeyList = new List <char>(); char ch = 'a'; part2.ForeachObject(delegate(XRL.World.GameObject GO) { ObjectChoices.Add(GO); HotkeyList.Add(ch); ChoiceList.Add(GO.DisplayName); ch = (char)(ch + 1); }); if (ObjectChoices.Count == 0) { Popup.Show("You have no gifts to give."); return(false); } int num12 = Popup.ShowOptionList(string.Empty, ChoiceList.ToArray(), HotkeyList.ToArray(), 0, "Select a gift to give.", 60, bRespectOptionNewlines: false, bAllowEscape: true); if (num12 < 0) { return(false); } int result = (int)((assessGift(ObjectChoices[num12], who).amount + (Stat.Rnd2.Next(1, 4) - 1.5f)) * 10); XRL.World.Event event2 = XRL.World.Event.New("SplitStack", "Number", 1); event2.AddParameter("OwningObject", XRLCore.Core.Game.Player.Body); ObjectChoices[num12].FireEvent(event2); if (!part2.FireEvent(XRL.World.Event.New("CommandRemoveObject", "Object", ObjectChoices[num12]))) { Popup.Show("You can't give that object."); return(false); } ObjectChoices[num12].SetStringProperty("GiftedTo", ParentObject.id); ParentObject.GetPart <Inventory>().AddObject(ObjectChoices[num12]); ParentObject.pBrain.AdjustFeeling(who, result); if (who.IsPlayer()) { Popup.Show(ParentObject.The + ParentObject.DisplayNameOnlyDirect + (result > 0?"&Y likes the " + ObjectChoices[num12].pRender.DisplayName + ".":"&r is unimpressed by the " + ObjectChoices[num12].pRender.DisplayName + ".")); } return(true); }
public override bool FireEvent(XRL.World.Event E) { // bail out if not the event we want if (E.ID != EVENT_NAME) { return(base.FireEvent(E)); } // get list of known location categories System.Collections.Generic.List <string> categories = Qud.API.JournalAPI.GetMapNoteCategories(); // if no locations known, pop up an informational message and abort if (categories.Count <= 0) { XRL.UI.Popup.ShowSpace("No location categories known yet. Go forth and explore!"); return(base.FireEvent(E)); } // build list of category choices string[] catArray = new string[categories.Count + 1]; catArray[0] = "All Known Categories"; categories.CopyTo(catArray, 1); // query the user for category choice int catChoice = XRL.UI.Popup.ShowOptionList( Title: "Map Pin Toggle - Location", Options: catArray, Intro: "Which location category's map pins would you like to toggle?\n", AllowEscape: true ); // abort if player escaped out if (catChoice < 0) { return(base.FireEvent(E)); } // query the user for toggle action choice int actChoice = XRL.UI.Popup.ShowOptionList( Title: "Map Pin Toggle - Action", Options: TOGGLE_ACTIONS, Intro: "What action would you like to perform for " + (catChoice == 0 ? " all known categories" : catArray[catChoice]) + "?\n", AllowEscape: true ); // abort if player escaped out if (actChoice < 0) { return(base.FireEvent(E)); } // player has committed to a change // derive action flags from player choice // -1 => disable // 0 => no change // 1 => enable ActE actUnv = ActE.NA; ActE actVis = ActE.NA; switch (actChoice) { case 0: { actUnv = ActE.OF; actVis = ActE.OF; } break; case 1: { actUnv = ActE.OF; actVis = ActE.NA; } break; case 2: { actUnv = ActE.OF; actVis = ActE.ON; } break; case 3: { actUnv = ActE.NA; actVis = ActE.OF; } break; case 4: { actUnv = ActE.NA; actVis = ActE.ON; } break; case 5: { actUnv = ActE.ON; actVis = ActE.OF; } break; case 6: { actUnv = ActE.ON; actVis = ActE.NA; } break; case 7: { actUnv = ActE.ON; actVis = ActE.ON; } break; } // iterate over all revealed map notes foreach (Qud.API.JournalMapNote mapNote in Qud.API.JournalAPI.GetMapNotes( (Qud.API.JournalMapNote item) => item.revealed && (catChoice == 0 || item.category == catArray[catChoice]) ) ) { // apply chosen action(s) switch (VisitedNote(mapNote) ? actVis : actUnv) { case ActE.OF: mapNote.tracked = false; break; case ActE.NA: /* do nothing */ break; case ActE.ON: mapNote.tracked = true; break; } } XRL.World.Zone z = XRL.Core.XRLCore.Core?.Game?.Player?.Body?.CurrentCell?.ParentZone; if (z != null && z.IsWorldMap()) { z.Activated(); } // toggle categories per configured behavior switch (GetCategoryBehavior()) { case CatE.ALL: { // enable all categories since we're managing individual entries // otherwise disabled categories may override visibility foreach (string catString in categories) { Qud.API.JournalAPI.SetCategoryMapNoteToggle(catString, true); } } break; case CatE.NONE: { // do nothing } break; case CatE.SYNC: { // add categories with tracked notes to hash set System.Collections.Generic.HashSet <string> catSet = new System.Collections.Generic.HashSet <string>(); foreach (Qud.API.JournalMapNote mapNote in Qud.API.JournalAPI.GetMapNotes( (Qud.API.JournalMapNote item) => item.revealed && item.tracked)) { catSet.Add(mapNote.category); } // now iterate over all categories and toggle based on set presence foreach (string catString in categories) { Qud.API.JournalAPI.SetCategoryMapNoteToggle(catString, catSet.Contains(catString)); } } break; } return(base.FireEvent(E)); }
public override bool FireEvent(XRL.World.Event E) { // bail out if not the event we want if (E.ID != EVENT_NAME) { return(base.FireEvent(E)); } // get list of known location categories System.Collections.Generic.List <string> categories = Qud.API.JournalAPI.GetMapNoteCategories(); // if no locations known, pop up an informational message and abort if (categories.Count <= 0) { XRL.UI.Popup.ShowSpace("No location categories known yet. Go forth and explore!"); return(base.FireEvent(E)); } // build list of category choices string[] catArray = new string[categories.Count + 1]; catArray[0] = "All Known Categories"; categories.CopyTo(catArray, 1); // query the user for category choice int catChoice = XRL.UI.Popup.ShowOptionList( Title: "Map Pin Toggle - Location", Options: catArray, Intro: "Which location category's map pins would you like to toggle?\n", AllowEscape: true ); // abort if player escaped out if (catChoice < 0) { return(base.FireEvent(E)); } // query the user for toggle action choice int actChoice = XRL.UI.Popup.ShowOptionList( Title: "Map Pin Toggle - Action", Options: TOGGLE_ACTIONS, Intro: "What action would you like to perform for " + (catChoice == 0 ? " all known categories" : categories[catChoice - 1]) + "?\n", AllowEscape: true ); // abort if player escaped out if (actChoice < 0) { return(base.FireEvent(E)); } // derive action flags from player choice // -1 => disable // 0 => no change // 1 => enable ActE actUnv = ActE.NA; ActE actVis = ActE.NA; switch (actChoice) { case 0: { actUnv = ActE.OF; actVis = ActE.OF; } break; case 1: { actUnv = ActE.OF; actVis = ActE.NA; } break; case 2: { actUnv = ActE.OF; actVis = ActE.ON; } break; case 3: { actUnv = ActE.NA; actVis = ActE.OF; } break; case 4: { actUnv = ActE.NA; actVis = ActE.ON; } break; case 5: { actUnv = ActE.ON; actVis = ActE.OF; } break; case 6: { actUnv = ActE.ON; actVis = ActE.NA; } break; case 7: { actUnv = ActE.ON; actVis = ActE.ON; } break; } // iterate over all revealed map notes foreach (Qud.API.JournalMapNote mapNote in Qud.API.JournalAPI.GetMapNotes( (Qud.API.JournalMapNote item) => item.revealed && (catChoice == 0 || item.category == categories[catChoice - 1]) ) ) { // apply chosen action(s) switch (VisitedNote(mapNote) ? actVis : actUnv) { case ActE.OF: mapNote.tracked = false; break; case ActE.NA: /* do nothing */ break; case ActE.ON: mapNote.tracked = true; break; } } XRL.World.Zone z = XRL.Core.XRLCore.Core?.Game?.Player?.Body?.CurrentCell?.ParentZone; if (z != null && z.IsWorldMap()) { z.Activated(); } return(base.FireEvent(E)); }