コード例 #1
0
            public string GetAdjustedBaseCooldown(AbilityXmlInfo abilityDataEntry)
            {
                if (string.IsNullOrEmpty(abilityDataEntry.BaseCooldown))
                {
                    return(string.Empty);
                }
                if (string.IsNullOrEmpty(abilityDataEntry.CooldownChangeSkills))
                {
                    return(abilityDataEntry.BaseCooldown);
                }
                GameObject player = XRLCore.Core?.Game?.Player?.Body;

                if (player == null)
                {
                    return(abilityDataEntry.BaseCooldown);
                }
                int baseCooldown = int.Parse(abilityDataEntry.BaseCooldown);

                foreach (string entry in abilityDataEntry.CooldownChangeSkills.Split(','))
                {
                    string skill        = entry.Split(':')[0];
                    int    adjustAmount = int.Parse(entry.Split(':')[1]);
                    if (player.HasSkill(skill))
                    {
                        baseCooldown += adjustAmount;
                    }
                }
                return(baseCooldown.ToString());
            }
コード例 #2
0
        public float CopyOfInternalMethod_TradeUI_GetMultiplier()
        {
            GameObject body = XRLCore.Core.Game.Player.Body;

            if (!body.Statistics.ContainsKey("Ego"))
            {
                return(0.25f);
            }
            float num = (float)body.Statistics["Ego"].Modifier;

            if (body.HasPart("Persuasion_SnakeOiler"))
            {
                num += 2f;
            }
            if (body.HasEffect("Glotrot"))
            {
                num = -3f;
            }
            float num2 = 0.35f + 0.07f * num;

            if (body.HasPart("SociallyRepugnant"))
            {
                num2 /= 5f;
            }
            if (num2 > 0.95f)
            {
                num2 = 0.95f;
            }
            else if (num2 < 0.05f)
            {
                num2 = 0.05f;
            }
            return(num2);
        }
 static void Postfix(XRL.World.GameObject __instance, ref bool __result)
 {
     if (__result == true && Options.UI.EnableAutogetExclusions)
     {
         __result = !XRL.World.Parts.QudUX_AutogetHelper.IsAutogetDisabledByQudUX(__instance);
     }
 }
コード例 #4
0
ファイル: HZMapPinToggle.cs プロジェクト: HunterZ/qudmods
 // called whenever starting a new game
 public void mutate(XRL.World.GameObject player)
 {
     // add part unconditionally
     player.AddPart <HZMapPinTogglePart>();
     // also set up ability
     HZMapPinTogglePart.AddAbility(player);
 }
コード例 #5
0
        public static void FlipGameObjectTexture(XRL.World.GameObject obj, bool unflipIfAlreadyFlipped = true)
        {
            if (obj.pRender?.Tile == null)
            {
                return;
            }
            if (obj.pRender.Tile.EndsWith(Constants.FlippedTileSuffix))
            {
                if (unflipIfAlreadyFlipped)
                {
                    UnflipGameObjectTexture(obj);
                }
                return;
            }
            string sourcePath  = obj.pRender.Tile;
            string flippedPath = $"{System.IO.Path.ChangeExtension(sourcePath, null)}{Constants.FlippedTileSuffix}";

            GameManager.Instance.uiQueue.queueSingletonTask("QudUX Texture Flip", delegate
            {
                if (MakeFlippedTexture(flippedPath, out _))
                {
                    obj.pRender.Tile = flippedPath;
                }
            });
        }
コード例 #6
0
ファイル: skillPainting.cs プロジェクト: acegiak/qudpigments
 public override void Register(XRL.World.GameObject Object)
 {
     Object.RegisterPartEvent(this, "OwnerGetInventoryActions");
     Object.RegisterPartEvent(this, "InvCommandPainting");
     Object.RegisterPartEvent(this, "InvCommandPaintingSelf");
     base.Register(Object);
 }
コード例 #7
0
 public override void Register(XRL.World.GameObject Object)
 {
     Object.RegisterPartEvent(this, "StartFishing");
     Object.RegisterPartEvent(this, "StopFishing");
     Object.RegisterPartEvent(this, "AddedToInventory");
     Object.RegisterPartEvent(this, "UseEnergy");
     base.Register(Object);
 }
コード例 #8
0
 static bool Prefix(XRL.World.GameObject GO, ref XRL.UI.ScreenReturn __result)
 {
     if (QudUXOptions.UI.UseQudUXInventory && !GameOptions.OverlayPrereleaseInventory)
     {
         __result = (new XRL.UI.QudUX_InventoryScreen()).Show(GO);
         return(false);
     }
     return(true);
 }
コード例 #9
0
 private static void Postfix_GetMaxTargets(GameObject Beguiler, ref int __result)
 {
     if (!Beguiler.IsPlayer())
     {
         return;
     }
     Log($"Beguiling.GetMaxTargets. Original result: {__result}");
     __result *= 2;
 }
コード例 #10
0
 static void Prefix()
 {
     XRL.World.GameObject player = XRLCore.Core?.Game?.Player?.Body;
     if (player != null)
     {
         player.RequirePart <XRL.World.Parts.QudUX_ConversationHelper>();
     }
     ConsoleUtilities.SuppressScreenBufferImposters(true);
 }
コード例 #11
0
 private static void Postfix(GameObject Proselytizer, ref int __result)
 {
     if (!Proselytizer.IsPlayer())
     {
         return;
     }
     Log($"Persuasion_Proselytize.GetMaxTargets. Original result: {__result}");
     __result *= 2;
 }
コード例 #12
0
 public Egcb_LookTiler(GameObject target)
 {
     this.LookTarget       = target;
     this.LookTargetName   = ConsoleLib.Console.ColorUtility.StripFormatting(target.DisplayName);
     this.LookTargetInfo   = new TileMaker(target);
     this.bLookTargetValid = this.LookTarget != null &&
                             this.LookTarget.IsValid() &&
                             this.LookTargetInfo.IsValid() &&
                             !string.IsNullOrEmpty(this.LookTargetName);
     this.LastTileCoordsList = new List <Coords>();
 }
コード例 #13
0
 public Egcb_ConversationTiler(GameObject target)
 {
     this.ConversationTarget       = target;
     this.ConversationTargetName   = ConsoleLib.Console.ColorUtility.StripFormatting(target.DisplayName);
     this.ConversationTargetInfo   = new TileMaker(target);
     this.bConversationTargetValid = this.ConversationTarget != null &&
                                     this.ConversationTarget.IsValid() &&
                                     this.ConversationTargetInfo.IsValid() &&
                                     !string.IsNullOrEmpty(this.ConversationTargetName) &&
                                     this.ConversationTargetName.Length <= 74; //no room to render tile if name is greater than 74 characters (it'll overflow off the side of the screen)
 }
コード例 #14
0
 public void SaveCustomTile()
 {
     if (this.tileDataIndex >= 0)
     {
         Egcb_ReviewCharExtender.TileTarget             = CreateCharacter.Template.PlayerBody;
         Egcb_ReviewCharExtender.TileToApply            = this.TileData[this.tileDataIndex].Item1;
         Egcb_ReviewCharExtender.TileToApplyDetailColor = (this.detailColorListIndex >= 0) ? this.detailColorListStrings[this.detailColorListIndex] : this.TileData[this.tileDataIndex].Item2;
         Egcb_ReviewCharExtender.cachedColorIndex       = (this.detailColorListIndex >= 0) ? this.detailColorListIndex : -999;
         Egcb_ReviewCharExtender.cachedTileIndex        = this.tileDataIndex;
     }
 }
コード例 #15
0
ファイル: HZMapPinToggle.cs プロジェクト: HunterZ/qudmods
 public static void GameLoadHandler()
 {
     XRL.World.GameObject player = XRL.Core.XRLCore.Core?.Game?.Player?.Body;
     if (player == null)
     {
         return;
     }
     // add part only if it's not already present
     player.RequirePart <HZMapPinTogglePart>();
     // also set up ability if needed
     HZMapPinTogglePart.AddAbility(player);
 }
コード例 #16
0
 public static void ApplyCustomTile()
 {
     if (Egcb_ReviewCharExtender.TileTarget == XRLCore.Core.Game.Player.Body && !string.IsNullOrEmpty(Egcb_ReviewCharExtender.TileToApply))
     {
         Egcb_ReviewCharExtender.TileTarget.pRender.Tile        = Egcb_ReviewCharExtender.TileToApply;
         Egcb_ReviewCharExtender.TileTarget.pRender.DetailColor = Egcb_ReviewCharExtender.TileToApplyDetailColor;
         Egcb_ReviewCharExtender.TileTarget       = null;
         Egcb_ReviewCharExtender.TileToApply      = string.Empty;
         Egcb_ReviewCharExtender.cachedColorIndex = -999;
         Egcb_ReviewCharExtender.cachedTileIndex  = -999;
     }
 }
コード例 #17
0
 public static void UnflipGameObjectTexture(XRL.World.GameObject obj)
 {
     if (obj.pRender?.Tile != null && obj.pRender.Tile.EndsWith(Constants.FlippedTileSuffix))
     {
         string sourcePath = obj.pRender.Tile.Substring(0, obj.pRender.Tile.LastIndexOf(Constants.FlippedTileSuffix));
         GetTextureInfoFromBaseTilePath(sourcePath, out string originalTilePath);
         if (originalTilePath != null)
         {
             obj.pRender.Tile = originalTilePath;
         }
     }
 }
コード例 #18
0
            private static void Postfix_IsSuitableTarget(Brain __instance, GameObject who, ref bool __result)
            {
                if (__result || !__instance.IsPlayerLed() || who.HasEffect <Asleep>() || !who.IsHostileTowards(__instance.PartyLeader) || !__instance.CheckPerceptionOf(who))
                {
                    return;
                }

                var parent = __instance.ParentObject;

                if (__instance.PartyLeader.DistanceTo(who) <= 10)
                {
                    __result = true;
                }
            }
コード例 #19
0
ファイル: skillPainting.cs プロジェクト: acegiak/qudpigments
        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));
        }
コード例 #20
0
            /// <summary>
            /// Calculates the willpower-adjusted cooldown for an ability.
            /// </summary>
            public int GetAdjustedCooldown(int baseCooldown)
            {
                GameObject player = XRLCore.Core?.Game?.Player?.Body;

                if (player == null || !player.HasStat("Willpower"))
                {
                    return(baseCooldown);
                }
                int internalCooldown = baseCooldown * 10;
                int val = (int)((double)internalCooldown * (100.0 - (double)((player.Stat("Willpower", 0) - 16) * 5))) / 100;
                int calculatedCooldown = Math.Max(val, ActivatedAbilities.MinimumValueForCooldown(internalCooldown));

                baseCooldown = (int)Math.Ceiling((double)((float)calculatedCooldown / 10f));
                return(baseCooldown);
            }
コード例 #21
0
 public static void DirectEnableUIMode(string uiMode, string subMode, XRL.World.GameObject obj1)
 {
     Egcb_UIMonitor.Instance.UIMode          = uiMode;
     Egcb_UIMonitor.Instance.waitForUIFrames = 2; //allow a frame or two to pass until popup GameView transition occurs
     Egcb_UIMonitor.Instance.enabled         = true;
     Egcb_UIMonitor.Instance.UISubmode       = subMode;
     if (subMode == "LookTiler")
     {
         Egcb_UIMonitor.Instance.LookTiler = new Egcb_LookTiler(obj1);
     }
     if (subMode == "ConversationTiler")
     {
         Egcb_UIMonitor.Instance.ConversationTiler = new Egcb_ConversationTiler(obj1);
     }
 }
コード例 #22
0
        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);
        }
コード例 #23
0
        private string GetFactionString(Faction faction)
        {
            XRL.World.GameObject player = XRLCore.Core?.Game?.Player?.Body;
            if (player is null)
            {
                //Debug.Log("Player is null, big sad");
                return("");
            }
            Debug.Log("Getting faction feeling for faction " + faction.Name);
            int?factionFeeling = faction.GetFeelingTowardsObject(player);

            if (factionFeeling is null)
            {
                //Debug.Log($"Oh no, seems there was no faction by that name, I am cri :'(");
                return("");
            }
            char factionColour = (factionFeeling < 0) ? 'R' : (factionFeeling < 50) ? 'y' : 'G';

            return("{{" + factionColour + "|" + faction.DisplayName + "}}");
        }
コード例 #24
0
        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));
                    }
                }
            }
        }
コード例 #25
0
        public string GetItemValueString(GameObject item)
        {
            string valueString = String.Empty;
            int    weight      = (item.pPhysics != null) ? item.pPhysics.Weight : 0;

            if (weight <= 0)
            {
                valueString = "&Kweightless";
            }
            else
            {
                double itemValue     = this.GetItemPricePer(item) * (double)item.Count;
                double perPoundValue = itemValue / (double)weight;
                int    finalValue    = this.NalathniAppraiser.Approximate(perPoundValue); //Try to use the Nalathni Approximate method first, in case the player has NalathniDragon's Appraisal mod installed.
                if (finalValue < 0)                                                       //Fall back to normal integer rounding if the player doesn't have that mod installed (or if it returned a negative [intended to represent fractional] value)
                {
                    finalValue = (int)Math.Round(perPoundValue, MidpointRounding.AwayFromZero);
                }
                valueString = "&b$&c" + finalValue + "&y / lb.";
            }
            return(valueString);
        }
コード例 #26
0
ファイル: HZMapPinToggle.cs プロジェクト: HunterZ/qudmods
        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
                );
        }
コード例 #27
0
ファイル: HZShowOwner.cs プロジェクト: HunterZ/qudmods
        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);
        }
コード例 #28
0
        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));
        }
コード例 #29
0
ファイル: HZMapPinToggle.cs プロジェクト: HunterZ/qudmods
 // register for custom event callbacks
 public override void Register(XRL.World.GameObject obj)
 {
     obj.RegisterPartEvent(this, EVENT_NAME);
 }
コード例 #30
0
ファイル: skillPainting.cs プロジェクト: acegiak/qudpigments
        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);
            }
        }