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);
    }
Example #2
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 #3
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);
        }