Exemplo n.º 1
0
        private static void ExtractVanillaStaticPrefabs(SweetBridgeDog bridge)
        {
            AnankeContext.Current.StaticPrefabRegistry.Reset();

            IEnumerable <Tuple <string, int> > listOfVanillaPrefabs            = bridge.CollectBuiltinEnummedStaticPrefabs();
            IEnumerable <Tuple <Tuple <string, int>, Type> > listOfProbedItems =
                bridge.ProbeTypesOfCreatedStaticPrefabs(listOfVanillaPrefabs);

            foreach (var probe in listOfProbedItems)
            {
                var activator = probe.Item2 == null
                    ? new StaticPrefabActivator(() => null)
                    : new StaticPrefabActivator(() => (StaticPrefab)Activator.CreateInstance(probe.Item2));

                StaticPrefabDefinition definition = new StaticPrefabDefinition(probe.Item1.Item2, probe.Item1.Item1,
                                                                               activator);
                AnankeContext.Current.StaticPrefabRegistry.Add(definition);
            }
        }
Exemplo n.º 2
0
        public void Init(AnankeContext context, IModContextV1 mod)
        {
            PathHelper path = new PathHelper(mod as ModContext);

            var spriteGoldenChicken = AnankeContext.Current.DumbGraphicsRegistry.DefineResource(
                path.GetResource(@"assets\goldenchicken.png"),
                new Rectangle(17, 10, 32, 44));

            var spriteGoldenChickenMagnument = AnankeContext.Current.DumbGraphicsRegistry.DefineResource(
                path.GetResource(@"assets\goldenchicken_magnument.png"),
                new Rectangle(0, 0, 64, 64));

            var itemDefinitionGoldenChicken = new ItemDefinition(
                50001,
                "examplemod_goldenchicken",
                new ItemActivator(() => new GoldenChickenItem(50001, spriteGoldenChicken)));

            context.ItemsRegistry.Add(itemDefinitionGoldenChicken);

            //TODO: MY GOD!!! IT IS SO UGLY!
            long sptMagnumentId = 2000;
            var  staticPrefabDefintionMagnument = new StaticPrefabDefinition(
                sptMagnumentId,
                "golden_chincken_magnument",
                new StaticPrefabActivator(
                    () => new GoldenChickenMagnument(sptMagnumentId,
                                                     spriteGoldenChickenMagnument)
                    )
                );

            context.StaticPrefabRegistry.Add(staticPrefabDefintionMagnument);

            //Living entites
            var myAliveGoldenChicken = new LivingEntityDefinition(
                10001,
                "GCHICK", new LivingEntityActivator(
                    () => new AliveGoldenChicken(10001)
                    )
                );

            context.LivingEntityRegistry.Add(myAliveGoldenChicken);

            context.Compatibility.V1Compat.AddActionForRecipeLoadingPhase(
                GetType(), ctx =>
            {
                var category = ctx.RecipeRegistry.GetRecipeCategory("Swag");

                ctx.RecipeRegistry.CreateRecipe(
                    "Golden Chicken Statue",
                    category, RecipeRegistry.SoLCraftingCategory.FURNITURE,
                    new[]
                {
                    new RequiredRecipeMaterial(
                        InventoryItemType.GOLD_INGOT,
                        1),
                },
                    new [] { new RecipeRegistry.ItemRecipeOutcome(itemDefinitionGoldenChicken.Id, 1) }
                    );

                ctx.RecipeRegistry.CreateRecipe(
                    "Golden Chicken Magnument",
                    category, RecipeRegistry.SoLCraftingCategory.PROJECTS,
                    new[]
                {
                    new RequiredRecipeMaterial(
                        InventoryItemType.GOLD_INGOT,
                        5),
                },
                    new [] { new RecipeRegistry.StaticPrefabRecipeOutcome(staticPrefabDefintionMagnument.Id) }
                    );

                //Vanilla recipe deletion
                var fancyRecipe = ctx.RecipeRegistry.Discover(r => r.Name == "Wooden Chair");
                foreach (var actionableRecipe in fancyRecipe)
                {
                    actionableRecipe.Remove();
                }
            }
                );
        }