public static Identifiable.Id CraftLargo(this LookupDirector director, Identifiable.Id slimeA, Identifiable.Id slimeB, Action <SlimeDefinition> extraLargoBehaviour = null, Predicate <Identifiable.Id> canBeTarr = null, Predicate <Identifiable.Id> forceLargo = null)
    {
        if (director.LargoExists(slimeA, slimeB))
        {
            return(Identifiable.Id.NONE);
        }

        string prefabName = "slime" +
                            slimeA.ToString().Replace("_SLIME", "").ToUpper()[0] + slimeA.ToString().Replace("_SLIME", "").ToLower().Substring(1) +
                            slimeB.ToString().Replace("_SLIME", "").ToUpper()[0] + slimeB.ToString().Replace("_SLIME", "").ToLower().Substring(1);

        string name = slimeA.ToString().Replace("_SLIME", "") + slimeB.ToString().Replace("_SLIME", "") + "_LARGO";

        Identifiable.Id largoID = IdentifiableRegistry.CreateIdentifiableId(EnumPatcher.GetFirstFreeValue(typeof(Identifiable.Id)), name);

        SlimeDefinitions defs = GameContext.Instance.SlimeDefinitions;

        SlimeDefinition curr  = defs.GetSlimeByIdentifiableId(slimeA);
        SlimeDefinition other = defs.GetSlimeByIdentifiableId(slimeB);

        bool largofyState = curr.CanLargofy;

        curr.CanLargofy = true;

        if (!other.CanLargofy && !(forceLargo?.Invoke(slimeB) ?? false))
        {
            return(Identifiable.Id.NONE);
        }

        bool largofyStateB = other.CanLargofy;

        other.CanLargofy = true;

        SlimeDefinition largoDef = defs.GetLargoByBaseSlimes(curr, other);

        largoDef.IdentifiableId = largoID;

        curr.CanLargofy  = largofyState;
        other.CanLargofy = largofyStateB;

        if (!(canBeTarr?.Invoke(slimeB) ?? true))
        {
            largoDef.Diet.EatMap.RemoveAll((entry) => entry.becomesId == Identifiable.Id.TARR_SLIME);
            largoDef.Diet.EatMap.RemoveAll((entry) => entry.becomesId == Identifiable.Id.GLITCH_TARR_SLIME);
        }

        extraLargoBehaviour?.Invoke(largoDef);

        SlimeTemplate largoTemplate = new SlimeTemplate(prefabName, largoDef).SetVacSize(Vacuumable.Size.LARGE)
                                      .SetTranslation(curr.Name + " " + other.Name + " Largo").Create();

        LookupRegistry.RegisterIdentifiablePrefab(largoTemplate.ToPrefab());

        return(largoID);
    }
        //+ SETUP
        /// <summary>
        /// Sets up a new identifiable into it's respective lists
        /// </summary>
        /// <param name="id">The ID to setup</param>
        public static void SetupIdentifiable(Identifiable.Id id)
        {
            string name = id.ToString();

            if (name.StartsWith(CRATE_PREFIX))
            {
                Identifiable.STANDARD_CRATE_CLASS.Add(id);
            }
            else if (name.StartsWith(ELDER_PREFIX))
            {
                Identifiable.ELDER_CLASS.Add(id);
            }
            else if (name.EndsWith(SYNERGY_SUFFIX))
            {
                Identifiable.LARGO_CLASS.Add(id);
                SYNERGY_CLASS.Add(id);
            }
            else if (name.EndsWith(EXTRACT_SUFFIX))
            {
                Identifiable.CRAFT_CLASS.Add(id);
                Identifiable.NON_SLIMES_CLASS.Add(id);
                EXTRACT_CLASS.Add(id);
            }
            else if (name.EndsWith(EFFY_SUFFIX))
            {
                EFFY_CLASS.Add(id);
            }
            else if (name.EndsWith(CAROL_SUFFIX))
            {
                Identifiable.ECHO_NOTE_CLASS.Add(id);
                CAROL_CLASS.Add(id);
            }
            Identifiable.EATERS_CLASS.UnionWith(SYNERGY_CLASS);
        }
Example #3
0
        // TODO: Make the get largo ID use both suffixes
        /// <summary>
        /// Gets a Custom Largo ID (With suffix _CLARGO)
        /// </summary>
        /// <param name="slimeA">ID of base slime A</param>
        /// <param name="slimeB">ID of base slime B</param>
        /// <param name="suffix">The suffix of the largo ID</param>
        public static Identifiable.Id GetLargoID(Identifiable.Id slimeA, Identifiable.Id slimeB, string suffix = "CLARGO")
        {
            string name  = $"{slimeA.ToString().Replace("_SLIME", "")}_{slimeB.ToString().Replace("_SLIME", "")}_{suffix}";
            string name2 = $"{slimeB.ToString().Replace("_SLIME", "")}_{slimeA.ToString().Replace("_SLIME", "")}_{suffix}";

            Identifiable.Id newID = Largo(name);

            if (newID != Identifiable.Id.NONE)
            {
                return(newID);
            }

            newID = Largo(name2);

            return(newID != Identifiable.Id.NONE ? newID : Identifiable.Id.NONE);
        }
Example #4
0
 public static void RegisterToFoodGroup(this Identifiable.Id id)
 {
     if (Identifiable.IsFruit(id))
     {
         id.RegisterToFoodGroup(SlimeEat.FoodGroup.FRUIT);
     }
     if (id.ToString().Contains("GINGER"))
     {
         id.RegisterToFoodGroup(SlimeEat.FoodGroup.GINGER);
     }
     if (Identifiable.IsAnimal(id))
     {
         id.RegisterToFoodGroup(SlimeEat.FoodGroup.MEAT);
     }
     if (Identifiable.IsSlime(id) && Identifiable.IsTarr(id))
     {
         id.RegisterToFoodGroup(SlimeEat.FoodGroup.NONTARRGOLD_SLIMES);
     }
     if (Identifiable.IsPlort(id))
     {
         id.RegisterToFoodGroup(SlimeEat.FoodGroup.PLORTS);
     }
     if (Identifiable.IsVeggie(id))
     {
         id.RegisterToFoodGroup(SlimeEat.FoodGroup.VEGGIES);
     }
 }
Example #5
0
        /// <summary>
        /// Register a toy (note: does not register the identifiable itself, only the toy, do that separately)
        /// </summary>
        /// <param name="id"><see cref="Identifiable.Id"/> of the toy</param>
        /// <param name="icon">Icon for the toy in the toy store</param>
        /// <param name="cost">How much the toy costs in the toy store</param>
        /// <param name="nameKey"></param>
        public static void RegisterToy(Identifiable.Id id, Sprite icon, int cost, string nameKey)
        {
            ToyDefinition definition = ScriptableObject.CreateInstance <ToyDefinition>();

            definition.toyId   = id;
            definition.icon    = icon;
            definition.cost    = cost;
            definition.nameKey = nameKey?.ToLower() ?? id.ToString().ToLower();
            RegisterToy(definition);
        }
        /// <summary>
        /// Creates a Toy Definition
        /// </summary>
        /// <param name="toyId">The ID of the toy for this definition</param>
        /// <param name="icon">The icon to be displayed</param>
        /// <param name="cost">The cost of this toy</param>
        /// <param name="nameKey">The name for the language key</param>
        public static ToyDefinition CreateToyDefinition(Identifiable.Id toyId, Sprite icon, int cost, string nameKey = null)
        {
            ToyDefinition definition = ScriptableObject.CreateInstance <ToyDefinition>();

            definition.SetPrivateField("toyId", toyId);
            definition.SetPrivateField("icon", icon);
            definition.SetPrivateField("cost", cost);
            definition.SetPrivateField("nameKey", nameKey?.ToLower() ?? toyId.ToString().ToLower());

            return(definition);
        }
    // Check Methods
    public static bool LargoExists(this LookupDirector director, Identifiable.Id slimeA, Identifiable.Id slimeB)
    {
        string nameA = slimeA.ToString().Replace("_SLIME", "");
        string nameB = slimeB.ToString().Replace("_SLIME", "");

        string largoA = $"{nameA}_{nameB}_LARGO";
        string largoB = $"{nameB}_{nameA}_LARGO";

        object result = Enum.Parse(typeof(Identifiable.Id), largoA) ?? Enum.Parse(typeof(Identifiable.Id), largoB);

        return(result != null);
    }
Example #8
0
        internal Identifiable.Id CraftLargo(bool canBeTarr, Identifiable.Id slimeA, Identifiable.Id slimeB, System.Action <SlimeDefinition> extraLargoBehaviour = null)
        {
            if (GameContext.Instance.LookupDirector.LargoExists(slimeA, slimeB))
            {
                return(Identifiable.Id.NONE);
            }

            string prefabName = mainObject.Name + slimeB.ToString().Replace("_SLIME", "").ToUpper()[0] + slimeB.ToString().Replace("_SLIME", "").ToLower().Substring(1);
            string name       = slimeA.ToString().Replace("_SLIME", "") + slimeB.ToString().Replace("_SLIME", "") + "_LARGO";

            Identifiable.Id largoID = IdentifiableRegistry.CreateIdentifiableId(EnumPatcher.GetFirstFreeValue(typeof(Identifiable.Id)), name);

            SlimeDefinitions defs = GameContext.Instance.SlimeDefinitions;

            SlimeDefinition other = defs.GetSlimeByIdentifiableId(slimeB);

            if (!other.CanLargofy)
            {
                return(Identifiable.Id.NONE);
            }

            SlimeDefinition largoDef = defs.GetLargoByBaseSlimes(definition, other);

            largoDef.IdentifiableId = largoID;

            if (!canBeTarr)
            {
                largoDef.Diet.EatMap.RemoveAll((entry) => entry.becomesId == Identifiable.Id.TARR_SLIME);
                largoDef.Diet.EatMap.RemoveAll((entry) => entry.becomesId == Identifiable.Id.GLITCH_TARR_SLIME);
            }

            extraLargoBehaviour?.Invoke(largoDef);

            SlimeTemplate largoTemplate = new SlimeTemplate(prefabName, largoDef).SetFeralState(canBeFeral).SetGlitchState(canBeAGlitch)
                                          .SetVacSize(Vacuumable.Size.LARGE).SetTranslation(definition.Name + " " + other.Name + " Largo").Create();

            LookupRegistry.RegisterIdentifiablePrefab(largoTemplate.ToPrefab());

            return(largoID);
        }
Example #9
0
 static void Prefix(Ammo __instance, Identifiable.Id id)
 {
     PlortMarket.Log("[AncientWater-Prefix] id: " + id.ToString());
     if (id == Identifiable.Id.MAGIC_WATER_LIQUID)
     {
         PlortMarket.Log("[AncientWater-Prefix] ID == MAGIC_WATER_LIQUID");
         isAncientWater = true;
     }
     else
     {
         //PlortMarket.Log("[AncientWater-Prefix] ID != MAGIC_WATER_LIQUID");
         isAncientWater = false;
     }
 }
Example #10
0
        /// <summary>
        /// Generates all the IDs for the largos.
        /// <para>NOTE that all IDs are generated even if they don't get used.</para>
        /// </summary>
        /// <param name="slimeToLargo">ID of the slime to create largos</param>
        public static void GenerateLargoIDs(Identifiable.Id slimeToLargo)
        {
            foreach (Identifiable.Id id in Identifiable.SLIME_CLASS)
            {
                if (GetLargoID(slimeToLargo, id) != Identifiable.Id.NONE)
                {
                    continue;
                }

                string name = $"{slimeToLargo.ToString().Replace("_SLIME", "")}_{id.ToString().Replace("_SLIME", "")}_LARGO";

                var newVal = EnumPatcher.GetFirstFreeValue(typeof(Identifiable.Id));
                IdentifiableRegistry.CreateIdentifiableId(newVal, name, false);
            }
        }
Example #11
0
        /// <summary>
        /// Generates all the IDs for the custom largos. (THIS CAN ONLY RUN ON PRE-LOAD)
        /// <para>NOTE that all IDs are generated even if they don't get used.</para>
        /// </summary>
        /// <param name="slimeToLargo">ID of the slime to create custom largos</param>
        public static void GenerateLargoIDs(Identifiable.Id slimeToLargo)
        {
            foreach (Identifiable.Id id in Identifiable.SLIME_CLASS)
            {
                if (GetLargoID(slimeToLargo, id) != Identifiable.Id.NONE &&
                    GetLargoID(slimeToLargo, id, "LARGO") != Identifiable.Id.NONE)
                {
                    continue;
                }

                string name = $"{slimeToLargo.ToString().Replace("_SLIME", "")}_{id.ToString().Replace("_SLIME", "")}_CLARGO";

                // TODO: Fix this
                //Identifiable.Id newVal = EnumFixer.AddValue<Identifiable.Id>(name);
                //IdentifiableRegistry.CreateIdentifiableId(newVal, name, false);
            }
        }
    public static GameObject GetLargoPrefab(this LookupDirector director, Identifiable.Id slimeA, Identifiable.Id slimeB)
    {
        Identifiable.Id largo = Identifiable.Id.NONE;

        string nameA = slimeA.ToString().Replace("_SLIME", "");
        string nameB = slimeB.ToString().Replace("_SLIME", "");

        string largoA = $"{nameA}_{nameB}_LARGO";
        string largoB = $"{nameB}_{nameA}_LARGO";

        object result = Enum.Parse(typeof(Identifiable.Id), largoA) ?? Enum.Parse(typeof(Identifiable.Id), largoB);

        if (result != null)
        {
            largo = (Identifiable.Id)result;
        }

        return(largo == Identifiable.Id.NONE ? null : director.GetPrefab(largo));
    }
Example #13
0
 /// <summary>
 /// Sets the translation for this slime's name
 /// </summary>
 /// <param name="name">The translated name</param>
 public override FoodTemplate SetTranslation(string name)
 {
     TranslationPatcher.AddActorTranslation("l." + ID.ToString().ToLower(), name);
     return(this);
 }
Example #14
0
        private void RandomizeSlimeDiets(System.Random rand)
        {
            if (!diet_enabled)
            {
                return;
            }

            // Build list of food items that cannot be set as favorite //
            List <Identifiable.Id> restrictedFavorites = new List <Identifiable.Id>();

            if (!diet_allowElderFavorite)
            {
                restrictedFavorites.Add(Identifiable.Id.ELDER_HEN);
                restrictedFavorites.Add(Identifiable.Id.ELDER_ROOSTER);
            }
            if (!diet_allowGildedGingerFavorite)
            {
                restrictedFavorites.Add(Identifiable.Id.GINGER_VEGGIE);
            }
            if (!diet_allowKookadobaFavorite)
            {
                restrictedFavorites.Add(Identifiable.Id.KOOKADOBA_FRUIT);
            }
            if (!diet_allowTofuFavorite)
            {
                restrictedFavorites.Add(Identifiable.Id.SPICY_TOFU);
            }


            // Build list of allowed slime & largo types //
            SlimeDefinitions       slimeDefinitions = SRSingleton <GameContext> .Instance.SlimeDefinitions;
            List <Identifiable.Id> allowedSlimes    = new List <Identifiable.Id>(Identifiable.EATERS_CLASS);

            //remove slimes from the list that are special cases or have no diet
            allowedSlimes.Remove(Identifiable.Id.FIRE_SLIME);
            allowedSlimes.Remove(Identifiable.Id.GLITCH_SLIME);
            allowedSlimes.Remove(Identifiable.Id.GLITCH_TARR_SLIME);
            allowedSlimes.Remove(Identifiable.Id.PUDDLE_SLIME);
            allowedSlimes.Remove(Identifiable.Id.QUICKSILVER_SLIME);
            allowedSlimes.Remove(Identifiable.Id.TARR_SLIME);

            //remove slimes as specified by options
            if (!diet_changeGoldSlimeDiet)
            {
                allowedSlimes.Remove(Identifiable.Id.GOLD_SLIME);
            }
            if (!diet_changeLuckySlimeDiet)
            {
                allowedSlimes.Remove(Identifiable.Id.LUCKY_SLIME);
            }
            if (!diet_changePinkSlimeDiet)
            {
                allowedSlimes.Remove(Identifiable.Id.PINK_SLIME);
            }


            // Handle base slime types //
            IEnumerable <Identifiable.Id> baseSlimes = from slime in allowedSlimes
                                                       where slime.ToString().EndsWith("_SLIME")
                                                       select slime;

            foreach (Identifiable.Id slime in baseSlimes)
            {
                SlimeDefinition currSlime = slimeDefinitions.GetSlimeByIdentifiableId(slime);

                Log("Slime: " + currSlime);

                //set new food group
                SlimeEat.FoodGroup newFoodGroup = PickRandom(VALID_FOOD_GROUPS, rand);
                currSlime.Diet.MajorFoodGroups = new SlimeEat.FoodGroup[] { newFoodGroup };

                Log("Food group: " + newFoodGroup.ToString());

                //set new favorite food
                Identifiable.Id newFavoriteFood = Identifiable.Id.NONE;
                while (newFavoriteFood == Identifiable.Id.NONE || restrictedFavorites.Contains(newFavoriteFood))
                {
                    IEnumerable <Identifiable.Id> idClass = null;
                    if (newFoodGroup == SlimeEat.FoodGroup.FRUIT)
                    {
                        idClass = Identifiable.FRUIT_CLASS;
                    }
                    else if (newFoodGroup == SlimeEat.FoodGroup.VEGGIES)
                    {
                        idClass = Identifiable.VEGGIE_CLASS;
                    }
                    else if (newFoodGroup == SlimeEat.FoodGroup.MEAT)
                    {
                        idClass = Identifiable.MEAT_CLASS;
                    }
                    else
                    {
                        Log("Invalid food group in RandomizeSlimeDiets. Applying fallback...");
                        newFavoriteFood = Identifiable.Id.POGO_FRUIT;
                        break;
                    }

                    newFavoriteFood = PickRandom(idClass, rand);
                }

                Log("Favorite food: " + newFavoriteFood.ToString());

                currSlime.Diet.Favorites = new Identifiable.Id[] { newFavoriteFood };
            }


            // Handle largo types //
            IEnumerable <Identifiable.Id> largos = from largo in allowedSlimes
                                                   where largo.ToString().EndsWith("_LARGO")
                                                   select largo;

            foreach (Identifiable.Id largo in largos)
            {
                SlimeDefinition currLargo = slimeDefinitions.GetSlimeByIdentifiableId(largo);
                if (currLargo.IsLargo && currLargo.BaseSlimes.Length == 2) //coherence check
                {
                    currLargo.Diet = SlimeDiet.Combine(currLargo.BaseSlimes[0].Diet, currLargo.BaseSlimes[1].Diet);
                }
                else
                {
                    Log("Non-largo coming through largo diet randomization? Id: " + largo.ToString());
                }
            }


            //refresh the EatMap of every slime definition (apply the changes, essentially)
            slimeDefinitions.RefreshDefinitions();
        }
        /// <summary>
        /// Converts a Gordo Slime ID to its base Slime ID
        /// </summary>
        /// <param name="gordoID">Gordo Slime ID</param>
        /// <returns>The base slime ID</returns>
        public static Identifiable.Id GetSlimeFromGordo(Identifiable.Id gordoID)
        {
            string name = gordoID.ToString().Replace("_GORDO", "_SLIME");

            return(EnumUtils.Parse <Identifiable.Id>(name));
        }