// Token: 0x06000097 RID: 151 RVA: 0x0000891C File Offset: 0x00006B1C
        public void PutInsideOfTheWorld()
        {
            IntVector3 RealChunkIndex = Ground.ChunkIndexOfPosition(this.Position);
            bool       flag           = Loader.MaxWorldBorders.X <= RealChunkIndex.X;

            if (flag)
            {
                this.Position.X = (float)(checked (Loader.MaxWorldBorders.X * 8 * 50)) - 100f;
            }
            else
            {
                bool flag2 = RealChunkIndex.X <= Ground.CStack.ChunkRangeMin.X;
                if (flag2)
                {
                    this.Position.X = 500f;
                }
            }
            bool flag3 = Loader.MaxWorldBorders.Z <= RealChunkIndex.Z;

            if (flag3)
            {
                this.Position.Z = (float)(checked (Loader.MaxWorldBorders.Z * 8 * 50)) - 100f;
            }
            else
            {
                bool flag4 = RealChunkIndex.Z <= Ground.CStack.ChunkRangeMin.Z;
                if (flag4)
                {
                    this.Position.Z = 500f;
                }
            }
        }
        // Token: 0x06000095 RID: 149 RVA: 0x000087E8 File Offset: 0x000069E8
        public bool CheckOutOfStackRange()
        {
            IntVector3 RealChunkIndex = Ground.ChunkIndexOfPosition(this.Position);
            bool       flag           = Ground.CStack.ChunkRangeMax.Z <= RealChunkIndex.Z;
            bool       CheckOutOfStackRange;

            if (flag)
            {
                CheckOutOfStackRange = true;
            }
            else
            {
                bool flag2 = RealChunkIndex.Z <= Ground.CStack.ChunkRangeMin.Z;
                if (flag2)
                {
                    CheckOutOfStackRange = true;
                }
                else
                {
                    bool flag3 = Ground.CStack.ChunkRangeMax.X <= RealChunkIndex.X;
                    if (flag3)
                    {
                        CheckOutOfStackRange = true;
                    }
                    else
                    {
                        bool flag4 = RealChunkIndex.X <= Ground.CStack.ChunkRangeMin.X;
                        CheckOutOfStackRange = flag4;
                    }
                }
            }
            return(CheckOutOfStackRange);
        }
        // Token: 0x06000096 RID: 150 RVA: 0x00008894 File Offset: 0x00006A94
        public bool CheckOutOfWorld()
        {
            IntVector3 RealChunkIndex = Ground.ChunkIndexOfPosition(this.Position);
            bool       flag           = Loader.MaxWorldBorders.Z <= RealChunkIndex.Z;
            bool       CheckOutOfWorld;

            if (flag)
            {
                CheckOutOfWorld = true;
            }
            else
            {
                bool flag2 = RealChunkIndex.Z <= 0;
                if (flag2)
                {
                    CheckOutOfWorld = true;
                }
                else
                {
                    bool flag3 = Loader.MaxWorldBorders.X <= RealChunkIndex.X;
                    if (flag3)
                    {
                        CheckOutOfWorld = true;
                    }
                    else
                    {
                        bool flag4 = RealChunkIndex.X <= 0;
                        CheckOutOfWorld = flag4;
                    }
                }
            }
            return(CheckOutOfWorld);
        }
        /// <summary>
        /// Player Only
        /// </summary>
        // Token: 0x06000094 RID: 148 RVA: 0x0000866C File Offset: 0x0000686C
        public void ChunkOutOfStackRange()
        {
            IntVector3 RealChunkIndex = Ground.ChunkIndexOfPosition(this.Position);
            bool       BNotOutOfRange = true;
            bool       flag           = Ground.CStack.ChunkRangeMax.Z <= RealChunkIndex.Z;

            if (flag)
            {
                this.Position.Z = (float)(checked (Ground.CStack.ChunkRangeMax.Z * 400)) - 50f;
                BNotOutOfRange  = false;
            }
            else
            {
                bool flag2 = RealChunkIndex.Z <= Ground.CStack.ChunkRangeMin.Z;
                if (flag2)
                {
                    this.Position.Z = (float)(checked (Ground.CStack.ChunkRangeMin.Z * 400)) + 50f;
                    BNotOutOfRange  = false;
                }
            }
            bool flag3 = Ground.CStack.ChunkRangeMax.X <= RealChunkIndex.X;

            if (flag3)
            {
                this.Position.X = (float)(checked (Ground.CStack.ChunkRangeMax.X * 400)) - 50f;
                BNotOutOfRange  = false;
            }
            else
            {
                bool flag4 = RealChunkIndex.X <= Ground.CStack.ChunkRangeMin.X;
                if (flag4)
                {
                    this.Position.X = (float)(checked (Ground.CStack.ChunkRangeMin.X * 400)) + 50f;
                    BNotOutOfRange  = false;
                }
            }
            bool flag5 = BNotOutOfRange;

            if (flag5)
            {
                Loader.LoadAndReplaceChunkTempory(RealChunkIndex);
                this.Velocity *= -5f;
            }
            this.InRandomMovement = false;
        }
Exemple #5
0
        // Token: 0x0600013C RID: 316 RVA: 0x00011378 File Offset: 0x0000F578
        public override void Update()
        {
            bool flag = !this.IsDead;

            if (flag)
            {
                bool flag2 = !this.eType.IsPlayer && base.CheckOutOfStackRange();
                if (!flag2)
                {
                    this.Position += this.Velocity;
                    this.Velocity *= this.ModelVelocityReducingFactor;
                    bool flag3 = this.Velocity.LengthSquared() < 0.02f;
                    if (flag3)
                    {
                        this.Velocity = Vector3.Zero;
                    }
                    bool flag4 = base.CheckOutOfWorld();
                    if (flag4)
                    {
                        base.PutInsideOfTheWorld();
                    }
                    this.FacingDirection = this.HeadRotation.Forward;
                    this.FacingDirection.Normalize();
                    this.DualFacingDirections = Physics.Find2DDualDirectionsOfDirection(this.FacingDirection);
                    this.OnGround             = false;
                    this.BlockEnv             = Ground.GetBlockEnvironment(this.Position - Ground.BlockSizeHalfYonlyV3, true);
                    bool flag5 = Information.IsNothing(this.BlockEnv);
                    if (flag5)
                    {
                        base.ChunkOutOfStackRange();
                        this.BlockEnv = Ground.GetBlockEnvironment(this.Position - Ground.BlockSizeHalfYonlyV3, true);
                        bool flag6 = Information.IsNothing(this.BlockEnv);
                        if (flag6)
                        {
                            bool isPlayer = this.eType.IsPlayer;
                            if (!isPlayer)
                            {
                                return;
                            }
                            while (Information.IsNothing(this.BlockEnv))
                            {
                                base.ChunkOutOfStackRange();
                                this.BlockEnv = Ground.GetBlockEnvironment(this.Position - Ground.BlockSizeHalfYonlyV3, true);
                            }
                        }
                    }
                    this.CurrentBlock           = this.BlockEnv.CurrentBlock;
                    this.CurrentChunk           = this.CurrentBlock.Chunk;
                    this.DualFacingDirectionsFB = this.DualFacingDirections[0];
                    this.DualFacingDirectionsLR = this.DualFacingDirections[1];
                    bool flag7 = !this.BlockEnv.LegsBlock.IsAir;
                    if (flag7)
                    {
                        bool flag8 = this.TrappedCount > 10;
                        if (flag8)
                        {
                            this.Position.Y = this.Position.Y + 100f;
                            this.BodyParts[3].Hurten(20f);
                            this.TrappedCount = 0;
                            this.Update();
                            return;
                        }
                        checked
                        {
                            this.TrappedCount++;
                        }
                    }
                    else
                    {
                        this.TrappedCount = 0;
                    }
                    bool flag9 = !this.CurrentBlock.RealBlock.IsAir;
                    if (flag9)
                    {
                        this.Position.Y = (float)(checked ((this.CurrentBlock.Index * 50).Y + 50));
                        bool flag10 = this.Velocity.Y < -10f;
                        if (flag10)
                        {
                            this.BodyParts[4].Hurten(this.Velocity.Y * -2f);
                            this.BodyParts[0].Hurten(this.Velocity.Y * -2f);
                            checked
                            {
                                this.Health -= (int)Math.Round((double)(unchecked (this.Velocity.Y * -2f)));
                            }
                        }
                        this.FallingSpeed = 0f;
                    }
                    else
                    {
                        this.FallingSpeed += this.Weight;
                        this.Velocity.Y    = this.Velocity.Y - this.FallingSpeed;
                    }
                    bool flag11 = this.Velocity.Y < -10f;
                    if (flag11)
                    {
                        bool flag12 = Ground.GetIsAirDistanceInTheDirection(this.Position, Vector3.Down, -2, false) > 20;
                        if (flag12)
                        {
                            this.FallingSpeed           = 0f;
                            this.Velocity.Y             = 0f;
                            this.BlockEnv               = Ground.GetBlockEnvironment(this.Position - Ground.BlockSizeYonlyV3, false);
                            this.CurrentBlock           = this.BlockEnv.CurrentBlock;
                            this.DualFacingDirectionsFB = this.DualFacingDirections[0];
                            this.DualFacingDirectionsLR = this.DualFacingDirections[1];
                            this.DualFacingDirectionsFB = this.DualFacingDirections[0];
                            this.DualFacingDirectionsLR = this.DualFacingDirections[1];
                            this.CurrentChunk           = this.CurrentBlock.Chunk;
                            this.Position.Y             = (float)(checked ((this.CurrentBlock.Index * 50).Y + 50));
                            this.OnGround               = true;
                        }
                    }
                    bool isPlayer2 = this.eType.IsPlayer;
                    if (isPlayer2)
                    {
                        IntVector3 RealChunkIndex = Ground.ChunkIndexOfPosition(this.Position - Ground.BlockSizeYonlyV3);
                        bool       flag13         = this.CurrentChunk.Index.X != RealChunkIndex.X || this.CurrentChunk.Index.Z != RealChunkIndex.Z;
                        if (flag13)
                        {
                            base.CheckOutOfStackRange();
                        }
                    }
                    bool flag14 = !this.CurrentBlock.RealBlock.IsAir;
                    if (flag14)
                    {
                        this.OnGround = true;
                    }
                    bool movedFB = this.MovedFB;
                    if (movedFB)
                    {
                        this.ResumeWalking();
                    }
                    else
                    {
                        this.PuaseWalking();
                    }
                    this.MovedFB = false;
                    bool flag15 = !this.NoAI;
                    if (flag15)
                    {
                        bool flag16 = this.DelUpdateAI != null;
                        if (flag16)
                        {
                            this.DelUpdateAI(this);
                        }
                    }
                    bool neededBodyRotationChanged = this.NeededBodyRotationChanged;
                    if (neededBodyRotationChanged)
                    {
                        bool flag17 = this.ModelRotation.Forward != this.NeededBodyRotation.Forward;
                        if (flag17)
                        {
                            bool flag18 = Vector3.Distance(this.NeededBodyRotation.Forward, this.ModelRotation.Forward) > this.GetingTargetBodyRotationLast;
                            if (flag18)
                            {
                                bool getingTargetBodyRotationLastDir = this.GetingTargetBodyRotationLastDir;
                                if (getingTargetBodyRotationLastDir)
                                {
                                    this.GetingTargetBodyRotationLastDir = false;
                                }
                                else
                                {
                                    this.GetingTargetBodyRotationLastDir = true;
                                }
                            }
                            this.GetingTargetBodyRotationLast = Vector3.Distance(this.ModelRotation.Forward, this.NeededBodyRotation.Forward);
                            bool flag19 = !this.GetingTargetBodyRotationLastDir;
                            if (flag19)
                            {
                                this.RotationVelocity.Y = (float)((double)this.RotationVelocity.Y + (double)Vector3.Distance(this.NeededBodyRotation.Forward, this.ModelRotation.Forward) * 0.2);
                            }
                            else
                            {
                                this.RotationVelocity.Y = (float)((double)this.RotationVelocity.Y - (double)Vector3.Distance(this.NeededBodyRotation.Forward, this.ModelRotation.Forward) * 0.2);
                            }
                            bool flag20 = (double)Vector3.Distance(this.NeededBodyRotation.Forward, this.ModelRotation.Forward) < 0.001;
                            if (flag20)
                            {
                                this.NeededBodyRotationChanged = false;
                            }
                        }
                    }
                    base.RotationY      = MathHelper.WrapAngle(this.RotationVelocity.Y);
                    base.RotationX      = MathHelper.WrapAngle(this.RotationVelocity.X);
                    base.RotationZ      = MathHelper.WrapAngle(this.RotationVelocity.Z);
                    this.ModelRotation *= Matrix.Identity;
                    this.HeadRotation  *= Matrix.Identity;
                    bool flag21 = base.RotationY != 0f;
                    if (flag21)
                    {
                        this.ModelRotation *= Matrix.CreateFromAxisAngle(Vector3.Up, base.RotationY);
                    }
                    bool flag22 = base.RotationX != 0f;
                    if (flag22)
                    {
                        this.ModelRotation *= Matrix.CreateFromAxisAngle(this.ModelRotation.Right, base.RotationX);
                    }
                    bool flag23 = base.RotationZ != 0f;
                    if (flag23)
                    {
                        this.ModelRotation *= Matrix.CreateFromAxisAngle(this.ModelRotation.Forward, base.RotationZ);
                    }
                    this.ModelRotationY *= Matrix.CreateRotationY(base.RotationY);
                    Matrix RotationYCHange = Matrix.CreateFromAxisAngle(this.ModelRotation.Up, base.RotationY);
                    this.BodyParts[5].Rotation = this.HeadRotation;
                    this.BodyParts[3].Rotation = this.ModelRotation;
                    this.BodyParts[1].RotateAsChild(this.ModelRotation.Up, base.RotationY);
                    this.BodyParts[6].RotateAsChild(this.ModelRotation.Up, base.RotationY);
                    this.BodyParts[2].RotateAsChild(RotationYCHange);
                    this.BodyParts[7].RotateAsChild(RotationYCHange);
                    this.BodyParts[5].OriginalRotation = this.HeadRotation * this.BodyParts[5].DefualtRotation;
                    this.BodyParts[3].OriginalRotation = this.ModelRotation * this.BodyParts[3].DefualtRotation;
                    this.BodyParts[7].OriginalRotation = this.ModelRotation * this.BodyParts[7].DefualtRotation;
                    this.BodyParts[2].OriginalRotation = this.ModelRotation * this.BodyParts[2].DefualtRotation;
                    this.BodyParts[0].OriginalRotation = this.ModelRotation * this.BodyParts[0].DefualtRotation;
                    this.BodyParts[4].OriginalRotation = this.ModelRotation * this.BodyParts[4].DefualtRotation;
                    bool flag24 = !Information.IsNothing(this.CTool);
                    if (flag24)
                    {
                        this.CTool.Rotate(RotationYCHange);
                        this.CTool.Update();
                        this.CTool.OriginalRotation = this.CTool.DefualtRotation * this.ModelRotation;
                    }
                    this.FacingDirection = this.HeadRotation.Forward;
                    this.FacingDirection.Normalize();
                    this.CollitionHierarchy.UpdateAllSpheres(this.Position);
                    float MeWidthSq   = this.eType.Width * this.eType.Width * 2f;
                    bool  IsAttacking = this.CTool != null && this.CTool.Attacking;


                    foreach (Entity e in Ground.CStack.eList)
                    {
                        bool flag25 = e != this;
                        if (flag25)
                        {
                            bool flag26 = IsAttacking;
                            if (flag26)
                            {
                                eCollitionNode CN     = e.CollitionHierarchy.GetCollided(this.CTool.R, this.CTool.Length);
                                bool           flag27 = !Information.IsNothing(CN);
                                if (flag27)
                                {
                                    Vector3 Dir = e.Position - this.Position;
                                    Dir.Y = 0f;
                                    Dir.Normalize();
                                    this.CTool.RewardsToVictim.Reward(e, CN.RRewardMultiplier);
                                    CN.eP.Hurten((float)(checked (-1 * this.CTool.RewardsToVictim.Health)));
                                    Controls.Go(e, Dir, 15f);
                                    e.ShotHit(this);
                                }
                            }
                            float DistanceSquaredToE = Vector3.DistanceSquared(e.Position, this.Position);
                            bool  flag28             = DistanceSquaredToE < MeWidthSq;
                            if (flag28)
                            {
                                Vector3 Dir2 = (this.Position - e.Position) * Physics.YZero;
                                Controls.Go(this, Dir2, 0.1f);
                            }
                        }
                    }

                    base.RotationY          = 0f;
                    base.RotationX          = 0f;
                    base.RotationZ          = 0f;
                    this.RotationVelocity.Y = this.RotationVelocity.Y * this.RotationVelocityReducingFactor.Y;
                    this.RotationVelocity.X = this.RotationVelocity.X * this.RotationVelocityReducingFactor.X;
                    this.RotationVelocity.Z = this.RotationVelocity.Z * this.RotationVelocityReducingFactor.Z;
                    bool flag29 = this.Health < 1;
                    if (flag29)
                    {
                        this.Kill();
                    }
                }
            }
            else
            {
                base.RotationY = MathHelper.WrapAngle(this.RotationVelocity.Y);
                base.RotationX = MathHelper.WrapAngle(this.RotationVelocity.X);
                base.RotationZ = MathHelper.WrapAngle(this.RotationVelocity.Z);
                bool flag30 = base.RotationX != 0f;
                if (flag30)
                {
                    this.ModelRotation *= Matrix.CreateFromAxisAngle(this.ModelRotation.Right, base.RotationX);
                    Matrix RotationXCHange = Matrix.CreateFromAxisAngle(this.ModelRotation.Right, base.RotationX);
                    this.BodyParts[5].Rotation         = this.ModelRotation;
                    this.BodyParts[5].RelativePosition = Vector3.Transform(this.BodyParts[5].RelativePosition, RotationXCHange);
                    this.BodyParts[3].Rotation         = this.ModelRotation;
                    this.BodyParts[3].RelativePosition = Vector3.Transform(this.BodyParts[3].RelativePosition, RotationXCHange);
                    this.BodyParts[1].Rotation         = this.ModelRotation;
                    this.BodyParts[1].RelativePosition = Vector3.Transform(this.BodyParts[1].RelativePosition, RotationXCHange);
                    this.BodyParts[2].Rotation         = this.ModelRotation;
                    this.BodyParts[2].RelativePosition = Vector3.Transform(this.BodyParts[2].RelativePosition, RotationXCHange);
                    this.BodyParts[6].Rotation         = this.ModelRotation;
                    this.BodyParts[6].RelativePosition = Vector3.Transform(this.BodyParts[6].RelativePosition, RotationXCHange);
                    this.BodyParts[7].Rotation         = this.ModelRotation;
                    this.BodyParts[7].RelativePosition = Vector3.Transform(this.BodyParts[7].RelativePosition, RotationXCHange);
                    this.BodyParts[0].Rotation         = this.ModelRotation;
                    this.BodyParts[0].RelativePosition = Vector3.Transform(this.BodyParts[0].RelativePosition, RotationXCHange);
                    this.BodyParts[4].Rotation         = this.ModelRotation;
                    this.BodyParts[4].RelativePosition = Vector3.Transform(this.BodyParts[4].RelativePosition, RotationXCHange);
                    bool flag31 = this.CTool != null;
                    if (flag31)
                    {
                        this.CTool.Rotation         = this.ModelRotation;
                        this.CTool.RelativePosition = Vector3.Transform(this.CTool.RelativePosition, RotationXCHange);
                    }
                    base.RotationY          = 0f;
                    base.RotationX          = 0f;
                    base.RotationZ          = 0f;
                    this.RotationVelocity.Y = this.RotationVelocity.Y * 0.95f;
                    this.RotationVelocity.X = this.RotationVelocity.X * 0.95f;
                    this.RotationVelocity.Z = this.RotationVelocity.Z * 0.95f;
                }
            }
        }