コード例 #1
0
        public override bool OnTryIgniteBlock(EntityAgent byEntity, BlockPos pos, float secondsIgniting, ref EnumHandling handling)
        {
            BlockEntityBloomery beb = byEntity.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityBloomery;

            bool ok = (beb == null || beb.IsBurning || !beb.CanIgnite()) ? false : secondsIgniting < 2f;

            handling = EnumHandling.PreventDefault;

            return(ok);
        }
コード例 #2
0
        public override EnumIgniteState OnTryIgniteBlock(EntityAgent byEntity, BlockPos pos, float secondsIgniting)
        {
            BlockEntityBloomery beb = byEntity.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityBloomery;

            if (!beb.CanIgnite())
            {
                return(EnumIgniteState.NotIgnitablePreventDefault);
            }

            return(secondsIgniting > 4 ? EnumIgniteState.IgniteNow : EnumIgniteState.Ignitable);
        }
コード例 #3
0
        public override void OnLoaded(ICoreAPI api)
        {
            if (api.Side != EnumAppSide.Client)
            {
                return;
            }
            ICoreClientAPI capi = api as ICoreClientAPI;

            interactions = ObjectCacheUtil.GetOrCreate(api, "bloomeryBlockInteractions", () =>
            {
                List <ItemStack> heatableStacklist = new List <ItemStack>();
                List <ItemStack> fuelStacklist     = new List <ItemStack>();
                List <ItemStack> canIgniteStacks   = new List <ItemStack>();

                foreach (CollectibleObject obj in api.World.Collectibles)
                {
                    if (obj.CombustibleProps?.SmeltedStack != null && obj.CombustibleProps.MeltingPoint < 1500)
                    {
                        List <ItemStack> stacks = obj.GetHandBookStacks(capi);
                        if (stacks != null)
                        {
                            heatableStacklist.AddRange(stacks);
                        }
                    }
                    else
                    {
                        if (obj.CombustibleProps?.BurnTemperature >= 1200 && obj.CombustibleProps.BurnDuration > 30)
                        {
                            List <ItemStack> stacks = obj.GetHandBookStacks(capi);
                            if (stacks != null)
                            {
                                fuelStacklist.AddRange(stacks);
                            }
                        }
                    }

                    if (obj is Block && (obj as Block).HasBehavior <BlockBehaviorCanIgnite>())
                    {
                        List <ItemStack> stacks = obj.GetHandBookStacks(capi);
                        if (stacks != null)
                        {
                            canIgniteStacks.AddRange(stacks);
                        }
                    }
                }

                return(new WorldInteraction[] {
                    new WorldInteraction()
                    {
                        ActionLangCode = "blockhelp-bloomery-heatable",
                        HotKeyCode = null,
                        MouseButton = EnumMouseButton.Right,
                        Itemstacks = heatableStacklist.ToArray(),
                        GetMatchingStacks = getMatchingStacks
                    },
                    new WorldInteraction()
                    {
                        ActionLangCode = "blockhelp-bloomery-heatablex4",
                        HotKeyCode = "sneak",
                        MouseButton = EnumMouseButton.Right,
                        Itemstacks = heatableStacklist.ToArray(),
                        GetMatchingStacks = getMatchingStacks
                    },
                    new WorldInteraction()
                    {
                        ActionLangCode = "blockhelp-bloomery-fuel",
                        HotKeyCode = null,
                        MouseButton = EnumMouseButton.Right,
                        Itemstacks = fuelStacklist.ToArray(),
                        GetMatchingStacks = getMatchingStacks
                    },
                    new WorldInteraction()
                    {
                        ActionLangCode = "blockhelp-bloomery-ignite",
                        HotKeyCode = "sneak",
                        MouseButton = EnumMouseButton.Right,
                        Itemstacks = canIgniteStacks.ToArray(),
                        GetMatchingStacks = (wi, bs, es) => {
                            BlockEntityBloomery beb = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityBloomery;
                            if (beb != null && beb.CanIgnite() == true && !beb.IsBurning && api.World.BlockAccessor.GetBlock(bs.Position.UpCopy()).Code.Path.Contains("bloomerychimney"))
                            {
                                return wi.Itemstacks;
                            }
                            return null;
                        }
                    }
                });
            });
        }