public override bool FireEvent(Event E) { if (E.ID == "OwnerGetInventoryActions") { EventParameterGetInventoryActions eventParameterGetInventoryActions = E.GetParameter("Actions") as EventParameterGetInventoryActions; XRL.World.GameObject GO = E.GetGameObjectParameter("Object"); eventParameterGetInventoryActions.AddAction("Paint", 'P', true, "&WP&yaint " + GO.the + GO.DisplayNameOnly, "InvCommandPainting"); if (GO.GetPart <LiquidVolume>() != null) { eventParameterGetInventoryActions.AddAction("PaintSelf", 's', true, "Paint your&Ws&yelf", "InvCommandPaintingSelf"); } return(true); } if (E.ID == "InvCommandPainting") { XRL.World.GameObject Owner = E.GetGameObjectParameter("Owner"); XRL.World.GameObject Object = E.GetGameObjectParameter("Object"); if (Object.pBrain != null && Object.pBrain.GetFeeling(Owner) < 50) { Object.pBrain.AdjustFeeling(Owner, -10); if (Owner.IsPlayer()) { Popup.Show(Object.The + Object.DisplayNameOnly + " doesn't want to be painted!"); } if (Object.MakeSave("Agility", 20, Owner, null, "Painting")) { return(false); } } Paint(Object, Owner); } if (E.ID == "InvCommandPaintingSelf") { XRL.World.GameObject Owner = E.GetGameObjectParameter("Owner"); Paint(Owner, Owner); } // if (E.ID == "AIGetOffensiveMutationList") // { // List<AICommandList> list = (List<AICommandList>)E.GetParameter("List"); // ActivatedAbilities activatedAbilities = ParentObject.GetPart("ActivatedAbilities") as ActivatedAbilities; // ActivatedAbilityEntry activatedAbilityEntry = activatedAbilities.AbilityByGuid[ActivatedAbilityID]; // list.Add(new AICommandList("CommandPaint", 1)); // } return(base.FireEvent(E)); }
public static Dictionary <Guid, string> LoadAbilityData() { Dictionary <Guid, string> originalAbilityDescriptions = null; GameObject playerBody = XRLCore.Core?.Game?.Player?.Body; if (playerBody != null) { if (!playerBody.HasPart("Egcb_PlayerUIHelper")) { Debug.Log("QudUX Mod: Unexpectedly failed to load ability data from the player body. QudUX might be unable to show improved descriptions on the activated ability screen."); } else { originalAbilityDescriptions = playerBody.GetPart <Egcb_PlayerUIHelper>().DefaultAbilityDescriptions; } } return((originalAbilityDescriptions == null) ? new Dictionary <Guid, string>() : originalAbilityDescriptions); }
public void LoadInventoryData() { //This assumes items can't be added to the inventory while the inventory is open. It's probably possible that a mod could add items while //the inventory is open. If it turns out to be an issue, this code can be updated to retrieve the entire list every frame, but that seems //overkill for now - this should probably work for most realistic cases. if (this.InventoryList.Count <= 0) { GameObject playerCurrentBody = XRLCore.Core?.Game?.Player?.Body; Inventory inventory = playerCurrentBody?.GetPart("Inventory") as Inventory; if (inventory == null) { return; } List <GameObject> objects = inventory.GetObjectsDirect(); for (int i = 0; i < objects.Count; i++) { GameObject item = objects[i]; if (!item.HasTag("HiddenInInventory")) { //removed filter string handling, because if the player removes the filter after we do this, we won't have all the items saved in our List<GameObject> //if (InventoryScreen.filterString == string.Empty || ConsoleLib.Console.ColorUtility.StripFormatting(item.DisplayName).ToLower().Contains(InventoryScreen.filterString.ToLower())) //{ this.InventoryList.Add(item); //} } } this.InventoryList.Sort(InventoryScreen.displayNameSorter); foreach (GameObject item in this.InventoryList) { string strippedConstrainedName = item.GetCachedDisplayNameStripped().Substring(0, Math.Min(item.GetCachedDisplayNameStripped().Length, 60)).PadRight(60); if (!this.CachedValuePerLbStrings.ContainsKey(strippedConstrainedName)) { this.CachedValuePerLbStrings.Add(strippedConstrainedName, this.GetItemValueString(item)); } } } }
public static void AddAbility(XRL.World.GameObject player) { // abort if ActivatedAbilities part is not found if (!(player.GetPart("ActivatedAbilities") is XRL.World.Parts.ActivatedAbilities aaPart)) { return; } // abort if custom ability already exists XRL.World.Parts.ActivatedAbilityEntry ability = aaPart.GetAbilityByCommand(EVENT_NAME); if (ability != null) { return; } // add custom ability /* System.Guid abilityId = */ _ = aaPart.AddAbility( Name: "Toggle Map Pins", Command: EVENT_NAME, Class: "Location Management", Description: "Open menu of map pin bulk toggle functions", Silent: true ); }
public void Paint(XRL.World.GameObject Canvas, XRL.World.GameObject Artist) { //choose colour if (Artist.IsPlayer()) { // CHOOSE DESIGN List <string> ChoiceList = new List <string>(); List <char> HotkeyList = new List <char>(); char ch = 'a'; ChoiceList.Add("Custom design."); HotkeyList.Add(ch); ch = (char)(ch + 1); List <acegiak_PaintingRecipe> recipes = new List <acegiak_PaintingRecipe>(); foreach (acegiak_PaintingRecipe observation in Recipes) { if (observation is acegiak_PaintingRecipe) { acegiak_PaintingRecipe recipe = observation as acegiak_PaintingRecipe; if (recipe.revealed) { recipes.Add(recipe); ChoiceList.Add(recipe.FormName + ": \n" + recipe.FormDescription + "\n"); HotkeyList.Add(ch); ch = (char)(ch + 1); } } } string BaseColour = ""; string DetailColour = ""; List <string> chosenStuffs = new List <string>(); int designNumber = Popup.ShowOptionList(string.Empty, ChoiceList.ToArray(), HotkeyList.ToArray(), 0, "Choose a design.", 60, false, true); if (designNumber < 0) { return; } // CHOOSE BODY PART ChoiceList = new List <string>(); HotkeyList = new List <char>(); ch = 'a'; BodyPart paintingpart = null; if (Canvas.GetPart <Body>() != null) { List <BodyPart> parts = new List <BodyPart>(); ch = 'a'; foreach (BodyPart part in Canvas.GetPart <Body>()._Body.GetParts()) { if (!part.Abstract && !part.Extrinsic) { if (designNumber <= 0 || recipes[designNumber - 1].PartType == null || part.Type == recipes[designNumber - 1].PartType) { parts.Add(part); HotkeyList.Add(ch); ChoiceList.Add(part.Name); ch = (char)(ch + 1); } } } if (parts.Count == 0) { Popup.Show("They don't have the body part required for this pattern."); return; } int partChoice = Popup.ShowOptionList(string.Empty, ChoiceList.ToArray(), HotkeyList.ToArray(), 0, "Which part of " + Canvas.the + Canvas.DisplayNameOnly + " will you paint?", 60, false, true); if (partChoice >= 0) { paintingpart = parts[partChoice]; } } // CHOOSE BASE COLOR Inventory part2 = Artist.GetPart <Inventory>(); List <XRL.World.GameObject> ObjectChoices = new List <XRL.World.GameObject>(); ChoiceList = new List <string>(); HotkeyList = new List <char>(); ch = 'a'; part2.ForeachObject(delegate(XRL.World.GameObject GO) { if (GO != null && GO.GetPart <LiquidVolume>() != null && GO.GetPart <LiquidVolume>().GetPrimaryLiquid() != null && GO.GetPart <LiquidVolume>().GetPrimaryLiquid().Name != "water") { if (designNumber <= 0 || recipes[designNumber - 1].BaseColor == null || (recipes[designNumber - 1].BaseColor.Length == 1 && GO.GetPart <LiquidVolume>().GetPrimaryLiquidColor() == recipes[designNumber - 1].BaseColor) || (recipes[designNumber - 1].BaseColor.Length > 1 && GO.GetPart <LiquidVolume>().GetPrimaryLiquid().Name == recipes[designNumber - 1].BaseColor)) { ObjectChoices.Add(GO); HotkeyList.Add(ch); ChoiceList.Add(GO.DisplayName); ch = (char)(ch + 1); } } }); if (ObjectChoices.Count == 0) { if (designNumber > 0) { Popup.Show("You have no " + acegiak_LiquidDye.ColorNames[recipes[designNumber - 1].BaseColor] + " pigments."); } else { Popup.Show("You have nothing to paint with."); } return; } int baseColor = Popup.ShowOptionList(string.Empty, ChoiceList.ToArray(), HotkeyList.ToArray(), 0, "Choose your base colour.", 60, false, true); if (baseColor >= 0) { BaseColour = ObjectChoices[baseColor].GetPart <LiquidVolume>().GetPrimaryLiquidColor(); if (ObjectChoices[baseColor].GetPart <LiquidVolume>().GetPrimaryLiquid() is acegiak_LiquidDye) { //that's fine } else { StringBuilder b = new StringBuilder(); ObjectChoices[baseColor].GetPart <LiquidVolume>().AppendLiquidName(b); chosenStuffs.Add(b.ToString()); } } if (BaseColour == "") { BaseColour = Canvas.pRender.TileColor == String.Empty?Canvas.pRender.GetForegroundColor().Replace("&", ""):Canvas.pRender.TileColor.Replace("&", ""); } //CHOOSE DETAIL COLOR List <XRL.World.GameObject> ObjectChoices2 = new List <XRL.World.GameObject>(); ChoiceList = new List <string>(); HotkeyList = new List <char>(); ch = 'a'; part2.ForeachObject(delegate(XRL.World.GameObject GO) { if (GO != null && GO.GetPart <LiquidVolume>() != null && GO.GetPart <LiquidVolume>().GetPrimaryLiquid() != null && GO.GetPart <LiquidVolume>().GetPrimaryLiquid().Name != "water") { if (designNumber <= 0 || recipes[designNumber - 1].DetailColor == null || (recipes[designNumber - 1].DetailColor.Length == 1 && GO.GetPart <LiquidVolume>().GetPrimaryLiquidColor() == recipes[designNumber - 1].DetailColor) || (recipes[designNumber - 1].DetailColor.Length > 1 && GO.GetPart <LiquidVolume>().GetPrimaryLiquid().Name == recipes[designNumber - 1].DetailColor)) { ObjectChoices2.Add(GO); HotkeyList.Add(ch); ChoiceList.Add(GO.DisplayName); ch = (char)(ch + 1); } } }); if (ObjectChoices2.Count == 0) { if (designNumber > 0) { Popup.Show("You have no " + acegiak_LiquidDye.ColorNames[recipes[designNumber - 1].DetailColor] + " pigments."); } else { Popup.Show("You have nothing to paint with."); } return; } int detailColor = Popup.ShowOptionList(string.Empty, ChoiceList.ToArray(), HotkeyList.ToArray(), 0, "Choose your detail colour.", 60, false, true); if (detailColor >= 0) { DetailColour = ObjectChoices[detailColor].GetPart <LiquidVolume>().GetPrimaryLiquidColor(); if (ObjectChoices[detailColor].GetPart <LiquidVolume>().GetPrimaryLiquid() is acegiak_LiquidDye) { //that's fine } else { StringBuilder c = new StringBuilder(); ObjectChoices[detailColor].GetPart <LiquidVolume>().AppendLiquidName(c); chosenStuffs.Add(c.ToString()); } } if (DetailColour == "") { DetailColour = Canvas.pRender.DetailColor; } if (detailColor < 0 && baseColor < 0) { return; } // DO THE PAINTING if (paintingpart != null) { List <Effect> list = new List <Effect>(); foreach (Effect effect in Canvas.Effects) { list.Add(effect); } foreach (Effect e in list) { if (e is acegiak_ModHandPainted) { int?bpid = ((acegiak_ModHandPainted)e).BodyPartId; if (bpid != null && Canvas.GetPart <Body>() != null) { if ( Canvas.GetPart <Body>()._Body.GetPartByID(bpid.Value) == paintingpart) { Canvas.RemoveEffect(e); } } } } } acegiak_ModHandPainted painting = new acegiak_ModHandPainted(); if (designNumber > 0 && recipes[designNumber - 1].className != null) { Type t = typeof(acegiak_ModHandPainted); painting = Activator.CreateInstance(Type.GetType(recipes[designNumber - 1].className)) as acegiak_ModHandPainted; // painting = (acegiak_ModHandPainted)Activator.CreateInstance(null, recipes[designNumber-1].className ).Unwrap(); } painting.Engraving = "mysterious shapes"; if (designNumber == 0) { painting.Engraving = Popup.AskString("What do you depict?", string.Empty, 999); } if (designNumber > 0) { painting.Engraving = recipes[designNumber - 1].FormDescription; painting.Faction = recipes[designNumber - 1].FormFaction; painting.DisplayName = recipes[designNumber - 1].FormName; } painting.BaseColour = BaseColour; painting.DetailColour = DetailColour; if (paintingpart != null) { painting.BodyPartId = paintingpart.ID; } if (chosenStuffs.Count > 0) { painting.With = String.Join(" and ", chosenStuffs.ToArray()); } if (baseColor >= 0) { ObjectChoices[baseColor].GetPart <LiquidVolume>().GetPrimaryLiquid().PouredOn(new LiquidVolume(ObjectChoices[baseColor].GetPart <LiquidVolume>().GetPrimaryLiquid().ID, 1), Canvas); ObjectChoices[baseColor].GetPart <LiquidVolume>().UseDrams(1); } if (detailColor >= 0) { ObjectChoices2[detailColor].GetPart <LiquidVolume>().GetPrimaryLiquid().PouredOn(new LiquidVolume(ObjectChoices2[detailColor].GetPart <LiquidVolume>().GetPrimaryLiquid().ID, 1), Canvas); ObjectChoices2[detailColor].GetPart <LiquidVolume>().UseDrams(1); } Canvas.ApplyEffect(painting); } }
public static bool Prefix(ref string __result, XRL.World.GameObject O) { XRL.World.Parts.Description part = O.GetPart <XRL.World.Parts.Description>(); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); // name line // name _ = stringBuilder.Append(O.DisplayName); // id (optional) if (XRL.UI.Options.GetOption("HZShowOwnerOptionId").EqualsNoCase("Yes")) { _ = stringBuilder.Append(" {").Append(O.Blueprint).Append("#").Append(O.id).Append("}"); } // owner (optional) string owner = O.Owner; if (!string.IsNullOrEmpty(owner)) { _ = stringBuilder.Append(" (").Append(owner).Append(")"); } _ = stringBuilder.AppendLine(); // reaction and/or faction line (optional) string feelingDescription = part.GetFeelingDescription(); string primaryFaction = O.GetPrimaryFaction(); string faction = ( string.IsNullOrEmpty(primaryFaction) ? null : XRL.World.Factions.get(primaryFaction).DisplayName ); if (!string.IsNullOrEmpty(feelingDescription) || !string.IsNullOrEmpty(faction)) { // reaction (optional) if (!string.IsNullOrEmpty(feelingDescription)) { _ = stringBuilder.Append(feelingDescription); // add a space separator before faction if both are present if (!string.IsNullOrEmpty(faction)) { _ = stringBuilder.Append(" "); } } // faction (optional) if (!string.IsNullOrEmpty(faction)) { int factionValue = XRL.Core.XRLCore.Core.Game.PlayerReputation.get(primaryFaction); string factionValueString = "{{" + XRL.World.Reputation.getColor(factionValue) + "|" + factionValue.ToString() + "}}"; _ = stringBuilder.Append("(").Append(factionValueString).Append(" ").Append(faction).Append(")"); } _ = stringBuilder.AppendLine(); } // assessment line // health _ = stringBuilder.Append(XRL.Rules.Strings.WoundLevel(O)); // difficulty (optional) string difficultyDescription = part.GetDifficultyDescription(); if (!string.IsNullOrEmpty(difficultyDescription)) { _ = stringBuilder.Append(", ").Append(difficultyDescription); } _ = stringBuilder.AppendLine(); // long description line(s) _ = stringBuilder.AppendLine(); part.GetLongDescription(stringBuilder); // stringBuilder.AppendLine(); __result = ConsoleLib.Console.Markup.Transform(stringBuilder.ToString()); return(false); }
public override bool FireEvent(Event E) { //Debug.Log("Event: "+E.ID+"."); if (E.ID == "StartFishing") { //Debug.Log("startfishevent."); //Popup.Show("You cast a line."); fishinHole = E.GetGameObjectParameter("Pool"); } if (E.ID == "StopFishing") { //Debug.Log("stopfishevent."); if (fishinHole != null) { IPart.AddPlayerMessage("You stop fishing."); } fishinHole = null; } if (E.ID == "UseEnergy") { //Debug.Log("use energy."); //Debug.Log(E.GetStringParameter("Type", string.Empty)); if (E.GetStringParameter("Type", string.Empty) == "Pass" || E.GetStringParameter("Type", string.Empty) == string.Empty || E.GetStringParameter("Type", string.Empty) == "Fishing" || E.GetStringParameter("Type", string.Empty) == "None") { //Debug.Log("passturn."); if (fishinHole != null) { if (fishinHole.GetPart <acegiak_Fishable>().Epic != null) { IPart.AddPlayerMessage("The line goes slack."); } fishinHole.GetPart <acegiak_Fishable>().fromCell = null; fishinHole.GetPart <acegiak_Fishable>().Epic = null; fishinHole.FireEvent(Event.New("InvCommandContinueFish", "Owner", ParentObject, "Count", ++turnCount)); } } else { //Debug.Log("notfish."); if (fishinHole != null) { //Debug.Log("stopfish."); if (fishinHole.GetPart <acegiak_Fishable>() == null || fishinHole.GetPart <acegiak_Fishable>().Epic == null) { IPart.AddPlayerMessage("You stop fishing."); fishinHole = null; } else { if (fishinHole.GetPart <acegiak_Fishable>().Epic.HasStat("Strength") && fishinHole.GetPart <acegiak_Fishable>().Epic.MakeSave("Strength", 1, ParentObject, "Strength")) { if (ParentObject.CurrentCell != fishinHole.GetPart <acegiak_Fishable>().fromCell) { fishinHole.GetPart <acegiak_Fishable>().fromCell.AddObject(ParentObject); //ParentObject.CurrentCell = fishinHole.GetPart<acegiak_Fishable>().fromCell; IPart.AddPlayerMessage("You strain at the line!"); } } else { Popup.Show("You reel in " + fishinHole.GetPart <acegiak_Fishable>().Epic.the + fishinHole.GetPart <acegiak_Fishable>().Epic.DisplayNameOnly + "."); fishinHole.GetPart <acegiak_Fishable>().Epic.AwardXPTo(ParentObject, "Catch"); fishinHole.GetPart <acegiak_Fishable>().fromCell.AddObject(fishinHole.GetPart <acegiak_Fishable>().Epic); fishinHole.GetPart <acegiak_Fishable>().fromCell = null; fishinHole.GetPart <acegiak_Fishable>().Epic = null; fishinHole = null; } } } } } //Debug.Log("End event: "+E.ID+"."); return(base.FireEvent(E)); }