Ejemplo n.º 1
0
        public override bool OnTryIgniteBlock(EntityAgent byEntity, BlockPos pos, float secondsIgniting, ref EnumHandling handling)
        {
            BlockEntityBomb bebomb = byEntity.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityBomb;

            handling = EnumHandling.PreventDefault;

            return((bebomb == null || bebomb.IsLit) ? false : secondsIgniting < 0.75f);
        }
Ejemplo n.º 2
0
        public override EnumIgniteState OnTryIgniteBlock(EntityAgent byEntity, BlockPos pos, float secondsIgniting)
        {
            BlockEntityBomb bebomb = byEntity.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityBomb;

            if (bebomb == null || bebomb.IsLit)
            {
                return(EnumIgniteState.NotIgnitablePreventDefault);
            }

            if (secondsIgniting > 0.75f)
            {
                return(EnumIgniteState.IgniteNow);
            }

            return(EnumIgniteState.Ignitable);
        }
Ejemplo n.º 3
0
        public override void OnLoaded(ICoreAPI api)
        {
            base.OnLoaded(api);

            if (api.Side != EnumAppSide.Client)
            {
                return;
            }
            ICoreClientAPI capi = api as ICoreClientAPI;

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

                foreach (CollectibleObject obj in api.World.Collectibles)
                {
                    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()
                    {
                        MouseButton = EnumMouseButton.Right,
                        ActionLangCode = "blockhelp-bomb-ignite",
                        Itemstacks = canIgniteStacks.ToArray(),
                        GetMatchingStacks = (wi, bs, es) => {
                            BlockEntityBomb bebomb = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityBomb;
                            return bebomb == null || bebomb.IsLit ? null : wi.Itemstacks;
                        }
                    }
                });
            });
        }
Ejemplo n.º 4
0
        public override void OnTryIgniteBlockOver(EntityAgent byEntity, BlockPos pos, float secondsIgniting, ref EnumHandling handling)
        {
            if (secondsIgniting < 0.7f)
            {
                return;
            }

            handling = EnumHandling.PreventDefault;

            IPlayer byPlayer = null;

            if (byEntity is EntityPlayer)
            {
                byPlayer = byEntity.World.PlayerByUid(((EntityPlayer)byEntity).PlayerUID);
            }
            if (byPlayer == null)
            {
                return;
            }

            BlockEntityBomb bebomb = byPlayer.Entity.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityBomb;

            bebomb?.OnIgnite(byPlayer);
        }
Ejemplo n.º 5
0
        public override void OnBlockExploded(IWorldAccessor world, BlockPos pos, BlockPos explosionCenter, EnumBlastType blastType)
        {
            BlockEntityBomb bebomb = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityBomb;

            bebomb?.OnBlockExploded(pos);
        }