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); }
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; }
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); }
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 }); } } }
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; }
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); }
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); }
protected override void HandleCollisionsInternal(GameTime gameTime, CollisionCheckResult collisions) { throw new NotImplementedException(); }
protected override void HandleCollisionsInternal(GameTime gameTime, CollisionCheckResult collisions) { }
protected override void HandleCollisionsInternal(GameTime gameTime, CollisionCheckResult collisions) { Hit = collisions.HitImpassable; }
// custom method to do some extra work after the collision check protected override void UpdateEntityState(CollisionCheckResult result) { base.UpdateEntityState(result); _againstWall = result.XAxis; }