Exemple #1
0
        /// <summary>
        /// Internal implementation of creating a path from an entity to a point
        /// </summary>
        private PathEntity CreateEntityPathTo(Entity par1Entity, double par2, double par4, double par6, float par8)
        {
            Path.ClearPath();
            PointMap.ClearMap();
            bool flag = IsPathingInWater;
            int  i    = MathHelper2.Floor_double(par1Entity.BoundingBox.MinY + 0.5D);

            if (CanEntityDrown && par1Entity.IsInWater())
            {
                i = (int)par1Entity.BoundingBox.MinY;

                for (int j = WorldMap.GetBlockId(MathHelper2.Floor_double(par1Entity.PosX), i, MathHelper2.Floor_double(par1Entity.PosZ)); j == Block.WaterMoving.BlockID || j == Block.WaterStill.BlockID; j = WorldMap.GetBlockId(MathHelper2.Floor_double(par1Entity.PosX), i, MathHelper2.Floor_double(par1Entity.PosZ)))
                {
                    i++;
                }

                flag             = IsPathingInWater;
                IsPathingInWater = false;
            }
            else
            {
                i = MathHelper2.Floor_double(par1Entity.BoundingBox.MinY + 0.5D);
            }

            PathPoint  pathpoint  = OpenPoint(MathHelper2.Floor_double(par1Entity.BoundingBox.MinX), i, MathHelper2.Floor_double(par1Entity.BoundingBox.MinZ));
            PathPoint  pathpoint1 = OpenPoint(MathHelper2.Floor_double(par2 - (double)(par1Entity.Width / 2.0F)), MathHelper2.Floor_double(par4), MathHelper2.Floor_double(par6 - (double)(par1Entity.Width / 2.0F)));
            PathPoint  pathpoint2 = new PathPoint(MathHelper2.Floor_float(par1Entity.Width + 1.0F), MathHelper2.Floor_float(par1Entity.Height + 1.0F), MathHelper2.Floor_float(par1Entity.Width + 1.0F));
            PathEntity pathentity = AddToPath(par1Entity, pathpoint, pathpoint1, pathpoint2, par8);

            IsPathingInWater = flag;
            return(pathentity);
        }
Exemple #2
0
        protected virtual float GetWingRotation(EntityChicken par1EntityChicken, float par2)
        {
            float f  = par1EntityChicken.Field_756_e + (par1EntityChicken.Field_752_b - par1EntityChicken.Field_756_e) * par2;
            float f1 = par1EntityChicken.Field_757_d + (par1EntityChicken.DestPos - par1EntityChicken.Field_757_d) * par2;

            return((MathHelper2.Sin(f) + 1.0F) * f1);
        }
        /// <summary>
        /// Returns whether the EntityAIBase should begin execution.
        /// </summary>
        public override bool ShouldExecute()
        {
            if (EntityObj.WorldObj.IsDaytime() && !EntityObj.WorldObj.IsRaining() || EntityObj.WorldObj.WorldProvider.HasNoSky)
            {
                return(false);
            }

            if (EntityObj.GetRNG().Next(50) != 0)
            {
                return(false);
            }

            if (InsidePosX != -1 && EntityObj.GetDistanceSq(InsidePosX, EntityObj.PosY, InsidePosZ) < 4D)
            {
                return(false);
            }

            Village village = EntityObj.WorldObj.VillageCollectionObj.FindNearestVillage(MathHelper2.Floor_double(EntityObj.PosX), MathHelper2.Floor_double(EntityObj.PosY), MathHelper2.Floor_double(EntityObj.PosZ), 14);

            if (village == null)
            {
                return(false);
            }
            else
            {
                DoorInfo = village.FindNearestDoorUnrestricted(MathHelper2.Floor_double(EntityObj.PosX), MathHelper2.Floor_double(EntityObj.PosY), MathHelper2.Floor_double(EntityObj.PosZ));
                return(DoorInfo != null);
            }
        }
        /// <summary>
        /// Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
        /// use this to react to sunlight and start to burn.
        /// </summary>
        public override void OnLivingUpdate()
        {
            base.OnLivingUpdate();

            if (IsWet())
            {
                AttackEntityFrom(DamageSource.Drown, 1);
            }

            int i = MathHelper2.Floor_double(PosX);
            int k = MathHelper2.Floor_double(PosZ);

            if (WorldObj.GetBiomeGenForCoords(i, k).GetFloatTemperature() > 1.0F)
            {
                AttackEntityFrom(DamageSource.OnFire, 1);
            }

            for (int j = 0; j < 4; j++)
            {
                int l  = MathHelper2.Floor_double(PosX + (double)((float)((j % 2) * 2 - 1) * 0.25F));
                int i1 = MathHelper2.Floor_double(PosY);
                int j1 = MathHelper2.Floor_double(PosZ + (double)((float)(((j / 2) % 2) * 2 - 1) * 0.25F));

                if (WorldObj.GetBlockId(l, i1, j1) == 0 && WorldObj.GetBiomeGenForCoords(l, j1).GetFloatTemperature() < 0.8F && Block.Snow.CanPlaceBlockAt(WorldObj, l, i1, j1))
                {
                    WorldObj.SetBlockWithNotify(l, i1, j1, Block.Snow.BlockID);
                }
            }
        }
        /// <summary>
        /// Returns whether the EntityAIBase should begin execution.
        /// </summary>
        public override bool ShouldExecute()
        {
            if (EntityObj.WorldObj.IsDaytime())
            {
                return(false);
            }

            Village village = EntityObj.WorldObj.VillageCollectionObj.FindNearestVillage(MathHelper2.Floor_double(EntityObj.PosX), MathHelper2.Floor_double(EntityObj.PosY), MathHelper2.Floor_double(EntityObj.PosZ), 16);

            if (village == null)
            {
                return(false);
            }

            FrontDoor = village.FindNearestDoor(MathHelper2.Floor_double(EntityObj.PosX), MathHelper2.Floor_double(EntityObj.PosY), MathHelper2.Floor_double(EntityObj.PosZ));

            if (FrontDoor == null)
            {
                return(false);
            }
            else
            {
                return((double)FrontDoor.GetInsideDistanceSquare(MathHelper2.Floor_double(EntityObj.PosX), MathHelper2.Floor_double(EntityObj.PosY), MathHelper2.Floor_double(EntityObj.PosZ)) < 2.25D);
            }
        }
Exemple #6
0
        public override void Draw(GameTime gameTime, RenderEnv env)
        {
            Vector2 origin = env.Camera.Origin;
            Point   p1     = new Point(this.X - (int)origin.X, this.Y1 - (int)origin.Y);
            Point   p2     = new Point(this.X - (int)origin.X, this.Y2 - (int)origin.Y);
            Color   color  = MathHelper2.Lerp(colorTable, (float)gameTime.TotalGameTime.TotalMilliseconds % 10000 / 2000);

            env.Sprite.DrawLine(p1, p2, 5, color);
        }
Exemple #7
0
        /// <summary>
        /// Execute a one shot task or start executing a continuous task
        /// </summary>
        public override void StartExecuting()
        {
            float d  = LeapTarget.PosX - Leaper.PosX;
            float d1 = LeapTarget.PosZ - Leaper.PosZ;
            float f  = MathHelper2.Sqrt_double(d * d + d1 * d1);

            Leaper.MotionX += (d / f) * 0.5F * 0.80000001192092896F + Leaper.MotionX * 0.20000000298023224F;
            Leaper.MotionZ += (d1 / f) * 0.5F * 0.80000001192092896F + Leaper.MotionZ * 0.20000000298023224F;
            Leaper.MotionY  = LeapMotionY;
        }
        /// <summary>
        /// Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
        /// True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
        /// </summary>
        public override bool OnItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
        {
            if (par7 != 1)
            {
                return(false);
            }

            par5++;
            BlockBed blockbed = (BlockBed)Block.Bed;
            int      i        = MathHelper2.Floor_double((double)((par2EntityPlayer.RotationYaw * 4F) / 360F) + 0.5D) & 3;
            sbyte    byte0    = 0;
            sbyte    byte1    = 0;

            if (i == 0)
            {
                byte1 = 1;
            }

            if (i == 1)
            {
                byte0 = -1;
            }

            if (i == 2)
            {
                byte1 = -1;
            }

            if (i == 3)
            {
                byte0 = 1;
            }

            if (!par2EntityPlayer.CanPlayerEdit(par4, par5, par6) || !par2EntityPlayer.CanPlayerEdit(par4 + byte0, par5, par6 + byte1))
            {
                return(false);
            }

            if (par3World.IsAirBlock(par4, par5, par6) && par3World.IsAirBlock(par4 + byte0, par5, par6 + byte1) && par3World.IsBlockNormalCube(par4, par5 - 1, par6) && par3World.IsBlockNormalCube(par4 + byte0, par5 - 1, par6 + byte1))
            {
                par3World.SetBlockAndMetadataWithNotify(par4, par5, par6, blockbed.BlockID, i);

                if (par3World.GetBlockId(par4, par5, par6) == blockbed.BlockID)
                {
                    par3World.SetBlockAndMetadataWithNotify(par4 + byte0, par5, par6 + byte1, blockbed.BlockID, i + 8);
                }

                par1ItemStack.StackSize--;
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// Returns whether an in-progress EntityAIBase should continue executing
 /// </summary>
 public override bool ContinueExecuting()
 {
     if (EntityObj.WorldObj.IsDaytime())
     {
         return(false);
     }
     else
     {
         return(!FrontDoor.IsDetachedFromVillageFlag && FrontDoor.IsInside(MathHelper2.Floor_double(EntityObj.PosX), MathHelper2.Floor_double(EntityObj.PosZ)));
     }
 }
        public override void Draw(GameTime gameTime, RenderEnv env)
        {
            Vector2 origin = env.Camera.Origin;
            Point   p1     = new Point(x1 - (int)origin.X, y1 - (int)origin.Y);
            Point   p2     = new Point(x2 - (int)origin.X, y2 - (int)origin.Y);
            Color   color  = MathHelper2.Lerp(colorTable, (float)gameTime.TotalGameTime.TotalMilliseconds % 10000 / 2000);

            if (x1 != x2 && y1 != y2)
            {
            }
            env.Sprite.DrawLine(p1, p2, 2, color);
        }
Exemple #11
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            if (BlockID == 0)
            {
                SetDead();
                return;
            }

            PrevPosX = PosX;
            PrevPosY = PosY;
            PrevPosZ = PosZ;
            FallTime++;
            MotionY -= 0.039999999105930328F;
            MoveEntity(MotionX, MotionY, MotionZ);
            MotionX *= 0.98000001907348633F;
            MotionY *= 0.98000001907348633F;
            MotionZ *= 0.98000001907348633F;
            int i = MathHelper2.Floor_double(PosX);
            int j = MathHelper2.Floor_double(PosY);
            int k = MathHelper2.Floor_double(PosZ);

            if (FallTime == 1 && WorldObj.GetBlockId(i, j, k) == BlockID)
            {
                WorldObj.SetBlockWithNotify(i, j, k, 0);
            }
            else if (!WorldObj.IsRemote && FallTime == 1)
            {
                SetDead();
            }

            if (OnGround)
            {
                MotionX *= 0.69999998807907104F;
                MotionZ *= 0.69999998807907104F;
                MotionY *= -0.5F;

                if (WorldObj.GetBlockId(i, j, k) != Block.PistonMoving.BlockID)
                {
                    SetDead();

                    if ((!WorldObj.CanBlockBePlacedAt(BlockID, i, j, k, true, 1) || BlockSand.CanFallBelow(WorldObj, i, j - 1, k) || !WorldObj.SetBlockWithNotify(i, j, k, BlockID)) && !WorldObj.IsRemote)
                    {
                        DropItem(BlockID, 1);
                    }
                }
            }
            else if (FallTime > 100 && !WorldObj.IsRemote && (j < 1 || j > 256) || FallTime > 600)
            {
                DropItem(BlockID, 1);
                SetDead();
            }
        }
Exemple #12
0
 /// <summary>
 /// Called to update the entity's position/logic.
 /// </summary>
 public override void OnUpdate()
 {
     if (!WorldObj.BlockExists(MathHelper2.Floor_double(PosX), 0, MathHelper2.Floor_double(PosZ)))
     {
         return;
     }
     else
     {
         base.OnUpdate();
         SendMotionUpdates();
         return;
     }
 }
Exemple #13
0
        /// <summary>
        /// Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
        /// use this to react to sunlight and start to burn.
        /// </summary>
        public override void OnLivingUpdate()
        {
            if (WorldObj.IsDaytime() && !WorldObj.IsRemote)
            {
                float f = GetBrightness(1.0F);

                if (f > 0.5F && WorldObj.CanBlockSeeTheSky(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ)) && Rand.NextFloat() * 30F < (f - 0.4F) * 2.0F)
                {
                    SetFire(8);
                }
            }

            base.OnLivingUpdate();
        }
Exemple #14
0
        public void SubtractTest()
        {
            //1.настройки тестовых данных
            //2.действия по проверке - тестированию
            //3.сравнить результат
            //1
            int a        = 20;
            int b        = 10;
            int expected = 10;
            //2
            MathHelper2 helper = new MathHelper2();
            int         result = helper.Subtract(a, b);

            //3
            Assert.AreEqual(expected, result);
        }
Exemple #15
0
        public void UpdateSize()
        {
            Vector2 minimapSize;

            if (this.MiniMap == null || this.MiniMap.Canvas == null)
            {
                minimapSize = Vector2.Zero;
            }
            else
            {
                Texture2D tex = this.MiniMap.Canvas;
                minimapSize = new Vector2(tex.Width, tex.Height);
            }

            //计算小地图size
            int top    = this.resource.N.Height,
                bottom = this.resource.S.Height,
                left   = this.resource.W.Width,
                right  = this.resource.E.Width;

            minimapSize = new Vector2(left + right + minimapSize.X,
                                      top + bottom + minimapSize.Y);

            //计算地图名称size
            float mapNameRight = this.mapNameOrigin.X;

            if (this.MapNameFont != null)
            {
                if (this.MapName != null)
                {
                    mapNameRight = Math.Max(mapNameRight,
                                            this.mapNameOrigin.X + this.MapNameFont.MeasureString(this.MapName).X);
                }
                if (this.StreetName != null)
                {
                    mapNameRight = Math.Max(mapNameRight,
                                            this.mapNameOrigin.X + this.MapNameFont.MeasureString(this.StreetName).X);
                }
            }
            mapNameRight += this.resource.E.Width;

            this.Size = new Vector2(MathHelper2.Max(this.minSize.X, minimapSize.X, mapNameRight),
                                    MathHelper2.Max(this.minSize.Y, minimapSize.Y));
        }
        /// <summary>
        /// Updates the task
        /// </summary>
        public override void UpdateTask()
        {
            ThePet.GetLookHelper().SetLookPositionWithEntity(TheOwner, 10F, ThePet.GetVerticalFaceSpeed());

            if (ThePet.IsSitting())
            {
                return;
            }

            if (--Field_48310_h > 0)
            {
                return;
            }

            Field_48310_h = 10;

            if (PetPathfinder.Func_48667_a(TheOwner, Field_48303_f))
            {
                return;
            }

            if (ThePet.GetDistanceSqToEntity(TheOwner) < 144D)
            {
                return;
            }

            int i = MathHelper2.Floor_double(TheOwner.PosX) - 2;
            int j = MathHelper2.Floor_double(TheOwner.PosZ) - 2;
            int k = MathHelper2.Floor_double(TheOwner.BoundingBox.MinY);

            for (int l = 0; l <= 4; l++)
            {
                for (int i1 = 0; i1 <= 4; i1++)
                {
                    if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && TheWorld.IsBlockNormalCube(i + l, k - 1, j + i1) && !TheWorld.IsBlockNormalCube(i + l, k, j + i1) && !TheWorld.IsBlockNormalCube(i + l, k + 1, j + i1))
                    {
                        ThePet.SetLocationAndAngles((float)(i + l) + 0.5F, k, (float)(j + i1) + 0.5F, ThePet.RotationYaw, ThePet.RotationPitch);
                        PetPathfinder.ClearPathEntity();
                        return;
                    }
                }
            }
        }
Exemple #17
0
        /// <summary>
        /// Checks to make sure the light is not too bright where the mob is spawning
        /// </summary>
        protected virtual bool IsValidLightLevel()
        {
            int i = MathHelper2.Floor_double(PosX);
            int j = MathHelper2.Floor_double(BoundingBox.MinY);
            int k = MathHelper2.Floor_double(PosZ);

            if (WorldObj.GetSavedLightValue(SkyBlock.Sky, i, j, k) > Rand.Next(32))
            {
                return(false);
            }

            int l = WorldObj.GetBlockLightValue(i, j, k);

            if (WorldObj.IsThundering())
            {
                int i1 = WorldObj.SkylightSubtracted;
                WorldObj.SkylightSubtracted = 10;
                l = WorldObj.GetBlockLightValue(i, j, k);
                WorldObj.SkylightSubtracted = i1;
            }

            return(l <= Rand.Next(8));
        }
        private bool Func_48375_a(EntityLiving par1EntityLiving)
        {
            Field_48377_f = 10 + TaskOwner.GetRNG().Next(5);
            PathEntity pathentity = TaskOwner.GetNavigator().Func_48679_a(par1EntityLiving);

            if (pathentity == null)
            {
                return(false);
            }

            PathPoint pathpoint = pathentity.GetFinalPathPoint();

            if (pathpoint == null)
            {
                return(false);
            }
            else
            {
                int i = pathpoint.XCoord - MathHelper2.Floor_double(par1EntityLiving.PosX);
                int j = pathpoint.ZCoord - MathHelper2.Floor_double(par1EntityLiving.PosZ);
                return((double)(i * i + j * j) <= 2.25D);
            }
        }
Exemple #19
0
        /// <summary>
        /// Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
        /// block.
        /// </summary>
        public override bool BlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
        {
            int i = par1World.GetBlockMetadata(par2, par3, par4);

            if (IsFenceGateOpen(i))
            {
                par1World.SetBlockMetadataWithNotify(par2, par3, par4, i & -5);
            }
            else
            {
                int j = (MathHelper2.Floor_double((double)((par5EntityPlayer.RotationYaw * 4F) / 360F) + 0.5D) & 3) % 4;
                int k = GetDirection(i);

                if (k == (j + 2) % 4)
                {
                    i = j;
                }

                par1World.SetBlockMetadataWithNotify(par2, par3, par4, i | 4);
            }

            par1World.PlayAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
            return(true);
        }
Exemple #20
0
        /// <summary>
        /// Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
        /// True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
        /// </summary>
        public override bool OnItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
        {
            if (par7 != 1)
            {
                return(false);
            }

            par5++;
            Block block;

            if (DoorMaterial == Material.Wood)
            {
                block = Block.DoorWood;
            }
            else
            {
                block = Block.DoorSteel;
            }

            if (!par2EntityPlayer.CanPlayerEdit(par4, par5, par6) || !par2EntityPlayer.CanPlayerEdit(par4, par5 + 1, par6))
            {
                return(false);
            }

            if (!block.CanPlaceBlockAt(par3World, par4, par5, par6))
            {
                return(false);
            }
            else
            {
                int i = MathHelper2.Floor_double((double)(((par2EntityPlayer.RotationYaw + 180F) * 4F) / 360F) - 0.5D) & 3;
                PlaceDoorBlock(par3World, par4, par5, par6, i, block);
                par1ItemStack.StackSize--;
                return(true);
            }
        }
Exemple #21
0
        /// <summary>
        /// Called when the block is placed in the world.
        /// </summary>
        public override void OnBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
        {
            int i = MathHelper2.Floor_double((double)((par5EntityLiving.RotationYaw * 4F) / 360F) + 2.5D) & 3;

            par1World.SetBlockMetadataWithNotify(par2, par3, par4, i);
        }
Exemple #22
0
        private TooltipContent DrawItem(GameTime gameTime, RenderEnv env, UIWorldMap.Tooltip item)
        {
            var          blocks   = new List <TextBlock>();
            var          textures = new List <TextureBlock>();
            Vector2      size     = Vector2.Zero;
            Vector2      current  = Vector2.Zero;
            StringResult sr       = null;

            var spot = item.Spot;

            if (spot != null)
            {
                //计算属性要求 获取怪物列表和npc列表
                int spotBarrier = 0, spotBarrierArc = 0, spotBarrierAut = 0;
                var mobNames = new List <string>();
                var npcNames = new List <string>();
                int minLevel = 0, maxLevel = 0;

                if (!spot.NoTooltip)
                {
                    HashSet <int> mobs = new HashSet <int>();
                    HashSet <int> npcs = new HashSet <int>();
                    //TODO: caching mobs level.
                    foreach (var mapNo in spot.MapNo)
                    {
                        var mapNode = PluginManager.FindWz(string.Format("Map/Map/Map{0}/{1:D9}.img/info", mapNo / 100000000, mapNo));
                        if (mapNode != null)
                        {
                            int barrier    = mapNode?.Nodes["barrier"].GetValueEx(0) ?? 0;
                            int barrierArc = mapNode?.Nodes["barrierArc"].GetValueEx(0) ?? 0;
                            int barrierAut = mapNode?.Nodes["barrierAut"].GetValueEx(0) ?? 0;
                            spotBarrier    = Math.Max(spotBarrier, barrier);
                            spotBarrierArc = Math.Max(spotBarrierArc, barrierArc);
                            spotBarrierAut = Math.Max(spotBarrierAut, barrierAut);
                        }

                        var mapInfo = PluginManager.FindWz(string.Format("Etc/MapObjectInfo.img/{0}", mapNo));
                        if (mapInfo != null)
                        {
                            var mobNode = mapInfo.Nodes["mob"];
                            if (mobNode != null)
                            {
                                foreach (var valNode in mobNode.Nodes)
                                {
                                    mobs.Add(valNode.GetValue <int>());
                                }
                            }
                            var npcNode = mapInfo.Nodes["npc"];
                            if (npcNode != null)
                            {
                                foreach (var valNode in npcNode.Nodes)
                                {
                                    npcs.Add(valNode.GetValue <int>());
                                }
                            }
                        }
                    }

                    if (mobs.Count > 0)
                    {
                        foreach (var mobID in mobs)
                        {
                            this.StringLinker?.StringMob.TryGetValue(mobID, out sr);
                            var    mobLevel = PluginManager.FindWz(string.Format("Mob/{0:D7}.img/info/level", mobID)).GetValueEx <int>(0);
                            string mobText  = sr != null?string.Format("{0}(Lv.{1})", sr.Name, mobLevel) : mobID.ToString();

                            mobNames.Add(mobText);
                            if (mobLevel > 0)
                            {
                                if (minLevel > 0)
                                {
                                    minLevel = Math.Min(minLevel, mobLevel);
                                }
                                else
                                {
                                    minLevel = mobLevel;
                                }
                                if (maxLevel > 0)
                                {
                                    maxLevel = Math.Max(maxLevel, mobLevel);
                                }
                                else
                                {
                                    maxLevel = mobLevel;
                                }
                            }
                        }
                        minLevel = Math.Max(10, minLevel - 3);
                        maxLevel = Math.Max(10, maxLevel - 2);
                    }
                    if (npcs.Count > 0)
                    {
                        foreach (var npcID in npcs)
                        {
                            this.StringLinker?.StringNpc.TryGetValue(npcID, out sr);
                            string npcText = sr?.Name ?? npcID.ToString();
                            npcNames.Add(npcText);
                        }
                    }
                }

                //预计算宽度
                int partWidth          = 0;
                int?drawNpcColumnWidth = null;
                var font = env.Fonts.TooltipContentFont;
                if (mobNames.Count > 0 || npcNames.Count > 0)
                {
                    float mobWidth = mobNames.Count <= 0 ? 0 : mobNames.Max(text => font.MeasureString(text).X);
                    float npcWidth = npcNames.Count <= 0 ? 0 : npcNames.Max(text => font.MeasureString(text).X);
                    if (npcNames.Count > 0 && mobNames.Count + npcNames.Count > 18)
                    {
                        partWidth          = (int)Math.Max(mobWidth, npcWidth * 2 + 10);
                        drawNpcColumnWidth = (int)npcWidth;
                    }
                    else
                    {
                        partWidth = (int)Math.Max(mobWidth, npcWidth);
                    }
                    partWidth += 15;
                }

                //开始绘制
                //属性要求
                List <object> part1      = null;
                float         part1Width = 0;
                if (spotBarrier > 0 || spotBarrierArc > 0 || spotBarrierAut > 0)
                {
                    part1 = new List <object>();
                    Action <int, Texture2D, Color> addBarrier = (barrier, icon, foreColor) =>
                    {
                        if (icon != null)
                        {
                            var rect = new Rectangle((int)current.X, (int)current.Y + 1, icon.Width, icon.Height);
                            part1.Add(new TextureBlock(icon, rect));
                            current.X += rect.Width + 1;
                        }

                        var textBlock = PrepareTextBlock(env.Fonts.DefaultFont, barrier.ToString(), ref current, foreColor);
                        part1.Add(textBlock);
                    };

                    if (spotBarrier > 0)
                    {
                        var icon = Content.Load <Texture2D>(nameof(MRes.UIWindow_img_ToolTip_WorldMap_StarForce));
                        addBarrier(spotBarrier, icon, new Color(255, 204, 0));
                    }
                    else if (spotBarrierArc > 0)
                    {
                        var icon = Content.Load <Texture2D>(nameof(MRes.UIWindow_img_ToolTip_WorldMap_ArcaneForce));
                        addBarrier(spotBarrierArc, icon, new Color(221, 170, 255));
                    }
                    else if (spotBarrierAut > 0)
                    {
                        var icon = Content.Load <Texture2D>(nameof(MRes.UIWindow_img_ToolTip_WorldMap_AuthenticForce));
                        addBarrier(spotBarrierAut, icon, new Color(221, 170, 255));
                    }

                    part1Width = current.X;
                    size.X     = Math.Max(size.X, current.X);
                    current.X  = 0;
                    current.Y += 15;
                }

                //地图名称
                List <TextBlock> part2      = new List <TextBlock>();
                List <TextBlock> part2_1    = null;
                float            part2Width = 0;
                {
                    int mapID = spot.MapNo[0];
                    this.StringLinker?.StringMap.TryGetValue(mapID, out sr);
                    string title     = spot.Title ?? (sr != null ? string.Format("{0} : {1}", sr["streetName"], sr["mapName"]) : mapID.ToString());
                    string desc      = spot.Desc ?? sr?["mapDesc"];
                    var    titleFont = string.IsNullOrEmpty(desc) ? env.Fonts.TooltipContentFont : env.Fonts.TooltipTitleFont;
                    part2.Add(PrepareTextLine(titleFont, title, ref current, Color.White, ref part2Width));
                    size.X = Math.Max(size.X, part2Width);

                    if (!string.IsNullOrEmpty(desc))
                    {
                        current.Y += 2;
                        part2_1    = new List <TextBlock>();
                        int width = (int)MathHelper2.Max(280, part2Width, size.X, partWidth);
                        part2_1.AddRange(PrepareFormatText(env.Fonts.TooltipContentFont, desc, ref current, width, ref size.X));
                    }

                    current.Y += 4;
                }

                //准备分割线
                List <TextureBlock> lines = new List <TextureBlock>();
                var line = Content.Load <Texture2D>(nameof(MRes.UIWindow_img_ToolTip_WorldMap_Line));

                //绘制怪物
                List <object> part3 = null;
                if (mobNames.Count > 0)
                {
                    part3 = new List <object>();

                    //绘制分割线
                    lines.Add(new TextureBlock(line, new Rectangle(current.ToPoint(), Point.Zero)));
                    current.Y += 8;

                    //推荐等级
                    current.X = 15;
                    part3.Add(PrepareTextBlock(font,
                                               string.Format("推荐等级 : Lv.{0} ~ Lv.{1}", minLevel, maxLevel),
                                               ref current, new Color(119, 204, 255)));
                    size.X     = Math.Max(size.X, current.X);
                    current.X  = 0;
                    current.Y += 18;

                    //绘制分割线
                    lines.Add(new TextureBlock(line, new Rectangle(current.ToPoint(), Point.Zero)));
                    current.Y += 8;

                    //怪物列表
                    Texture2D icon;
                    Color     color;
                    if (spotBarrier > 0 || spotBarrierArc > 0 || spotBarrierAut > 0)
                    {
                        icon  = Content.Load <Texture2D>(nameof(MRes.UIWindow_img_ToolTip_WorldMap_enchantMob));
                        color = new Color(255, 0, 102);
                    }
                    else
                    {
                        icon  = Content.Load <Texture2D>(nameof(MRes.UIWindow_img_ToolTip_WorldMap_Mob));
                        color = new Color(119, 255, 0);
                    }
                    part3.Add(new TextureBlock(icon, new Rectangle(0, (int)current.Y + 1, 0, 0)));
                    foreach (var mobName in mobNames)
                    {
                        part3.Add(new TextBlock()
                        {
                            Font      = font,
                            Text      = mobName,
                            Position  = new Vector2(15, current.Y),
                            ForeColor = color
                        });
                        current.Y += 18;
                    }
                }

                //绘制npc
                List <object> part4 = null;
                if (npcNames.Count > 0)
                {
                    part4 = new List <object>();
                    //绘制分割线
                    lines.Add(new TextureBlock(line, new Rectangle(current.ToPoint(), Point.Zero)));
                    current.Y += 8;

                    //npc列表
                    Texture2D icon  = Content.Load <Texture2D>(nameof(MRes.UIWindow_img_ToolTip_WorldMap_Npc));
                    Color     color = new Color(119, 204, 255);
                    part4.Add(new TextureBlock(icon, new Rectangle(0, (int)current.Y + 1, 0, 0)));
                    for (int i = 0; i < npcNames.Count; i++)
                    {
                        var pos = new Vector2(15, current.Y);
                        if (i % 2 == 1 && drawNpcColumnWidth != null)
                        {
                            pos.X += 10 + drawNpcColumnWidth.Value;
                        }

                        part4.Add(new TextBlock()
                        {
                            Font      = font,
                            Text      = npcNames[i],
                            Position  = pos,
                            ForeColor = color
                        });

                        if (i == npcNames.Count - 1 || drawNpcColumnWidth == null || i % 2 == 1)
                        {
                            current.X  = 0;
                            current.Y += 18;
                        }
                    }
                }

                size.X     = Math.Max(size.X, partWidth);
                current.Y -= 4;

                //合并parts
                //对part1 part2居中
                if (part1 != null)
                {
                    int offset = (int)((size.X - part1Width) / 2);
                    foreach (object obj in part1)
                    {
                        if (obj is TextBlock)
                        {
                            var tb = (TextBlock)obj;
                            tb.Position.X += offset;
                            blocks.Add(tb);
                        }
                        else if (obj is TextureBlock)
                        {
                            var tex = (TextureBlock)obj;
                            tex.Rectangle.X += offset;
                            textures.Add(tex);
                        }
                    }
                }
                if (part2 != null)
                {
                    int offset = (int)((size.X - part2Width) / 2);
                    for (int i = 0; i < part2.Count; i++)
                    {
                        var tb = part2[i];
                        tb.Position.X += offset;
                        blocks.Add(tb);
                    }
                }
                if (part2_1 != null)
                {
                    foreach (var tb in part2_1)
                    {
                        blocks.Add(tb);
                    }
                }
                if (lines != null)
                {
                    for (int i = 0; i < lines.Count; i++)
                    {
                        var tex = lines[i];
                        tex.Rectangle.Width  = (int)size.X;
                        tex.Rectangle.Height = 1;
                        textures.Add(tex);
                    }
                }
                foreach (var _part in new[] { part3, part4 })
                {
                    if (_part != null)
                    {
                        foreach (object obj in _part)
                        {
                            if (obj is TextBlock)
                            {
                                var tb = (TextBlock)obj;
                                blocks.Add(tb);
                            }
                            else if (obj is TextureBlock)
                            {
                                var tex = (TextureBlock)obj;
                                textures.Add(tex);
                            }
                        }
                    }
                }
            }
            size.Y = current.Y;
            return(new TooltipContent()
            {
                blocks = blocks, textures = textures, size = size
            });
        }
        /// <summary>
        /// Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
        /// True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
        /// </summary>
        public override bool OnItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
        {
            if (par7 == 0)
            {
                return(false);
            }

            if (!par3World.GetBlockMaterial(par4, par5, par6).IsSolid())
            {
                return(false);
            }

            if (par7 == 1)
            {
                par5++;
            }

            if (par7 == 2)
            {
                par6--;
            }

            if (par7 == 3)
            {
                par6++;
            }

            if (par7 == 4)
            {
                par4--;
            }

            if (par7 == 5)
            {
                par4++;
            }

            if (!par2EntityPlayer.CanPlayerEdit(par4, par5, par6))
            {
                return(false);
            }

            if (!Block.SignPost.CanPlaceBlockAt(par3World, par4, par5, par6))
            {
                return(false);
            }

            if (par7 == 1)
            {
                int i = MathHelper2.Floor_double((double)(((par2EntityPlayer.RotationYaw + 180F) * 16F) / 360F) + 0.5D) & 0xf;
                par3World.SetBlockAndMetadataWithNotify(par4, par5, par6, Block.SignPost.BlockID, i);
            }
            else
            {
                par3World.SetBlockAndMetadataWithNotify(par4, par5, par6, Block.SignWall.BlockID, par7);
            }

            par1ItemStack.StackSize--;
            TileEntitySign tileentitysign = (TileEntitySign)par3World.GetBlockTileEntity(par4, par5, par6);

            if (tileentitysign != null)
            {
                par2EntityPlayer.DisplayGUIEditSign(tileentitysign);
            }

            return(true);
        }
        /// <summary>
        /// Moves the entity based on the specified heading.  Args: strafe, forward
        /// </summary>
        public override void MoveEntityWithHeading(float par1, float par2)
        {
            if (IsInWater())
            {
                MoveFlying(par1, par2, 0.02F);
                MoveEntity(MotionX, MotionY, MotionZ);
                MotionX *= 0.80000001192092896F;
                MotionY *= 0.80000001192092896F;
                MotionZ *= 0.80000001192092896F;
            }
            else if (HandleLavaMovement())
            {
                MoveFlying(par1, par2, 0.02F);
                MoveEntity(MotionX, MotionY, MotionZ);
                MotionX *= 0.5F;
                MotionY *= 0.5F;
                MotionZ *= 0.5F;
            }
            else
            {
                float f = 0.91F;

                if (OnGround)
                {
                    f = 0.5460001F;
                    int i = WorldObj.GetBlockId(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(BoundingBox.MinY) - 1, MathHelper2.Floor_double(PosZ));

                    if (i > 0)
                    {
                        f = Block.BlocksList[i].Slipperiness * 0.91F;
                    }
                }

                float f1 = 0.1627714F / (f * f * f);
                MoveFlying(par1, par2, OnGround ? 0.1F * f1 : 0.02F);
                f = 0.91F;

                if (OnGround)
                {
                    f = 0.5460001F;
                    int j = WorldObj.GetBlockId(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(BoundingBox.MinY) - 1, MathHelper2.Floor_double(PosZ));

                    if (j > 0)
                    {
                        f = Block.BlocksList[j].Slipperiness * 0.91F;
                    }
                }

                MoveEntity(MotionX, MotionY, MotionZ);
                MotionX *= f;
                MotionY *= f;
                MotionZ *= f;
            }

            Field_705_Q = Field_704_R;
            double d  = PosX - PrevPosX;
            double d1 = PosZ - PrevPosZ;
            float  f2 = MathHelper2.Sqrt_double(d * d + d1 * d1) * 4F;

            if (f2 > 1.0F)
            {
                f2 = 1.0F;
            }

            Field_704_R += (f2 - Field_704_R) * 0.4F;
            Field_703_S += Field_704_R;
        }
Exemple #25
0
 public ChunkPosition(Vec3D par1Vec3D) : this(MathHelper2.Floor_double(par1Vec3D.XCoord), MathHelper2.Floor_double(par1Vec3D.YCoord), MathHelper2.Floor_double(par1Vec3D.ZCoord))
 {
 }
Exemple #26
0
        public void Draw(RenderEnv env, GameTime gameTime)
        {
            //计算UI偏移
            Matrix trans = Matrix.CreateTranslation(this.Position.X, this.Position.Y, 0);

            //绘制外框
            env.GraphicsDevice.ScissorRectangle = new Rectangle((int)this.Position.X, (int)this.Position.Y, (int)this.Size.X, (int)this.Size.Y);
            env.GraphicsDevice.RasterizerState  = StateEx.Scissor();

            env.Sprite.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: trans);
            env.Sprite.FillRectangle(this.MinimapRectangle, new Color(Color.Black, 0.7f));
            UIGraphics.DrawNineForm(env, this.resource, Vector2.Zero, this.Size);
            env.Sprite.End();

            env.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

            //绘制标题
            if (this.MapNameFont != null)
            {
                env.Sprite.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: trans);
                if (this.StreetName != null)
                {
                    env.Sprite.DrawStringEx(this.MapNameFont, this.StreetName, this.streetNameOrigin, Color.White);
                }
                if (this.MapName != null)
                {
                    env.Sprite.DrawStringEx(this.MapNameFont, this.MapName, this.mapNameOrigin, Color.White);
                }
                env.Sprite.End();
            }

            //绘制小地图
            if (this.MiniMap != null)
            {
                //绘制小地图标记
                env.Sprite.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: trans);
                if (MapMarkVisible && this.MiniMap.MapMark != null)
                {
                    env.Sprite.Draw(this.MiniMap.MapMark, mapMarkOrigin, Color.White);
                }
                env.Sprite.End();

                if (this.MiniMap.Canvas != null)
                {
                    //计算世界地图到小地图的偏移
                    Texture2D canvas = this.MiniMap.Canvas;
                    Rectangle fromRect;
                    if (this.MiniMap.Width > 0 && this.MiniMap.Height > 0)
                    {
                        fromRect = new Rectangle(-this.MiniMap.CenterX, -this.MiniMap.CenterY, this.MiniMap.Width, this.MiniMap.Height);
                    }
                    else
                    {
                        fromRect = env.Camera.WorldRect;
                    }
                    Rectangle toRect         = new Rectangle(0, 0, canvas.Width, canvas.Height);
                    Matrix    worldToMinimap = Matrix.CreateTranslation(-fromRect.X, -fromRect.Y, 0)
                                               * Matrix.CreateScale(1f / fromRect.Width * toRect.Width, 1f / fromRect.Height * toRect.Height, 0)
                                               * Matrix.CreateTranslation(toRect.X, toRect.Y, 0);

                    //计算小地图区域的二次偏移
                    Rectangle rect   = this.MinimapRectangle;
                    Vector2   offset = new Vector2((rect.Width - canvas.Width) / 2, (rect.Height - canvas.Height) / 2);
                    worldToMinimap *= Matrix.CreateTranslation(offset.X, offset.Y, 0);

                    //设置剪裁区域
                    env.GraphicsDevice.ScissorRectangle = new Rectangle(
                        (int)this.Position.X + rect.X, (int)this.Position.Y + rect.Y, rect.Width, rect.Height);
                    env.GraphicsDevice.RasterizerState = StateEx.Scissor();

                    //绘制小地图本体
                    env.Sprite.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: trans);
                    env.Sprite.Draw(this.MiniMap.Canvas, miniMapOrigin + offset, Color.White);

                    if (this.ResourceLoaded)
                    {
                        Vector2 iconOrigin = new Vector2(0, 5);
                        //绘制一般传送门
                        if (this.Portals.Count > 0 && this.texPortal != null)
                        {
                            Vector2 origin = new Vector2(this.texPortal.Width / 2, this.texPortal.Height / 2);
                            foreach (var portal in this.Portals)
                            {
                                Vector2 position = Vector2.Transform(portal, worldToMinimap);
                                position = miniMapOrigin + position - origin - iconOrigin;
                                position = MathHelper2.Round(position);
                                env.Sprite.Draw(this.texPortal, position, Color.White);
                            }
                        }

                        //绘制地图内传送门
                        if (this.Transports.Count > 0 && this.texTransport != null)
                        {
                            Vector2 origin = new Vector2(this.texTransport.Width / 2, this.texTransport.Height / 2);
                            foreach (var portal in this.Transports)
                            {
                                Vector2 position = Vector2.Transform(portal, worldToMinimap);
                                position = miniMapOrigin + position - origin - iconOrigin;
                                position = MathHelper2.Round(position);
                                env.Sprite.Draw(this.texTransport, position, Color.White);
                            }
                        }
                    }

                    //绘制摄像机区域框
                    Rectangle cameraRect = MathHelper2.Transform(env.Camera.ClipRect, worldToMinimap);
                    cameraRect.X += (int)miniMapOrigin.X;
                    cameraRect.Y += (int)miniMapOrigin.Y;
                    env.Sprite.DrawRectangle(cameraRect, Color.Yellow);
                    env.Sprite.End();
                    env.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
                }
            }
        }
Exemple #27
0
        public static TestModel CreateTestModel()
        {
            TestModel result = new TestModel();

            PointF   a      = new PointF(-10, 0);
            PointF   b      = new PointF(10, 0);
            Vector3d delta  = new Vector3d(0, 0, 10);
            Matrix3d matrix = Matrix3d.RotationY(5 / 57.29577f);

            result.Vertices.Add(new Vector3d(a.X, 0, a.Y));
            result.Vertices.Add(new Vector3d(b.X, 0, b.Y));

            for (uint i = 0; i < 80; i++)
            {
                delta.Mul(matrix);

                PointF d  = new PointF(b.X + delta.X, b.Y + delta.Z);
                PointF dp = new PointF(d.X, d.Y);
                PointF dv = new PointF(d.X + delta.Z, d.Y - delta.X);
                PointF ap = new PointF(a.X, a.Y);
                PointF av = new PointF(a.X + delta.X, a.Y + delta.Z);
                PointF p  = MathHelper2.Intersection(dp, dv, ap, av);
                PointF c  = new PointF(p.X, p.Y);

                result.Vertices.Add(new Vector3d(c.X, 0, c.Y));
                result.Vertices.Add(new Vector3d(d.X, 0, d.Y));

                result.Indices.Add(2 + i * 2);
                result.Indices.Add(0 + i * 2);
                result.Indices.Add(1 + i * 2);
                result.Indices.Add(2 + i * 2);
                result.Indices.Add(1 + i * 2);
                result.Indices.Add(3 + i * 2);

                a = c;
                b = d;
            }

            //float rotationY = (float)Math.Atan2(delta.Z, delta.X); // 57.29577f *
            //PointF c = new PointF(-100 + delta.X, 100 + delta.Z);

            //PointF[] points = new PointF[] { a, b, c, d };

            //for (int i = 0; i < points.Length; i++)
            //{
            //    points[i].X += 400;
            //    points[i].Y += 310;
            //}
            //
            //for (int i = 0; i < points.Length; i++)
            //{
            //    result.Vertices.Add(new Vector3d(points[i].X, 0, points[i].Y));
            //}
            //
            //result.Indices.Add(2 + 0 * 2);
            //result.Indices.Add(0 + 0 * 2);
            //result.Indices.Add(1 + 0 * 2);
            //result.Indices.Add(2 + 0 * 2);
            //result.Indices.Add(1 + 0 * 2);
            //result.Indices.Add(3 + 0 * 2);
            return(result);
        }
Exemple #28
0
        public override void UpdateEntityActionState()
        {
            base.UpdateEntityActionState();

            if (WorldObj.IsRemote)
            {
                return;
            }

            if (AllySummonCooldown > 0)
            {
                AllySummonCooldown--;

                if (AllySummonCooldown == 0)
                {
                    int  i    = MathHelper2.Floor_double(PosX);
                    int  k    = MathHelper2.Floor_double(PosY);
                    int  i1   = MathHelper2.Floor_double(PosZ);
                    bool flag = false;

                    for (int l1 = 0; !flag && l1 <= 5 && l1 >= -5; l1 = l1 > 0 ? 0 - l1 : 1 - l1)
                    {
                        for (int j2 = 0; !flag && j2 <= 10 && j2 >= -10; j2 = j2 > 0 ? 0 - j2 : 1 - j2)
                        {
                            for (int k2 = 0; !flag && k2 <= 10 && k2 >= -10; k2 = k2 > 0 ? 0 - k2 : 1 - k2)
                            {
                                int l2 = WorldObj.GetBlockId(i + j2, k + l1, i1 + k2);

                                if (l2 != Block.Silverfish.BlockID)
                                {
                                    continue;
                                }

                                WorldObj.PlayAuxSFX(2001, i + j2, k + l1, i1 + k2, Block.Silverfish.BlockID + (WorldObj.GetBlockMetadata(i + j2, k + l1, i1 + k2) << 12));
                                WorldObj.SetBlockWithNotify(i + j2, k + l1, i1 + k2, 0);
                                Block.Silverfish.OnBlockDestroyedByPlayer(WorldObj, i + j2, k + l1, i1 + k2, 0);

                                if (!Rand.NextBool())
                                {
                                    continue;
                                }

                                flag = true;
                                break;
                            }
                        }
                    }
                }
            }

            if (EntityToAttack == null && !HasPath())
            {
                int j  = MathHelper2.Floor_double(PosX);
                int l  = MathHelper2.Floor_double(PosY + 0.5D);
                int j1 = MathHelper2.Floor_double(PosZ);
                int k1 = Rand.Next(6);
                int i2 = WorldObj.GetBlockId(j + Facing.OffsetsXForSide[k1], l + Facing.OffsetsYForSide[k1], j1 + Facing.OffsetsZForSide[k1]);

                if (BlockSilverfish.GetPosingIdByMetadata(i2))
                {
                    WorldObj.SetBlockAndMetadataWithNotify(j + Facing.OffsetsXForSide[k1], l + Facing.OffsetsYForSide[k1], j1 + Facing.OffsetsZForSide[k1], Block.Silverfish.BlockID, BlockSilverfish.GetMetadataForBlockType(i2));
                    SpawnExplosionParticle();
                    SetDead();
                }
                else
                {
                    UpdateWanderPath();
                }
            }
            else if (EntityToAttack != null && !HasPath())
            {
                EntityToAttack = null;
            }
        }
        protected virtual bool Func_48376_a(EntityLiving par1EntityLiving, bool par2)
        {
            if (par1EntityLiving == null)
            {
                return(false);
            }

            if (par1EntityLiving == TaskOwner)
            {
                return(false);
            }

            if (!par1EntityLiving.IsEntityAlive())
            {
                return(false);
            }

            if (par1EntityLiving.BoundingBox.MaxY <= TaskOwner.BoundingBox.MinY || par1EntityLiving.BoundingBox.MinY >= TaskOwner.BoundingBox.MaxY)
            {
                return(false);
            }

            if (!TaskOwner.Func_48100_a(par1EntityLiving.GetType()))
            {
                return(false);
            }

            if ((TaskOwner is EntityTameable) && ((EntityTameable)TaskOwner).IsTamed())
            {
                if ((par1EntityLiving is EntityTameable) && ((EntityTameable)par1EntityLiving).IsTamed())
                {
                    return(false);
                }

                if (par1EntityLiving == ((EntityTameable)TaskOwner).GetOwner())
                {
                    return(false);
                }
            }
            else if ((par1EntityLiving is EntityPlayer) && !par2 && ((EntityPlayer)par1EntityLiving).Capabilities.DisableDamage)
            {
                return(false);
            }

            if (!TaskOwner.IsWithinHomeDistance(MathHelper2.Floor_double(par1EntityLiving.PosX), MathHelper2.Floor_double(par1EntityLiving.PosY), MathHelper2.Floor_double(par1EntityLiving.PosZ)))
            {
                return(false);
            }

            if (Field_48380_e && !TaskOwner.Func_48090_aM().CanSee(par1EntityLiving))
            {
                return(false);
            }

            if (Field_48383_a)
            {
                if (--Field_48377_f <= 0)
                {
                    Field_48381_b = 0;
                }

                if (Field_48381_b == 0)
                {
                    Field_48381_b = Func_48375_a(par1EntityLiving) ? 1 : 2;
                }

                if (Field_48381_b == 2)
                {
                    return(false);
                }
            }

            return(true);
        }