public string BlueprintPath(GameObjectBlueprint blueprint)
        {
            string path = string.Empty;

            if (blueprint == null)
            {
                return(path);
            }
            if (!string.IsNullOrEmpty(blueprint.Name))
            {
                path = blueprint.Name;
            }
            bool hasParent = !string.IsNullOrEmpty(blueprint.Inherits);

            if (hasParent)
            {
                path = blueprint.Inherits + " > " + path;
            }
            GameObjectBlueprint parent;

            if (hasParent && GameObjectFactory.Factory.Blueprints.TryGetValue(blueprint.Inherits, out parent))
            {
                if (!string.IsNullOrEmpty(parent.Inherits))
                {
                    path = parent.Inherits + " > " + path;
                }
            }
            return(path);
        }
Exemple #2
0
        public static Recipe ParseRecipe(GameObjectBlueprint blueprint)
        {
            byte duration;

            if (
                blueprint.HasTag(TAG_RECIPE) &&
                blueprint.HasTag(TAG_INGREDIENTS) &&
                blueprint.HasTag(TAG_DURATION) &&
                blueprint.HasTag(TAG_BEVERAGE) &&
                byte.TryParse(
                    blueprint.GetTag(TAG_DURATION),
                    result: out duration
                    )
                )
            {
                var recipe = new Recipe();

                recipe.Ingredients = new SortedSet <string>(
                    blueprint.GetTag(TAG_INGREDIENTS).Split(',')
                    );

                recipe.Duration = duration;
                recipe.Beverage = blueprint.GetTag(TAG_BEVERAGE);
                recipe.Mistake  = blueprint.HasTag(TAG_MISTAKE);
                recipe.Tricky   = blueprint.HasTag(TAG_TRICKY);
                return(recipe);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        public bool isGOaFactionHeirloom(GameObject GO)
        {
            foreach (KeyValuePair <string, int> item in ParentObject.pBrain.FactionMembership)
            {
                if (ParentObject.pBrain.GetFactionAllegiance(item.Key) == Brain.FactionAllegiance.member)
                {
                    Faction faction  = XRL.World.Factions.getIfExists(item.Key);
                    string  heirloom = faction.Heirloom.ToLower();
                    heirloom = Regex.Replace(heirloom, @"s$", "");
                    heirloom = Regex.Replace(heirloom, "body", "basearmor");
                    //IPart.AddPlayerMessage(heirloom+" is SOUGHT");

                    GameObjectBlueprint bp = GameObjectFactory.Factory.GetBlueprint(GO.Blueprint);
                    if (bp.Name.ToLower().Contains(heirloom))
                    {
                        //IPart.AddPlayerMessage(GO.Blueprint+" is FAVOURABLE");

                        return(true);
                    }
                    while (bp != null && bp.Inherits != null)
                    {
                        if (bp.Name.ToLower().Contains(heirloom))
                        {
                            //IPart.AddPlayerMessage(GO.Blueprint+" is FAVOURABLE");

                            return(true);
                        }
                        bp = GameObjectFactory.Factory.GetBlueprint(bp.Inherits);
                    }
                }
            }
            //IPart.AddPlayerMessage(GO.Blueprint+" is NOT FAVOURABLE");

            return(false);
        }
        private static void ApplyCyberneticsStatMods()
        {
            GameObjectBlueprint gameObjectBlueprint = GetCyberneticBlueprint();

            if (gameObjectBlueprint != null)
            {
                string partParameter = gameObjectBlueprint.GetPartParameter("Cybernetics2StatModifier", "Stats");
                if (!string.IsNullOrEmpty(partParameter))
                {
                    foreach (string item in partParameter.CachedCommaExpansion())
                    {
                        string[] array = item.Split(':');
                        if (array.Length != 2)
                        {
                            continue;
                        }
                        try
                        {
                            string key = array[0];
                            if (key != "Strength" && key != "Agility" && key != "Toughness" && key != "Intelligence" && key != "Willpower" && key != "Ego")
                            {
                                continue;
                            }
                            int num = Convert.ToInt32(array[1]);
                            BuildTemplate.PlayerBody.Statistics[key].Bonus += num;
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
        public static List <string> GetBuildSidebarInfo()
        {
            List <string> buildInfo = new List <string>();

            buildInfo.Add("{{y|" + BuildTemplate.Genotype + ", " + BuildTemplate.Subtype + "}}");
            buildInfo.Add("");
            buildInfo.Add(MakeStatString(BuildTemplate.PlayerBody, "Strength"));
            buildInfo.Add(MakeStatString(BuildTemplate.PlayerBody, "Agility"));
            buildInfo.Add(MakeStatString(BuildTemplate.PlayerBody, "Toughness"));
            buildInfo.Add(MakeStatString(BuildTemplate.PlayerBody, "Intelligence"));
            buildInfo.Add(MakeStatString(BuildTemplate.PlayerBody, "Willpower"));
            buildInfo.Add(MakeStatString(BuildTemplate.PlayerBody, "Ego"));
            buildInfo.Add("");

            GameObjectBlueprint cyberneticBlueprint = GetCyberneticBlueprint();
            Mutations           mutations           = BuildTemplate.PlayerBody.GetPart <Mutations>();
            bool hasCybernetics = cyberneticBlueprint != null;
            bool hasMutations   = mutations != null && mutations.MutationList.Count > 0;

            if (hasCybernetics)
            {
                buildInfo.Add("{{y|[ {{C|Cybernetics}} ]}}");
                buildInfo.Add("");
                buildInfo.Add(cyberneticBlueprint.GetPartParameter("Render", "DisplayName"));
                if (hasMutations)
                {
                    buildInfo.Add("");
                }
            }
            if (hasMutations)
            {
                buildInfo.Add("{{y|[ {{M|Mutations}} ]}}");
                buildInfo.Add("");

                if (!string.IsNullOrEmpty(BuildTemplate.MutationLevel))
                {
                    buildInfo.Add("{{C|" + BuildTemplate.MutationLevel + "}}");
                }
                for (int i = 0; i < mutations.MutationList.Count; i++)
                {
                    string displayName = mutations.MutationList[i].DisplayName;
                    if (!string.IsNullOrEmpty(displayName))
                    {
                        buildInfo.Add(displayName);
                    }
                    else
                    {
                        buildInfo.Add("{{R|*" + mutations.MutationList[i].Name + "*}}");
                    }
                }
            }
            return(buildInfo);
        }
Exemple #6
0
        public void Build(GameObject who)
        {
            Cell cell = ParentObject.CurrentCell;

            if (cell == null)
            {
                Popup.Show("Put things on the ground to build with them.");
                return;
            }
            GameObjectBlueprint bp = ChooseBuild(getBuilds());

            if (bp == null)
            {
                Popup.Show("There's nothing that uses those parts.");
                return;
            }
            Assemble(bp.GetTag("acegiak_Buildable"), bp.Name, cell, who);
        }
Exemple #7
0
        /// <summary>
        /// Remove elements of chance by including/excluding all.
        /// TODO: Deep clone and preserve original.
        /// </summary>
        GameObjectBlueprint NormalizeBlueprint(GameObjectBlueprint blueprint, bool max = false)
        {
            if (blueprint.Inventory == null)
            {
                return(blueprint);
            }

            foreach (var item in blueprint.Inventory)
            {
                if (item.Chance <= 0 || item.Chance >= 100)
                {
                    continue;
                }
                item.Chance = max ? 100 : 0;
            }

            return(blueprint);
        }
Exemple #8
0
        /// <summary>
        /// Filter out blueprints that should not be serialised.
        /// </summary>
        bool BlueprintPredicate(GameObjectBlueprint blueprint)
        {
            if (!blueprint.HasPart("Render"))
            {
                return(false);
            }
            if (blueprint.IsBaseBlueprint())
            {
                return(false);
            }
            if (blueprint.DescendsFrom("Widget"))
            {
                return(false);
            }
            if (blueprint.DescendsFrom("DataBucket"))
            {
                return(false);
            }

            return(true);
        }
        public bool CheckBlueprintMatchesQuery(GameObjectBlueprint blueprint, string queryLowercase)
        {
            if (blueprint == null)
            {
                return(false);
            }
            if (!string.IsNullOrEmpty(blueprint.Name) && blueprint.Name.ToLower().Contains(queryLowercase))
            {
                return(true);
            }
            bool hasParent = !string.IsNullOrEmpty(blueprint.Inherits);

            if (hasParent && blueprint.Inherits.ToLower().Contains(queryLowercase))
            {
                return(true);
            }
            GameObjectBlueprint parent;

            if (hasParent && GameObjectFactory.Factory.Blueprints.TryGetValue(blueprint.Inherits, out parent))
            {
                if (!string.IsNullOrEmpty(parent.Inherits) && parent.Inherits.ToLower().Contains(queryLowercase))
                {
                    return(true);
                }
            }
            GamePartBlueprint renderPart = blueprint.GetPart("Render");

            if (renderPart != null)
            {
                string displayName = renderPart.Parameters.ContainsKey("DisplayName") ? renderPart.Parameters["DisplayName"] : null;
                if (!string.IsNullOrEmpty(displayName))
                {
                    if (ColorUtility.StripFormatting(displayName).ToLower().Contains(queryLowercase))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        public override acegiak_RomancePreferenceResult GiftRecieve(GameObject from, GameObject gift)
        {
            float  retamount  = 0;
            string retexplain = "";

            if (gift.GetPart <ModFeathered>() != null && this.interestedFaction == "Birds")
            {
                retamount  += this.amount;
                retexplain += Romancable.ParentObject.The + Romancable.ParentObject.ShortDisplayName + Romancable.ParentObject.GetVerb("think") + " the feathers on " + gift.the + gift.ShortDisplayName + (this.amount > 0?"are excellent":"are horrible") + ".\n";
            }
            if (gift.GetPart <ModScaled>() != null && this.interestedFaction == "Unshelled Reptiles")
            {
                retamount  += this.amount;
                retexplain += Romancable.ParentObject.The + Romancable.ParentObject.ShortDisplayName + Romancable.ParentObject.GetVerb("think") + " the scales on " + gift.the + gift.ShortDisplayName + (this.amount > 0?"are excellent":"are horrible") + ".\n";
            }
            if (gift.GetPart <AddsRep>() != null && gift.GetPart <AddsRep>().Faction == this.interestedFaction)
            {
                retamount += this.amount;
            }
            GameObjectBlueprint bp = gift.GetBlueprint();

            if (bp.InheritsFrom("Jerky"))
            {
                GameObject g = EncountersAPI.GetAnObject((GameObjectBlueprint b) =>
                                                         b.GetPartParameter("Preservable", "Result") == bp.Name);
                if (g != null)
                {
                    bp = g.GetBlueprint();
                }
            }

            if (bp.InheritsFrom("Raw Meat"))
            {
                GameObject g = EncountersAPI.GetAnObject((GameObjectBlueprint b) =>
                                                         b.GetPartParameter("Butcherable", "OnSuccess") == bp.Name);
                if (g != null)
                {
                    bp = g.GetBlueprint();
                }
            }

            if (bp.InheritsFrom("Corpse"))
            {
                GameObject g = EncountersAPI.GetAnObject((GameObjectBlueprint b) =>
                                                         b.GetPartParameter("Corpse", "CorpseBlueprint") == bp.Name);
                if (g != null)
                {
                    if (this.interestedFaction == g.pBrain.GetPrimaryFaction())
                    {
                        retamount  += amount * -1;
                        retexplain += Romancable.ParentObject.The + Romancable.ParentObject.ShortDisplayName + Romancable.ParentObject.GetVerb("is") + (this.amount > 0?"upset by the remains of":"pleased by the remains of") + g.a + g.DisplayNameOnly + ".\n";
                    }
                }
            }
            if (retamount != 0 || retexplain != "")
            {
                return(new acegiak_RomancePreferenceResult(retamount, retexplain));
            }
            // if(getType(gift) == wantedType){
            //     return new acegiak_RomancePreferenceResult(amount,(amount >= 0 ?"&Glikes&Y the ":"&rdislikes&Y the ")+gift.ShortDisplayName+"&Y.");
            // }
            return(null);
        }
        public void ScanTarget()
        {
            string  description = string.Empty;
            Physics tempPhysics = ParentObject.pPhysics;

            if (tempPhysics.Equipped == null)
            {
                return;
            }
            if (tempPhysics.Equipped.pPhysics.CurrentCell.ParentZone.IsWorldMap())
            {
                return;
            }
            if (!tempPhysics.Equipped.IsPlayer())
            {
                return;
            }

            Cell targetCell = tempPhysics.Equipped.pPhysics.PickDestinationCell(10, AllowVis.OnlyVisible, false);

            if (targetCell == null)
            {
                return;
            }

            string output = string.Empty;

            foreach (GameObject gameObject in targetCell.GetObjectsWithPart("Brain"))
            {
                output = "Reading the brain of " + gameObject.DisplayName;
                XRLCore.Core.Game.Player.Messages.Add(output);

                GameObjectBlueprint myGOB = gameObject.GetBlueprint();
                output = "The target is a " + myGOB.Inherits;
                XRLCore.Core.Game.Player.Messages.Add(output);

                string targetsFaction = gameObject.pBrain.GetPrimaryFaction();

                output = "The targets primary faction is " + Faction.getFormattedName(targetsFaction);
                XRLCore.Core.Game.Player.Messages.Add(output);

                foreach (KeyValuePair <string, Faction> item in Factions.FactionList)
                {
                    bool modified      = false;
                    int  factionAmount = Factions.GetFeelingFactionToFaction(targetsFaction, item.Value.Name);
                    if (gameObject.pBrain.FactionFeelings.ContainsKey(item.Value.Name))
                    {
                        factionAmount = gameObject.pBrain.FactionFeelings[item.Value.Name];
                        modified      = true;
                    }

                    if (factionAmount == 0)
                    {
                        continue;
                    }

                    output = Faction.getFormattedName(item.Value.Name) + ": ";
                    if (factionAmount < 0)
                    {
                        if (modified)
                        {
                            output += "[&r" + factionAmount + "&y]";
                        }
                        else
                        {
                            output += "&r" + factionAmount + "&y";
                        }
                    }
                    else
                    {
                        if (modified)
                        {
                            output += "[&g" + factionAmount + "&y]";
                        }
                        else
                        {
                            output += "&g" + factionAmount + "&y";
                        }
                    }

                    XRLCore.Core.Game.Player.Messages.Add(output);
                }
            }
        }
Exemple #12
0
        public void havePreference()
        {
            if (ParentObject.IsPlayer())
            {
                this.preferences = new List <acegiak_RomancePreference>();
                this.boons       = new List <acegiak_RomanceBoon>();
                return;
            }
            bool loading = false;

            if (this.preferences == null || this.boons == null)
            {
                Loading.SetLoadingStatus("Compiling preferences...");
                loading = true;
            }
            if (this.preferences == null)
            {
                //IPart.AddPlayerMessage("Populating Preference for "+ParentObject.DisplayNameOnly);
                this.preferences = new List <acegiak_RomancePreference>();

                List <acegiak_RomancePreference> possible = new List <acegiak_RomancePreference>();


                if (GameObjectFactory.Factory == null || GameObjectFactory.Factory.BlueprintList == null)
                {
                    return;
                }
                GameObjectBlueprint[] blueprints = GameObjectFactory.Factory.BlueprintList.ToArray();
                for (int i = blueprints.Length - 1; i >= 0; i--)
                {
                    GameObjectBlueprint blueprint = blueprints[i];
                    if (!blueprint.IsBaseBlueprint() && blueprint.DescendsFrom("RomancePreference"))
                    {
                        //IPart.AddPlayerMessage("possible preference type:"+blueprint.Name);
                        GameObject sample = GameObjectFactory.Factory.CreateSampleObject(blueprint.Name);
                        if (sample.HasTag("classname") && sample.GetTag("classname") != null && sample.GetTag("classname") != "")
                        {
                            try{
                                acegiak_RomancePreference preference = Activator.CreateInstance(Type.GetType(sample.GetTag("classname")), this) as acegiak_RomancePreference;
                                possible.Add(preference);
                            }catch (Exception e) {
                                LogWarning(e.ToString());
                            }
                        }
                    }
                }
                //IPart.AddPlayerMessage("possible prefs checked.");


                int count = Stat.Rnd2.Next(3) + 3;
                //IPart.AddPlayerMessage("choosing "+count.ToString()+" out of "+possible.Count().ToString()+" prefs");

                for (int i = 0; i < count; i++)
                {
                    int w = Stat.Rnd2.Next(possible.Count());
                    preferences.Add(possible[w]);
                }
            }



            if (this.boons == null)
            {
                // IPart.AddPlayerMessage("Populating Preference");
                this.boons = new List <acegiak_RomanceBoon>();

                List <acegiak_RomanceBoon> possible = new List <acegiak_RomanceBoon>();


                if (GameObjectFactory.Factory == null || GameObjectFactory.Factory.BlueprintList == null)
                {
                    return;
                }
                foreach (GameObjectBlueprint blueprint in GameObjectFactory.Factory.BlueprintList)
                {
                    if (!blueprint.IsBaseBlueprint() && blueprint.DescendsFrom("RomanceBoon"))
                    {
                        //IPart.AddPlayerMessage(blueprint.Name);
                        GameObject sample = GameObjectFactory.Factory.CreateSampleObject(blueprint.Name);
                        if (sample.HasTag("classname") && sample.GetTag("classname") != null && sample.GetTag("classname") != "")
                        {
                            acegiak_RomanceBoon preference = Activator.CreateInstance(Type.GetType(sample.GetTag("classname")), this) as acegiak_RomanceBoon;
                            possible.Add(preference);
                        }
                    }
                }
                int count = Stat.Rnd2.Next(2);
                for (int i = 0; i < count; i++)
                {
                    int w = Stat.Rnd2.Next(possible.Count());
                    boons.Add(possible[w]);
                }



                // IPart.AddPlayerMessage(this.preferences.ToString());
            }


            if (loading)
            {
                Loading.SetLoadingStatus(null);
            }


            touch();
        }
Exemple #13
0
        public override bool FireEvent(Event E)
        {
            if (E.ID == "CommandReadEmotions")
            {
                Cell C = PickDestinationCell(12, AllowVis.Any, false);
                if (C == null)
                {
                    return(false);
                }
                if (ParentObject.pPhysics.CurrentCell.DistanceTo(C) > 12)
                {
                    if (ParentObject.IsPlayer())
                    {
                        Popup.Show("That it out of range (maximum 12)", true);
                    }
                    return(false);
                }
                ReadEmotionsActivatedAbility.Cooldown = 0;
                this.UseEnergy(1000);

                string output = string.Empty;
                foreach (GameObject gameObject in C.GetObjectsWithPart("Brain"))
                {
                    output = "Reading the brain of " + gameObject.DisplayName;
                    XRLCore.Core.Game.Player.Messages.Add(output);

                    GameObjectBlueprint myGOB = gameObject.GetBlueprint();
                    output = gameObject.DisplayName + " is a " + myGOB.Inherits;
                    XRLCore.Core.Game.Player.Messages.Add(output);

                    string targetsFaction = gameObject.pBrain.GetPrimaryFaction();

                    output = gameObject.DisplayName + " primary faction is " + Faction.getFormattedName(targetsFaction);
                    XRLCore.Core.Game.Player.Messages.Add(output);

                    foreach (KeyValuePair <string, Faction> item in Factions.FactionList)
                    {
                        bool modified      = false;
                        int  factionAmount = Factions.GetFeelingFactionToFaction(targetsFaction, item.Value.Name);
                        if (gameObject.pBrain.FactionFeelings.ContainsKey(item.Value.Name))
                        {
                            factionAmount = gameObject.pBrain.FactionFeelings[item.Value.Name];
                            modified      = true;
                        }

                        if (factionAmount == 0)
                        {
                            continue;
                        }
                        if (factionAmount > 0 && showFriendy == false)
                        {
                            continue;
                        }

                        output = Faction.getFormattedName(item.Value.Name);
                        if (factionAmount < 0)
                        {
                            output = "&rattack " + output + "&y";
                        }
                        else
                        {
                            output = "&gignore " + output + "&y";
                        }

                        output = gameObject.DisplayName + " will " + output + " faction members";

                        if (showNumbers)
                        {
                            if (factionAmount < 0)
                            {
                                if (modified)
                                {
                                    output += ": [&r" + factionAmount + "&y]";
                                }
                                else
                                {
                                    output += ": &r" + factionAmount + "&y";
                                }
                            }
                            else
                            {
                                if (modified)
                                {
                                    output += ": [&g" + factionAmount + "&y]";
                                }
                                else
                                {
                                    output += ": &g" + factionAmount + "&y";
                                }
                            }
                        }
                        output += ".";

                        XRLCore.Core.Game.Player.Messages.Add(output);
                    }
                }
            }
            return(true);
        }