Exemplo n.º 1
0
    /// <summary>
    /// Combines two Slime Definitions to create one for a Largo
    /// <para>The Identifiable ID for the Largo is Auto Generated</para>
    /// </summary>
    /// <param name="our">Our slime definition</param>
    /// <param name="other">The one to make a Largo with</param>
    /// <returns>The definition or null if it couldn't be created</returns>
    public static SlimeDefinition CombineForLargo(this SlimeDefinition our, SlimeDefinition other)
    {
        if (!other.CanLargofy)
        {
            return(null);
        }

        SlimeDefinition def = ScriptableObject.CreateInstance <SlimeDefinition>();

        def.name = our.name + " " + other.name;

        def.BaseModule = our.BaseModule;
        def.BaseSlimes = new[] { our, other };
        def.CanLargofy = false;

        def.IdentifiableId = SlimeUtils.GetLargoID(our.IdentifiableId, other.IdentifiableId);
        def.IsLargo        = false;

        def.Name        = "Largo " + our.Name + " " + other.Name;
        def.PrefabScale = 2f;

        List <GameObject> modules = new List <GameObject>(our.SlimeModules);

        modules.AddRange(other.SlimeModules);
        def.SlimeModules = modules.ToArray();

        def.AppearancesDefault = our.GetCombinedAppearancesDefault(other.AppearancesDefault);
        def.AppearancesDynamic = our.GetCombinedAppearancesDynamic(other.AppearancesDynamic);
        def.LoadDietFromBaseSlimes();
        def.LoadFavoriteToysFromBaseSlimes();

        def.Sounds = our.Sounds;

        return(def);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Generates a roaming Gordo Slime for this slime (use this if you want the slime to have a Gordo counter part)
        /// <para>Roaming gordos are normal slimes scaled as a gordo and contains almost no behaviours, also it doesnt eat. Use PrefabFunctions to give it
        /// behaviours</para>
        /// </summary>
        /// <param name="gordoID">The ID for the gordo</param>
        /// <returns>The slime template for the Roaming Gordo (YOU NEED TO CLASS .Create TO FINISH THE PROCESS)</returns>
        public SlimeTemplate MakeRoamingGordo(Identifiable.Id gordoID)
        {
            if (isGordo)
            {
                return(null);
            }

            SlimeDefinition gordoDef = ScriptableObject.CreateInstance <SlimeDefinition>();

            gordoDef.AppearancesDefault = definition.AppearancesDefault;
            gordoDef.AppearancesDynamic = definition.AppearancesDynamic;
            gordoDef.BaseModule         = definition.BaseModule;
            gordoDef.BaseSlimes         = definition.BaseSlimes;
            gordoDef.CanLargofy         = false;
            gordoDef.Diet           = definition.Diet;
            gordoDef.FavoriteToys   = new Identifiable.Id[0];
            gordoDef.IdentifiableId = gordoID;
            gordoDef.IsLargo        = true;
            gordoDef.PrefabScale    = 4f;
            gordoDef.SlimeModules   = definition.SlimeModules;
            gordoDef.Sounds         = definition.Sounds;
            gordoDef.Name           = "roamGordo." + definition.Name;

            FearProfile prof = ScriptableObject.CreateInstance <FearProfile>();

            prof.threats = new List <FearProfile.ThreatEntry>();
            prof.GetType().GetMethod("OnEnable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(prof, new object[0]);

            SlimeTemplate gordo = new SlimeTemplate("gordo" + mainObject.Name.Replace("slime", ""), gordoDef).SetVacSize(Vacuumable.Size.GIANT)
                                  .SetHealth(60).SetFeralState(false).SetGlitchState(false).SetFearProfile(prof).SetTranslation(definition.Name + " Gordo");

            gordo.isGordo = true;

            return(gordo);
        }
Exemplo n.º 3
0
 internal static bool Prefix(SlimeDefinition slimeDefinition, SlimeAppearance appearance)
 {
     if (slimeDefinition == null || appearance == null)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the Plort for a Slime
        /// </summary>
        /// <param name="slime">ID of the slime</param>
        public static Identifiable.Id SlimeToPlort(Identifiable.Id slime)
        {
            SlimeDefinition def = GameContext.Instance.SlimeDefinitions.GetSlimeByIdentifiableId(slime);

            return(def.Diet?.EatMap == null ?
                   Identifiable.Id.NONE :
                   (from entry in def.Diet.EatMap where Identifiable.IsPlort(entry.producesId) select entry.producesId).FirstOrDefault());
        }
Exemplo n.º 5
0
 internal static bool Prefix(SlimeDefinition definition, SlimeAppearance newChosenAppearance)
 {
     if (definition == null || newChosenAppearance == null)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Template to create new slimes
        /// </summary>
        /// <param name="name">The name of the object (prefixes are recommend, but not needed)</param>
        /// <param name="definition">The definition for this slime</param>
        public SlimeTemplate(string name, SlimeDefinition definition) : base(name)
        {
            ID = definition.IdentifiableId;
            this.definition = definition;

            if (definition.Name.StartsWith("roamGordo."))
            {
                isGordo = true;
            }
        }
    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);
    }
Exemplo n.º 8
0
        /// <summary>
        /// Register a secret style in a <see cref="SlimeDefinition"/>
        /// </summary>
        /// <param name="definition">Slime definition to register the secret style for</param>
        /// <param name="exoticAppearance">Secret style to register</param>
        public static void RegisterSecretStyle(SlimeDefinition definition, SlimeAppearance exoticAppearance)
        {
            SecretStyle ss  = new SecretStyle(definition, exoticAppearance);
            SRMod       mod = SRMod.GetCurrentMod();

            if (secretStyles.ContainsKey(ss))
            {
                throw new Exception($"{definition.IdentifiableId} already has a secret style registered by {secretStyles[ss].ModInfo.Id}");
            }
            secretStyles[ss] = mod;
        }
Exemplo n.º 9
0
    /// <summary>
    /// Gets a list of combined dynamic appearances
    /// </summary>
    /// <param name="our">Our slime definition</param>
    /// <param name="other">The dynamic appearances to combine with</param>
    public static List <SlimeAppearance> GetCombinedAppearancesDynamic(this SlimeDefinition our, List <SlimeAppearance> other)
    {
        List <SlimeAppearance> apps = new List <SlimeAppearance>();

        for (int i = 0; i < our.AppearancesDynamic.Count; i++)
        {
            if (other.Count >= i)
            {
                break;
            }

            apps.Add(SlimeAppearance.CombineAppearances(our.AppearancesDynamic[i], other[i]));
        }

        return(apps);
    }
Exemplo n.º 10
0
    /// <summary>
    /// Gets a list of combined default appearances
    /// </summary>
    /// <param name="our">Our slime definition</param>
    /// <param name="other">The default appearances to combine with</param>
    public static SlimeAppearance[] GetCombinedAppearancesDefault(this SlimeDefinition our, SlimeAppearance[] other)
    {
        List <SlimeAppearance> apps = new List <SlimeAppearance>();

        for (int i = 0; i < our.AppearancesDefault.Length; i++)
        {
            if (other.Length >= i)
            {
                break;
            }

            apps.Add(SlimeAppearance.CombineAppearances(our.AppearancesDefault[i], other[i]));
        }

        return(apps.ToArray());
    }
Exemplo n.º 11
0
        /// <summary>
        /// Register a slime definition in the <see cref="SlimeDefinitions"/> database
        /// </summary>
        /// <param name="definition">Slime definition to register</param>
        public static void RegisterSlimeDefinition(SlimeDefinition definition, bool refreshEatMaps = true)
        {
            slimeDefinitions[definition] = SRMod.GetCurrentMod();
            SlimeDefinitions definitions;

            switch (SRModLoader.CurrentLoadingStep)
            {
            case SRModLoader.LoadingStep.PRELOAD:
                definitions = UnityEngine.Object.FindObjectOfType <GameContext>().SlimeDefinitions;
                break;

            default:
                definitions = GameContext.Instance.SlimeDefinitions;
                break;
            }
            if (definition.IsLargo && definition.BaseSlimes != null && definition.BaseSlimes.Length == 2 && definition.BaseSlimes[0].Diet.ProducePlorts() && definition.BaseSlimes[1].Diet.ProducePlorts())
            {
                SlimeDefinitions.PlortPair pair = new SlimeDefinitions.PlortPair(definition.BaseSlimes[0].Diet.Produces[0], definition.BaseSlimes[1].Diet.Produces[0]);
                definitions.largoDefinitionByBasePlorts = definitions.largoDefinitionByBasePlorts.Where(x => !x.Key.Equals(pair)).ToDictionary(x => x.Key, y => y.Value);
                definitions.largoDefinitionByBasePlorts.Add(pair, definition);
            }
            if (definition.IsLargo && definition.BaseSlimes != null && definition.BaseSlimes.Length == 2)
            {
                SlimeDefinitions.SlimeDefinitionPair pair = new SlimeDefinitions.SlimeDefinitionPair(definition.BaseSlimes[0], definition.BaseSlimes[1]);
                definitions.largoDefinitionByBaseDefinitions = definitions.largoDefinitionByBaseDefinitions.Where(x => !x.Key.Equals(pair)).ToDictionary(x => x.Key, y => y.Value);
                definitions.largoDefinitionByBaseDefinitions.Add(pair, definition);
            }
            definitions.slimeDefinitionsByIdentifiable.Add(definition.IdentifiableId, definition);
            definitions.Slimes = definitions.Slimes.Where(x => x.IdentifiableId != definition.IdentifiableId).ToArray();
            definitions.Slimes = definitions.Slimes.AddToArray(definition);
            if (refreshEatMaps)
            {
                definition.Diet.RefreshEatMap(definitions, definition);
                if (definition.BaseSlimes != null)
                {
                    foreach (SlimeDefinition child in definition.BaseSlimes)
                    {
                        child.Diet.RefreshEatMap(definitions, child);
                    }
                }
            }
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Register a slime definition in the <see cref="SlimeDefinitions"/> database
        /// </summary>
        /// <param name="definition">Slime definition to register</param>
        public static void RegisterSlimeDefinition(SlimeDefinition definition)
        {
            slimeDefinitions[definition] = SRMod.GetCurrentMod();
            SlimeDefinitions definitions;

            switch (SRModLoader.CurrentLoadingStep)
            {
            case SRModLoader.LoadingStep.PRELOAD:
                definitions = UnityEngine.Object.FindObjectOfType <GameContext>().SlimeDefinitions;
                break;

            default:
                definitions = GameContext.Instance.SlimeDefinitions;
                break;
            }
            definitions.largoDefinitionByBasePlorts.Clear();
            definitions.largoDefinitionByBaseDefinitions.Clear();
            definitions.slimeDefinitionsByIdentifiable.Clear();
            definitions.Slimes = definitions.Slimes.Where(x => x.IdentifiableId != definition.IdentifiableId).ToArray();
            definitions.Slimes = definitions.Slimes.AddToArray(definition);
            definitions.OnEnable();
        }
Exemplo n.º 14
0
        /// <summary>Builds this Item</summary>
        protected override void Build()
        {
            //foreach (Identifiable.Id slime in Identifiable.SLIME_CLASS)
            //{
            // Make new Definition
            SlimeDefinition other  = SlimeUtils.GetDefinitionByID(Identifiable.Id.PINK_SLIME);
            SlimeDefinition newDef = Definition.CombineForLargo(other);

            // Translation
            DefTranslation.Add(newDef.IdentifiableId, Regex.Replace(Definition.Name, "(\\B[A-Z])", " $1") + " " + Regex.Replace(other.Name, "(\\B[A-Z])", " $1") + " Largo");

            //if (newDef == null)
            //	continue;

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Definition.Name + other.Name;
            Prefab.transform.localScale = Scale * newDef.PrefabScale;

            // PRIMARY SETUP
            // Load Components
            SlimeAppearanceApplicator app = Prefab.GetComponent <SlimeAppearanceApplicator>();
            SlimeVarietyModules       mod = Prefab.GetComponent <SlimeVarietyModules>();

            // Setup Components
            app.SlimeDefinition = newDef;
            mod.baseModule      = newDef.BaseModule;
            mod.slimeModules    = newDef.SlimeModules;

            mod.Assemble();

            // SECONDARY SETUP
            // Load Components
            SlimeEat    eat = Prefab.GetComponent <SlimeEat>();
            SlimeHealth hp  = Prefab.GetComponent <SlimeHealth>();

            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            // Setup Components
            eat.slimeDefinition    = newDef;
            eat.minDriveToEat      = MinDriveToEat;
            eat.drivePerEat        = DrivePerEat;
            eat.agitationPerEat    = AgitationPerEat;
            eat.agitationPerFavEat = AgitationPerFavEat;

            hp.maxHealth = Health;

            body.mass = Mass;
            vac.size  = Size;
            iden.id   = newDef.IdentifiableId;

            // TERTIARY SETUP
            // Load Components
            SlimeEmotions emot  = Prefab.GetComponent <SlimeEmotions>();
            SlimeEmotions emot2 = BaseItem.GetComponent <SlimeEmotions>();

            emot.initAgitation = emot2.initAgitation;
            emot.initFear      = emot2.initFear;
            emot.initHunger    = emot2.initHunger;

            // Add to Largo List
            Prefabs.Add(newDef.IdentifiableId, Prefab);
            //}
        }
Exemplo n.º 15
0
 public SecretStyle(SlimeDefinition definition, SlimeAppearance exoticAppearance)
 {
     SlimeDefinition  = definition;
     ExoticAppearance = exoticAppearance;
 }
Exemplo n.º 16
0
 public static GordoTemplate MakeStaticGordo(this LookupDirector director, string name, Identifiable.Id gordoID, SlimeDefinition definition, Material[] gordoMaterials)
 {
     return(new GordoTemplate(name, gordoID, definition, gordoMaterials).SetTranslation(definition.Name + " Gordo"));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Register a slime definition in the <see cref="SlimeDefinitions"/> database
 /// </summary>
 /// <param name="definition">Slime definition to register</param>
 public static void RegisterSlimeDefinition(SlimeDefinition definition)
 {
     RegisterSlimeDefinition(definition, true);
 }
Exemplo n.º 18
0
        // Called before GameContext.Start
        // Used for registering things that require a loaded gamecontext
        public override void Load()
        {
            SlimeDefinition mapleDefinition = PrefabUtils.DeepCopyObject(SRSingleton<GameContext>.Instance.SlimeDefinitions.GetSlimeByIdentifiableId(Identifiable.Id.PINK_SLIME)) as SlimeDefinition;
            mapleDefinition.AppearancesDefault = new SlimeAppearance[1];
            mapleDefinition.Diet.Produces = new Identifiable.Id[]
            {
                ModdedIds.MAPLE_PLORT
            };
            mapleDefinition.Diet.MajorFoodGroups = new SlimeEat.FoodGroup[]
            {
                SlimeEat.FoodGroup.FRUIT
            };
            mapleDefinition.Diet.AdditionalFoods = new Identifiable.Id[0];
            mapleDefinition.Diet.Favorites = new Identifiable.Id[]
            {
                Identifiable.Id.POGO_FRUIT
            };
            List<SlimeDiet.EatMapEntry> eatMap = mapleDefinition.Diet.EatMap;
            if (eatMap != null)
            {
                eatMap.Clear();
            }
            mapleDefinition.CanLargofy = false;
            mapleDefinition.FavoriteToys = new Identifiable.Id[0];
            mapleDefinition.Name = "Maple";
            mapleDefinition.IdentifiableId = ModdedIds.MAPLE_SLIME;
            SlimeDefinition pinkSlimeDefinition = SRSingleton<GameContext>.Instance.SlimeDefinitions.GetSlimeByIdentifiableId(Identifiable.Id.PINK_SLIME);
            GameObject mapleGameObject = PrefabUtils.CopyPrefab(SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.PINK_SLIME));
            mapleGameObject.name = "mapleSlime";
            mapleGameObject.GetComponent<PlayWithToys>().slimeDefinition = mapleDefinition;
            mapleGameObject.GetComponent<SlimeAppearanceApplicator>().SlimeDefinition = mapleDefinition;
            mapleGameObject.GetComponent<SlimeEat>().slimeDefinition = mapleDefinition;
            SlimeAppearance mapleAppearance = PrefabUtils.DeepCopyObject(pinkSlimeDefinition.AppearancesDefault[0]) as SlimeAppearance;
            foreach (SlimeAppearanceStructure slimeAppearanceStructure in mapleAppearance.Structures)
            {
                Material[] defaultMaterials = slimeAppearanceStructure.DefaultMaterials;
                bool flag = ((defaultMaterials != null) ? defaultMaterials.Length : 0) == 0;
                if (!flag)
                {
                    Material material = UnityEngine.Object.Instantiate<Material>(slimeAppearanceStructure.DefaultMaterials[0]);
                    material.SetColor(topColorNameId, new Color(87.0f / 255.0f, 32.0f / 255.0f, 0.0f / 255.0f)); // new Color(216.0f / 255.0f, 120.0f / 255.0f , 63.0f / 255.0f)
                    material.SetColor(middleColorNameId, new Color(164.0f / 255.0f, 75.0f / 255.0f, 23.0f / 255.0f)); // new Color(194.0f / 255.0f, 99.0f / 255.0f, 44.0f / 255.0f)
                    material.SetColor(bottomColorNameId, new Color(226.0f / 255.0f, 123.0f / 255.0f, 63.0f / 255.0f)); // new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f)
                    material.SetColor("_SpecColor", Color.red);
                    material.SetFloat("_Shininess", 5f);
                    material.SetFloat("_Gloss", 5f);
                    slimeAppearanceStructure.DefaultMaterials[0] = material;
                }
            }
            foreach(SlimeExpressionFace slimeExpressionFace in mapleAppearance.Face.ExpressionFaces)
            {
                bool flag2 = slimeExpressionFace.Mouth;
                if (flag2)
                { 
                    slimeExpressionFace.Mouth.SetColor("_MouthBot", new Color(145.0f / 255.0f, 17.0f / 255.0f, 17.0f / 255.0f));
                    slimeExpressionFace.Mouth.SetColor("_MouthMid", new Color(145.0f / 255.0f, 17.0f / 255.0f, 17.0f / 255.0f));
                    slimeExpressionFace.Mouth.SetColor("_MouthTop", new Color(145.0f / 255.0f, 17.0f / 255.0f, 17.0f / 255.0f));
                }

                bool flag3 = slimeExpressionFace.Eyes;
                if (flag3)
                {
                    slimeExpressionFace.Eyes.SetColor("_EyeBlue", Color.black);
                    slimeExpressionFace.Eyes.SetColor("_EyeGreen", Color.black);
                    slimeExpressionFace.Eyes.SetColor("_EyeRed", Color.black);
                    slimeExpressionFace.Eyes.SetColor("_GlowColor", Color.black);
                }
            }
            mapleAppearance.Face.OnEnable();
            mapleAppearance.ColorPalette = new SlimeAppearance.Palette
            {
                Bottom = new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f),
                Middle = new Color(194.0f / 255.0f, 99.0f / 255.0f, 44.0f / 255.0f),
                Top = new Color(216.0f / 255.0f, 120.0f / 255.0f, 63.0f / 255.0f),
                Ammo = new Color(194.0f / 255.0f, 99.0f / 255.0f, 44.0f / 255.0f)
            };
            Sprite mapleSlimeSprite = IMG2Sprite.LoadNewSprite("SDTestModNew.MapleSlime.png");
            mapleAppearance.Icon = mapleSlimeSprite;
            mapleDefinition.AppearancesDefault = new SlimeAppearance[]
            {
                mapleAppearance
            };
            mapleGameObject.GetComponent<Identifiable>().id = ModdedIds.MAPLE_SLIME;
            LookupRegistry.RegisterIdentifiablePrefab(mapleGameObject);
            SlimeRegistry.RegisterSlimeDefinition(mapleDefinition);
            Material maplePlortMaterial = SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.PINK_PLORT).GetComponentInChildren<MeshRenderer>().material;
            GameObject maplePlortObject = PrefabUtils.CopyPrefab(SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.PINK_PLORT));
            maplePlortObject.GetComponent<Identifiable>().id = ModdedIds.MAPLE_PLORT;
            maplePlortObject.name = "maplePlort";
            maplePlortMaterial = UnityEngine.Object.Instantiate<Material>(maplePlortMaterial);
            maplePlortMaterial.SetColor(topColorNameId, new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f));
            maplePlortMaterial.SetColor(middleColorNameId, new Color(87.0f / 255.0f, 32.0f / 255.0f, 0.0f / 255.0f));
            maplePlortMaterial.SetColor(bottomColorNameId, new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f));
            maplePlortObject.GetComponentInChildren<MeshRenderer>().material = maplePlortMaterial;
            LookupRegistry.RegisterIdentifiablePrefab(maplePlortObject);
            Sprite maplePlortSprite = IMG2Sprite.LoadNewSprite("SDTestModNew.MaplePlort.png");
            LookupRegistry.RegisterVacEntry(ModdedIds.MAPLE_PLORT, new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f), maplePlortSprite);
            AmmoRegistry.RegisterAmmoPrefab(PlayerState.AmmoMode.DEFAULT, maplePlortObject);
            AmmoRegistry.RegisterAmmoPrefab(PlayerState.AmmoMode.DEFAULT, mapleGameObject);
            PediaRegistry.RegisterIdEntry(ModdedIds.MAPLE_SLIMES, mapleSlimeSprite);
            PlortRegistry.AddEconomyEntry(ModdedIds.MAPLE_PLORT, 35f, 50f);
            DroneRegistry.RegisterBasicTarget(ModdedIds.MAPLE_PLORT);

            Mesh pogoMesh = PrefabUtils.CopyPrefab(SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.POGO_FRUIT)).GetComponent<Mesh>();
            MeshRenderer[] pogoMeshRenderers = PrefabUtils.CopyPrefab(SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.POGO_FRUIT)).GetComponentsInChildren<MeshRenderer>();
            IEnumerable<Material> pogoMaterials = new List<Material>();
            foreach(MeshRenderer renderer in pogoMeshRenderers)
            {
                foreach(Material material in renderer.materials)
                {
                    pogoMaterials = pogoMaterials.Append(material);
                }
            }
            SRML.Console.Console.Log("pogoMaterials.Count(): " + pogoMaterials.Count().ToString());
            SRML.Console.Console.Log("pogoMaterials.ToArray().Length: " + pogoMaterials.ToArray().Length.ToString());
            TestingUtils.DumpChildComponents(Identifiable.Id.POGO_FRUIT);
            FoodTemplate caramelAppleTemplate = new FoodTemplate("caramelApple", ModdedIds.CARAMEL_APPLE_FRUIT, ModdedIds.CARAMEL_APPLES, FoodTemplate.Type.FRUIT, pogoMesh, pogoMaterials.ToArray());
            caramelAppleTemplate = caramelAppleTemplate.SetTranslation("Caramel Apple");
            GameObject caramelAppleObject = caramelAppleTemplate.Create().ToPrefab();
            caramelAppleObject.GetComponent<Identifiable>().id = ModdedIds.CARAMEL_APPLE_FRUIT;
            caramelAppleObject.GetComponent<Vacuumable>().size = Vacuumable.Size.NORMAL;
            caramelAppleObject.name = "caramelApple";
            LookupRegistry.RegisterIdentifiablePrefab(caramelAppleObject);
            Sprite caramelAppleSprite = IMG2Sprite.LoadNewSprite("SDTestModNew.CaramelApple.png");
            LookupRegistry.RegisterVacEntry(ModdedIds.CARAMEL_APPLE_FRUIT, Color.green, caramelAppleSprite);
            AmmoRegistry.RegisterAmmoPrefab(PlayerState.AmmoMode.DEFAULT, caramelAppleObject);
            PediaRegistry.RegisterIdEntry(ModdedIds.CARAMEL_APPLES, caramelAppleSprite);
            DroneRegistry.RegisterBasicTarget(ModdedIds.CARAMEL_APPLE_FRUIT);
            TestingUtils.DumpChildComponents(ModdedIds.CARAMEL_APPLE_FRUIT);

            CrateTemplate testCrateTemplate = new CrateTemplate("testCrate", ModdedIds.TEST_CRATE_01);
            testCrateTemplate = testCrateTemplate.SetSpawnInfo(3, 5);
            List<BreakOnImpact.SpawnOption> testCrateSpawnOptions = new List<BreakOnImpact.SpawnOption>();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.MANGO_FRUIT, 1.5f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.POGO_FRUIT, 3.0f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.CARROT_VEGGIE, 3.0f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.OCAOCA_VEGGIE, 1.5f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.PEAR_FRUIT, 0.25f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.PARSNIP_VEGGIE, 0.25f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.GINGER_VEGGIE, 0.0001f)).ToList();
            testCrateTemplate.SetSpawnOptions(testCrateSpawnOptions);
            GameObject testCrateObject = testCrateTemplate.Create().ToPrefab();
            LookupRegistry.RegisterIdentifiablePrefab(testCrateObject);
        }
Exemplo n.º 19
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();
        }
Exemplo n.º 20
0
 /// <summary>
 /// Template to create new gordos
 /// </summary>
 /// <param name="name">The name of the object (prefixes are recommend, but not needed)</param>
 /// <param name="ID">The identifiable ID for this gordo</param>
 /// <param name="definition">The definition of the slime this gordo is based on</param>
 /// <param name="materials">The materials to use on the model of this gordo</param>
 public GordoTemplate(string name, Identifiable.Id ID, SlimeDefinition definition, Material[] materials) : base(name)
 {
     ID = definition.IdentifiableId;
     this.definition = definition;
     this.materials  = materials;
 }