public override void OnEntityDeath(DamageSource damageSourceForDeath)
        {
            if (entity.World.Side == EnumAppSide.Server)
            {
                mouthInv.DropAll(entity.ServerPos.XYZ);
            }

            base.OnEntityDeath(damageSourceForDeath);
        }
Пример #2
0
        public override void OnBlockBroken(IPlayer byPlayer = null)
        {
            if (burning)
            {
                Vec3d dpos = Pos.ToVec3d().Add(0.5, 0.5, 0.5);
                bloomeryInv.DropSlots(dpos, new int[] { 0, 2 });


                breakSparks.MinPos = Pos.ToVec3d().AddCopy(dpos.X - 4 / 16f, dpos.Y - 4 / 16f, dpos.Z - 4 / 16f);
                Api.World.SpawnParticles(breakSparks, null);
            }
            else
            {
                bloomeryInv.DropAll(Pos.ToVec3d().Add(0.5, 0.5, 0.5));
            }
        }
        public override void OnInteract(EntityAgent byEntity, ItemSlot itemslot, Vec3d hitPosition, EnumInteractMode mode, ref EnumHandling handled)
        {
            base.OnInteract(byEntity, itemslot, hitPosition, mode, ref handled);

            IPlayer byPlayer = byEntity.World.PlayerByUid((byEntity as EntityPlayer).PlayerUID);

            if (owner != null && owner != byPlayer)
            {
                return;
            }

            if (mode == EnumInteractMode.Interact)
            {
                if (byEntity.Controls.Sneak && byEntity.Controls.Sprint && !invLocked)
                {
                    workInv[0].TryFlipWith(itemslot);
                    return;
                }
                if (itemslot.Itemstack?.Collectible is ItemHammer)
                {
                    if (entity.GetBehavior <EntityBehaviorHealth>()?.Health < entity.GetBehavior <EntityBehaviorHealth>()?.MaxHealth)
                    {
                        itemslot.Itemstack.Collectible.DamageItem(entity.World, byEntity, itemslot, 5);
                        entity.World.PlaySoundAt(new AssetLocation("game:sounds/effect/anvilhit3.ogg"), entity, byPlayer);
                        entity.ReceiveDamage(new DamageSource()
                        {
                            Type = EnumDamageType.Heal
                        }, 1);
                        return;
                    }
                }
                if (byEntity.Controls.Sprint && !restricted && itemslot?.Itemstack?.Collectible is ItemProgCard)
                {
                    ItemStack stack = itemslot.Itemstack.Attributes.GetItemstack("workStack");
                    if (stack == null)
                    {
                        return;
                    }
                    stack.ResolveBlockOrItem(entity.World);

                    if (stack != null)
                    {
                        workInv.DropAll(entity.ServerPos.XYZ);
                        workStack = stack;
                        maintree.SetItemstack("workStack", workStack);
                        (byPlayer as IServerPlayer)?.SendMessage(GlobalConstants.InfoLogChatGroup, Lang.Get("temporalhack:work-itemprogram"), EnumChatType.Notification);
                    }

                    return;
                }
                else if (byEntity.Controls.Sprint && itemslot.Empty && byPlayer != null && workArea != null)
                {
                    BlockPos min = workArea.Start.AsBlockPos;
                    BlockPos max = workArea.End.AsBlockPos;
                    max.Y += 1;
                    List <BlockPos> blocks = new List <BlockPos>()
                    {
                        min, max
                    };
                    List <int> colors = new List <int>()
                    {
                        ColorUtil.ColorFromRgba(215, 94, 94, 64), ColorUtil.ColorFromRgba(215, 94, 94, 64)
                    };

                    entity.Api.World.HighlightBlocks(byPlayer, 56, blocks, colors, EnumHighlightBlocksMode.Absolute, EnumHighlightShape.Cube);
                    entity.Api.World.RegisterCallback((dt) => entity.Api.World.HighlightBlocks(byPlayer, 56, new List <BlockPos>(), new List <int>()), 3000);
                }

                if (byEntity.Controls.Sneak && itemslot?.Itemstack?.Collectible is ItemProgCard)
                {
                    ITreeAttribute area   = itemslot.Itemstack.Attributes.GetTreeAttribute("workArea");
                    ITreeAttribute box    = null;
                    ITreeAttribute barrel = null;

                    if (!nochest)
                    {
                        box = itemslot.Itemstack.Attributes.GetTreeAttribute("workChest");
                    }
                    if (!nobarrel)
                    {
                        barrel = itemslot.Itemstack.Attributes.GetTreeAttribute("workBarrel");
                    }

                    StopAll();

                    if (area != null)
                    {
                        maintree["workArea"] = area.Clone();
                        workArea             = cuboiddFromTree(area);
                    }

                    if (box != null)
                    {
                        maintree["workChest"] = box.Clone();
                        workChest             = new BlockPos(box.GetInt("x"), box.GetInt("y"), box.GetInt("z"));
                    }

                    if (barrel != null)
                    {
                        maintree["workBarrel"] = barrel.Clone();
                        workBarrel             = new BlockPos(barrel.GetInt("x"), barrel.GetInt("y"), barrel.GetInt("z"));
                    }

                    if (area != null || box != null || barrel != null)
                    {
                        (byPlayer as IServerPlayer)?.SendMessage(GlobalConstants.InfoLogChatGroup, Lang.Get("temporalhack:work-program"), EnumChatType.Notification);
                    }
                }
                else if (byEntity.Controls.Sneak && itemslot.Empty)
                {
                    AssetLocation item = new AssetLocation(entity.Code.Domain, "deploybot-" + entity.Code.Path);
                    if (item != null)
                    {
                        EntityBehaviorHealth bh    = entity.GetBehavior <EntityBehaviorHealth>();
                        ItemStack            stack = new ItemStack(entity.World.GetItem(item));

                        stack.Attributes.SetInt("workEnergy", energy);
                        if (bh != null)
                        {
                            stack.Attributes.SetFloat("workHealth", bh.MaxHealth - bh.Health);
                        }

                        byEntity.World.SpawnItemEntity(stack, entity.SidedPos.XYZ);


                        workInv.DropAll(entity.ServerPos.XYZ);
                        entity.Die(EnumDespawnReason.Removed);
                    }
                }
                else if (byEntity.Controls.Sneak && itemslot?.Itemstack?.Collectible?.CombustibleProps?.BurnDuration != null)
                {
                    if (itemslot.Itemstack.Collectible.CombustibleProps.BurnTemperature >= 200)
                    {
                        AddEnergy((itemslot.Itemstack.Collectible.CombustibleProps.BurnTemperature / 100) * (int)itemslot.Itemstack.Collectible.CombustibleProps.BurnDuration);
                        itemslot.TakeOut(1);
                        entity.World.PlaySoundAt(new AssetLocation("game:sounds/effect/extinguish2.ogg"), entity, byPlayer);
                    }
                }
            }
            else
            {
                if (byEntity.Controls.Sneak)
                {
                    StopAll();
                    workStack = null;
                    workInv.DropAll(entity.ServerPos.XYZ);
                    RemoveArea();
                    RemoveBarrel();
                    RemoveChest();
                    (byPlayer as IServerPlayer)?.SendMessage(GlobalConstants.InfoLogChatGroup, Lang.Get("temporalhack:work-memoryloss"), EnumChatType.Notification);
                }
            }
        }
Пример #4
0
 public override void OnBlockBroken()
 {
     base.OnBlockBroken();
     _inv.DropAll(Pos.ToVec3d().Add(0.5, 0.5, 0.5));
 }