Example #1
0
        public bool RequestVelocityCheckCollisions()
        {
            if (RAI_SessionCore.IsServer == false || this.UseCollisionDetection == false)
            {
                this.VelocityResult = new CollisionCheckResult(false);
                return(false);
            }

            if (this.CubeGrid.Physics == null || this.CubeGrid.IsStatic == true)
            {
                this.VelocityResult = new CollisionCheckResult(false);
                return(false);
            }

            if (this.CubeGrid.Physics.LinearVelocity.Length() < 0.1f)
            {
                this.VelocityResult = new CollisionCheckResult(false);
                return(false);
            }

            this.RemoteControlPosition = RemoteControl.GetPosition();
            this.GridVelocity          = this.CubeGrid.Physics.LinearVelocity;
            return(true);
            //MyAPIGateway.Parallel.Start(CheckVelocityCollisionsThreaded, VelocityCollisionCheckFinish);
        }
Example #2
0
        protected override void HandleCollisionsInternal(GameTime gameTime, CollisionCheckResult collisions)
        {
            IsOnGround = collisions.IsOnGround;

            // If the collision stopped us from moving, reset the velocity to zero.
            if (Position.X == collisions.PositionBeforeUpdate.X)
            {
                Velocity.X = 0;
            }

            if (Position.Y == collisions.PositionBeforeUpdate.Y)
            {
                Velocity.Y = 0;
            }

            if (!IsDead && IsOnGround)
            {
                if (Math.Abs(Velocity.X) - 0.02f > 0)
                {
                    //TODO run
                    _botAnimation.PlayAnimation(_lowerIdle);
                    _topAnimation.PlayAnimation(_upperIdle);
                }
                else
                {
                    _botAnimation.PlayAnimation(_lowerIdle);
                    _topAnimation.PlayAnimation(_upperIdle);
                }
            }

            // Clear input.
            movement  = 0.0f;
            isJumping = false;
            isFiring  = false;
        }
Example #3
0
 private void SetDirectionalChecksToNoCollision()
 {
     this.ForwardResult  = new CollisionCheckResult(false);
     this.BackwardResult = new CollisionCheckResult(false);
     this.UpResult       = new CollisionCheckResult(false);
     this.DownResult     = new CollisionCheckResult(false);
     this.LeftResult     = new CollisionCheckResult(false);
     this.RightResult    = new CollisionCheckResult(false);
 }
Example #4
0
        protected override void HandleCollisionsInternal(GameTime gameTime, CollisionCheckResult collisions)
        {
            if (collisions.HitImpassable)
            {
                //_engine.ExplosionMaster.AddExplosion(Explosion,gameTime);
                Kill();

                if (collisions.CollidedObject != null)                 //if what we hit isn't just a tile or screen border
                {
                    //TODO USE ROTATION
                    collisions.CollidedObject.OnGotHit(new HitData {
                        Rotation = Rotation, HitPosition = Position, HitTime = gameTime, Damage = 1
                    });
                }
            }
        }
Example #5
0
        protected virtual void UpdateEntityState(CollisionCheckResult result)
        {
            IsStanding = false;
            if (result.YAxis)
            {
                IsStanding = Velocity.Y > 0;
                Velocity   = new Vector2(Velocity.X, 0);
            }

            if (result.XAxis)
            {
                Velocity = new Vector2(0, Velocity.Y);
            }

            Position = result.Position;
        }
Example #6
0
        public void CheckPotentialEvasionCollisionThreaded(Vector3D direction, double distance)
        {
            if (RAI_SessionCore.IsServer == false || this.UseCollisionDetection == false)
            {
                this.EvasionResult = new CollisionCheckResult(false);
                return;
            }

            if (this.RemoteControl.SlimBlock.CubeGrid.Physics == null || this.RemoteControl.SlimBlock.CubeGrid.IsStatic == true)
            {
                this.EvasionResult = new CollisionCheckResult(false);
                return;
            }

            Logger.MsgDebug("Potential Evasion Collision Check", DebugTypeEnum.Dev);

            //this.EvasionResult = TargetHelper.CheckCollisions((IMyTerminalBlock)this.RemoteControl, direction, distance, 0, this.CollisionTimeTrigger, this.UseVoxelDetection, this.UseGridDetection, this.UseSafeZoneDetection, this.UseDefenseShieldDetection, this.UsePlayerDetection);
        }
Example #7
0
        public CollisionSystem(IMyRemoteControl remoteControl = null)
        {
            //General

            RemoteControl         = null;
            RemoteControlPosition = Vector3D.Zero;
            RemoteMaxtrix         = MatrixD.Identity;
            GridVelocity          = Vector3.Zero;
            CubeGrid = null;

            //Detect Settings
            UseCollisionDetection            = true;
            UseVoxelDetection                = true;
            UseGridDetection                 = true;
            UseSafeZoneDetection             = true;
            UseDefenseShieldDetection        = true;
            UsePlayerDetection               = false;
            CollisionVelocityCheckDistance   = 600;
            CollisionDirectionsCheckDistance = 150;
            CollisionTimeTrigger             = 5;

            //Results
            VelocityResult = new CollisionCheckResult(false);
            EvasionResult  = new CollisionCheckResult(false);
            ForwardResult  = new CollisionCheckResult(false);
            BackwardResult = new CollisionCheckResult(false);
            UpResult       = new CollisionCheckResult(false);
            DownResult     = new CollisionCheckResult(false);
            LeftResult     = new CollisionCheckResult(false);
            RightResult    = new CollisionCheckResult(false);

            //Voxel Results


            //Planet
            Planet    = null;
            InGravity = false;

            Setup(remoteControl);
        }
Example #8
0
 protected override void HandleCollisionsInternal(GameTime gameTime, CollisionCheckResult collisions)
 {
     throw new NotImplementedException();
 }
Example #9
0
 protected override void HandleCollisionsInternal(GameTime gameTime, CollisionCheckResult collisions)
 {
 }
Example #10
0
 protected override void HandleCollisionsInternal(GameTime gameTime, CollisionCheckResult collisions)
 {
     Hit = collisions.HitImpassable;
 }
Example #11
0
        // custom method to do some extra work after the collision check
        protected override void UpdateEntityState(CollisionCheckResult result)
        {
            base.UpdateEntityState(result);

            _againstWall = result.XAxis;
        }