Exemple #1
0
        public override void Tick()
        {
            base.Tick();
            Camera.UpdateFromActor(this);

            if (state == null)
            {
                ObjFlags |= GameObjFlags.EuthanizeMe;
            }
            else if (stTime != -1 && --stTime <= 0)
            {
                if (state.Next != null)
                {
                    ChangeState(state.Next);
                }
                else
                {
                    GConsole.Debug.WriteLine("Actor tried to change to null state.");
                    stTime = -1;
                }
            }

            if (ObjFlags.HasFlag(GameObjFlags.EuthanizeMe))
            {
                return;
            }

            DoMovement();
            DoZMovement();

            Accum friction = GetFriction();

            vel.X *= ((Math.Abs(vel.X.Value) > MINVELOCITY) ? friction : Accum.Zero);
            vel.Y *= ((Math.Abs(vel.Y.Value) > MINVELOCITY) ? friction : Accum.Zero);

            if (bCylinder.X < Constants.CoordinatesMin || bCylinder.Y < Constants.CoordinatesMin || bCylinder.Z < Constants.CoordinatesMin ||
                bCylinder.X > Constants.CoordinatesMax || bCylinder.Y > Constants.CoordinatesMax || bCylinder.Z > Constants.CoordinatesMax)
            {
                this.Destroy();
            }

            if (!flags.HasFlag(ActorFlags.NoGravity) && gravity > 0 && bCylinder.Z > 0)
            {
                vel.Z -= ((flags & ActorFlags.NoInteraction) == ActorFlags.NoInteraction) ? GetLocalGravity() : GetGravity();
            }

            prevPos = bCylinder.Position;
        }