private void TestForPipe(PipeDirection d) { Vec2i blockpos = (Vec2i)(GetMiddle() / Block.BLOCK_SIZE); blockpos += PipeZone.GetVectorForDirection(d); List <Trigger> triggerlist = owner.getTriggerList(blockpos.X, blockpos.Y); if (triggerlist != null) { foreach (Trigger t in owner.getTriggerList(blockpos.X, blockpos.Y)) { if (t is PipeZone && (t as PipeZone).IsDirection(d) && (t as PipeZone).CanEnter()) { AddController(new PipePlayerController(this, d)); } } } }
public override void Update(KeyboardDevice keyboard) { PipeZone zone = GetUnderlyingZone(); if (zone == null) { if (hasConnected) { hasFinished = true; zone = GetUnderlyingZone(); } } else { hasConnected = true; if (!zone.IsDirection(direction)) { direction = zone.GetOneDirection(); } speed = zone.GetSpeed(); } Vec2d delta = PipeZone.GetVectorForDirection(direction); delta.SetLength(speed); if (direction == PipeDirection.SOUTH || direction == PipeDirection.NORTH) { double corr = GetXCorrection(); delta.X += Math.Min(Math.Abs(corr), Math.Abs(speed * PIPECORRECTION_SPEEDFACTOR)) * Math.Sign(corr); } if (direction == PipeDirection.EAST || direction == PipeDirection.WEST) { double corr = GetYCorrection(); delta.Y += Math.Min(Math.Abs(corr), Math.Abs(speed * PIPECORRECTION_SPEEDFACTOR)) * Math.Sign(corr); } ent.position += delta; ent.DoCollisions(); deltaCache = delta; }