コード例 #1
0
        /// <summary>Registers the item into it's registry</summary>
        public override IdentifiableItem Register()
        {
            Build();

            foreach (Identifiable.Id id in Prefabs.Keys)
            {
                IdentifiableRegistry.CategorizeId(id);

                if (GameContext.Instance.MessageDirector.Get("actor", "l." + id.ToString().ToLower()) == null)
                {
                    LanguageController.AddActorTranslation("l." + id.ToString().ToLower(), DefTranslation[id]);
                }

                LookupRegistry.RegisterIdentifiablePrefab(Prefabs[id]);

                VacEntry = VacItemDefinition.CreateVacItemDefinition(id, Color, Icon ? Icon : SRObjects.MissingIcon);
                LookupRegistry.RegisterVacEntry(VacEntry);
                VacEntries.Add(id, VacEntry);

                if (IsVacuumableOverride || Size == Vacuumable.Size.NORMAL)
                {
                    AmmoRegistry.RegisterPlayerAmmo(PlayerState.AmmoMode.DEFAULT, id);
                }

                if (IsRefineryResource)
                {
                    AmmoRegistry.RegisterRefineryResource(id);
                }

                AmmoRegistry.RegisterSiloAmmo(ValidSiloAmmo, id);
            }

            VacEntry = null;
            return(this);
        }
コード例 #2
0
        public void PreLoad()
        {
            HarmonyPatcher.GetInstance().PatchAll(Assembly.GetExecutingAssembly());

            SRML.Console.Console.RegisterCommand(new SetColorsCommand());
            TranslationPatcher.AddTranslationKey("pedia", RAVEBALL_KEY, "Rave Ball");
            TranslationPatcher.AddTranslationKey("pedia", RAVEBALL_UI_KEY, "Rave Ball");
            TranslationPatcher.AddTranslationKey("pedia", RAVEBALL_DESC_KEY,
                                                 "This ball may look plain, but it makes slimes want to party!");
            //IdentifiableRegistry.CreateIdentifiableId(RAVE_BALL_ID, "RAVE_BALL_TOY");
            var bundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly()
                                                    .GetManifestResourceStream(typeof(Main), "colorfulslimes"));
            var g = bundle.LoadAsset <GameObject>("raveball");

            g.AddComponent <RegionMember>();
            g.AddComponent <Identifiable>().id = CustomIds.RAVE_BALL_TOY;
            g.layer = LayerMask.NameToLayer("Actor");
            g.AddComponent <Vacuumable>().size = Vacuumable.Size.LARGE;
            g.AddComponent <Raveball>();
            g.transform.GetChild(0).gameObject.AddComponent <VacDelaunchTrigger>();

            LookupRegistry.RegisterIdentifiablePrefab(g);

            SaveRegistry.RegisterDataParticipant <SlimePainter>();
        }
コード例 #3
0
    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);
    }
コード例 #4
0
ファイル: SlimeTemplate.cs プロジェクト: veesusmikelheir/SRML
        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);
        }
コード例 #5
0
        /// <summary>Registers the item into it's registry</summary>
        public override IdentifiableItem Register()
        {
            Build();

            LookupRegistry.RegisterIdentifiablePrefab(Prefab);

            VacEntry = VacItemDefinition.CreateVacItemDefinition(ID, Color, Icon ? Icon : SRObjects.MissingIcon);
            LookupRegistry.RegisterVacEntry(VacEntry);

            if (IsVacuumableOverride || Size == Vacuumable.Size.NORMAL)
            {
                AmmoRegistry.RegisterPlayerAmmo(PlayerState.AmmoMode.DEFAULT, ID);
            }

            if (IsRefineryResource)
            {
                AmmoRegistry.RegisterRefineryResource(ID);
            }

            AmmoRegistry.RegisterSiloAmmo(ValidSiloAmmo, ID);

            return(this);
        }
コード例 #6
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);
        }