Esempio n. 1
0
        public override bool TryStopHandAction(bool forceStop, EnumItemUseCancelReason cancelReason = EnumItemUseCancelReason.ReleasedMouse)
        {
            if (controls.HandUse == EnumHandInteract.None || RightHandItemSlot?.Itemstack == null)
            {
                return(true);
            }

            IPlayer player        = World.PlayerByUid(PlayerUID);
            float   secondsPassed = (World.ElapsedMilliseconds - controls.UsingBeginMS) / 1000f;

            if (forceStop)
            {
                controls.HandUse = EnumHandInteract.None;
            }
            else
            {
                controls.HandUse = RightHandItemSlot.Itemstack.Collectible.OnHeldUseCancel(secondsPassed, RightHandItemSlot, this, player.CurrentBlockSelection, player.CurrentEntitySelection, cancelReason);
            }


            if (controls.HandUse == EnumHandInteract.None)
            {
                RightHandItemSlot.Itemstack.Collectible.OnHeldUseStop(secondsPassed, RightHandItemSlot, this, player.CurrentBlockSelection, player.CurrentEntitySelection, controls.HandUse);
            }

            return(controls.HandUse == EnumHandInteract.None);
        }
Esempio n. 2
0
        /// <summary>
        /// Attempts to stop the hand  action.
        /// </summary>
        /// <param name="isCancel">Whether or not the action is cancelled or stopped.</param>
        /// <param name="cancelReason">The reason for stopping the action.</param>
        /// <returns>Whether the stop was cancelled or not.</returns>
        public virtual bool TryStopHandAction(bool isCancel, EnumItemUseCancelReason cancelReason = EnumItemUseCancelReason.ReleasedMouse)
        {
            if (controls.HandUse == EnumHandInteract.None || RightHandItemSlot?.Itemstack == null)
            {
                return(true);
            }

            float secondsPassed = (World.ElapsedMilliseconds - controls.UsingBeginMS) / 1000f;

            if (isCancel)
            {
                controls.HandUse = RightHandItemSlot.Itemstack.Collectible.OnHeldUseCancel(secondsPassed, RightHandItemSlot, this, null, null, cancelReason);
            }
            else
            {
                controls.HandUse = EnumHandInteract.None;
                RightHandItemSlot.Itemstack.Collectible.OnHeldUseStop(secondsPassed, RightHandItemSlot, this, null, null, controls.HandUse);
            }

            return(controls.HandUse == EnumHandInteract.None);
        }
Esempio n. 3
0
        public override bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
        {
            if (byEntity.World.Side == EnumAppSide.Client)
            {
                ILoadedSound sound = ObjectCacheUtil.TryGet <ILoadedSound>(api, "temporalGearSound");
                sound?.Stop();
                sound?.Dispose();
            }

            return(true);
        }
Esempio n. 4
0
 public override bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
 {
     api.Event.UnregisterCallback(ObjectCacheUtil.TryGet <long>(api, "firestartersound"));
     return(true);
 }
Esempio n. 5
0
        public override bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
        {
            //byEntity.World.Logger.Debug("{0} knife interact cancelled, seconds used {1}", byEntity.World.Side, secondsUsed);

            return(base.OnHeldInteractCancel(secondsUsed, slot, byEntity, blockSel, entitySel, cancelReason));
        }
Esempio n. 6
0
 public override bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
 {
     return(false);
 }
        public override bool OnBlockInteractCancel(float secondsUsed, IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, EnumItemUseCancelReason cancelReason)
        {
            var be = world.BlockAccessor.GetBlockEntity(blockSel.Position.DownCopy()) as BlockEntityFruitPress;

            if (be != null)
            {
                return(be.OnBlockInteractCancel(secondsUsed, byPlayer));
            }

            return(base.OnBlockInteractCancel(secondsUsed, world, byPlayer, blockSel, cancelReason));
        }
Esempio n. 8
0
 public override bool OnHeldAttackCancel(float secondsPassed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
 {
     return(false);
 }
 public override bool OnBlockInteractCancel(float secondsUsed, IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, EnumItemUseCancelReason cancelReason)
 {
     return(base.OnBlockInteractCancel(secondsUsed, world, byPlayer, blockSel, cancelReason));
 }
        public override bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent interactingEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
        {
            // api.Logger.Error("interactCancel: " + cancelReason);
            interactingEntity.Attributes.SetInt("aiming", 0);
            if (slot.Itemstack.Attributes.GetBool("loaded", false))
            {
                interactingEntity.AnimManager.StopAnimation(Attributes["loadedAimAnimation"].AsString("bowaim"));
            }
            else
            {
                interactingEntity.AnimManager.StopAnimation(Attributes["aimAnimation"].AsString("bowaim"));
            }

            if (interactingEntity.World is IClientWorldAccessor)
            {
                slot.Itemstack.TempAttributes.RemoveAttribute("renderVariant");
            }

            slot.Itemstack.Attributes.SetInt("renderVariant", 0);
            (interactingEntity as EntityPlayer)?.Player?.InventoryManager.BroadcastHotbarSlot();

            if (cancelReason != EnumItemUseCancelReason.ReleasedMouse)
            {
                interactingEntity.Attributes.SetInt("aimingCancel", 1);
            }

            return(true);
        }
Esempio n. 11
0
        public override bool OnHeldInteractCancel(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
        {
            if (byEntity.World.Side == EnumAppSide.Client)
            {
                ILoadedSound sound = byEntity.World.Api.ObjectCache["temporalGearSound"] as ILoadedSound;
                sound?.Stop();
                sound?.Dispose();
                // Console.WriteLine("sound stop");
            }

            return(true);
        }
Esempio n. 12
0
        public override bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
        {
            byEntity.Attributes.SetInt("aiming", 0);
            byEntity.AnimManager.StopAnimation("slingaimbalearic");

            if (byEntity.World is IClientWorldAccessor)
            {
                slot.Itemstack.TempAttributes.RemoveAttribute("renderVariant");
            }

            slot.Itemstack.Attributes.SetInt("renderVariant", 0);
            (byEntity as EntityPlayer)?.Player?.InventoryManager.BroadcastHotbarSlot();

            if (cancelReason != EnumItemUseCancelReason.ReleasedMouse)
            {
                byEntity.Attributes.SetInt("aimingCancel", 1);
            }

            return(true);
        }
Esempio n. 13
0
        public override bool OnBlockInteractCancel(float secondsUsed, IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, EnumItemUseCancelReason cancelReason)
        {
            var blockSelOffsetInved = blockSel.Clone();

            blockSelOffsetInved.Position.Add(OffsetInv);
            var block = world.BlockAccessor.GetBlock(blockSelOffsetInved.Position);

            if (block is IMultiBlockModular mbMono)
            {
                return(mbMono.MBOnBlockInteractCancel(secondsUsed, world, byPlayer, blockSel, cancelReason, OffsetInv));
            }

            return(block.OnBlockInteractCancel(secondsUsed, world, byPlayer, blockSelOffsetInved, cancelReason));
        }
Esempio n. 14
0
        public override bool OnHeldInteractCancel(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
        {
            byEntity.Attributes.SetInt("aiming", 0);
            byEntity.StopAnimation("bowaim");

            if (byEntity.World is IClientWorldAccessor)
            {
                slot.Itemstack.TempAttributes.SetInt("renderVariant", 0);
            }

            if (cancelReason != EnumItemUseCancelReason.ReleasedMouse)
            {
                byEntity.Attributes.SetInt("aimingCancel", 1);
            }

            return(true);
        }
Esempio n. 15
0
 /// <summary>
 /// When the player has canceled a custom attack action. Return false to deny action cancellation.
 /// </summary>
 /// <param name="secondsPassed"></param>
 /// <param name="slot"></param>
 /// <param name="byEntity"></param>
 /// <param name="blockSelection"></param>
 /// <param name="entitySel"></param>
 /// <param name="cancelReason"></param>
 /// <param name="handling"></param>
 /// <returns></returns>
 public virtual bool OnHeldAttackCancel(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel, EnumItemUseCancelReason cancelReason, ref EnumHandHandling handling)
 {
     handling = EnumHandHandling.NotHandled;
     return(false);
 }
        public override bool OnBlockInteractCancel(float secondsUsed, IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, EnumItemUseCancelReason cancelReason)
        {
            BEMortarAndPestle beQuern = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BEMortarAndPestle;

            if (beQuern != null)
            {
                beQuern.SetPlayerGrinding(byPlayer, false);
            }


            return(true);
        }
Esempio n. 17
0
 public override bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
 {
     if (api.Side == EnumAppSide.Client)
     {
         sound?.Stop();
         sound = null;
     }
     return(true);
 }
Esempio n. 18
0
        public override bool OnHeldInteractCancel(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
        {
            byEntity.Attributes.SetInt("aiming", 0);
            byEntity.StopAnimation("aim");

            if (cancelReason != EnumItemUseCancelReason.ReleasedMouse)
            {
                byEntity.Attributes.SetInt("aimingCancel", 1);
            }

            return(true);
        }
Esempio n. 19
0
 public override bool OnHeldInteractCancel(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
 {
     return(base.OnHeldInteractCancel(secondsUsed, slot, byEntity, blockSel, entitySel, cancelReason));
 }