public override void MoveVExact(int move) { //base.MoveVExact(move); GetRiders(); HashSet <Actor> riders = new DynData <Solid>(this).Get <HashSet <Actor> >("riders"); Y += move; MoveStaticMovers(Vector2.UnitY * move); if (Collidable) { foreach (Actor entity in Scene.Tracker.GetEntities <Actor>()) { if (entity.AllowPushing) { bool collidable = entity.Collidable; entity.Collidable = true; if (!entity.TreatNaive && CollideCheck(entity, Position)) { foreach (Hitbox hitbox in Colliders) { if (hitbox.Collide(entity)) { float top = Y + hitbox.Top; float bottom = Y + hitbox.Bottom; int moveV = (move <= 0) ? (int)(top - entity.Bottom) : (int)(bottom - entity.Top); Collidable = false; entity.MoveVExact(moveV, entity.SquishCallback, this); entity.LiftSpeed = LiftSpeed; Collidable = true; } } } else if (riders.Contains(entity)) { Collidable = false; if (entity.TreatNaive) { entity.NaiveMove(Vector2.UnitY * move); } else { entity.MoveVExact(move); } entity.LiftSpeed = LiftSpeed; Collidable = true; } entity.Collidable = collidable; } } } riders.Clear(); }
/* * Check for every Hitbox in base.Colliders, so that * the player & other entities don't get sent to the ends of the group. */ public override void MoveHExact(int move) { //base.MoveHExact(move); GetRiders(); Player player = Scene.Tracker.GetEntity <Player>(); HashSet <Actor> riders = new DynData <Solid>(this).Get <HashSet <Actor> >("riders"); if (player != null && Input.MoveX.Value == Math.Sign(move) && Math.Sign(player.Speed.X) == Math.Sign(move) && !riders.Contains(player) && CollideCheck(player, Position + Vector2.UnitX * move - Vector2.UnitY)) { player.MoveV(1f); } X += move; MoveStaticMovers(Vector2.UnitX * move); if (Collidable) { foreach (Actor entity in Scene.Tracker.GetEntities <Actor>()) { if (entity.AllowPushing) { bool collidable = entity.Collidable; entity.Collidable = true; if (!entity.TreatNaive && CollideCheck(entity, Position)) { foreach (Hitbox hitbox in Colliders) { if (hitbox.Collide(entity)) { float left = X + hitbox.Left; float right = X + hitbox.Right; int moveH = (move <= 0) ? (int)(left - entity.Right) : (int)(right - entity.Left); Collidable = false; entity.MoveHExact(moveH, entity.SquishCallback, this); entity.LiftSpeed = LiftSpeed; Collidable = true; } } } else if (riders.Contains(entity)) { Collidable = false; if (entity.TreatNaive) { entity.NaiveMove(Vector2.UnitX * move); } else { entity.MoveHExact(move); } entity.LiftSpeed = LiftSpeed; Collidable = true; } entity.Collidable = collidable; } } } riders.Clear(); }