public int OnPipeExit(Ray posDir, int amount) { var pos = posDir.FirstPos; var toSet = Math.Min(amount, 1000); var existingBlock = World.GetBlock(pos); if (!(existingBlock is EmptyBlock) && !(existingBlock is WaterBlock)) { return(0); } // Set the existing block if it's there, or add a new block. if (existingBlock is EmptyBlock) { existingBlock = World.SetBlock(typeof(WaterBlock), pos, toSet * 0.001f) as WaterBlock; } var waterBlock = existingBlock as WaterBlock; if (waterBlock.Water < toSet) { waterBlock.Water = toSet; World.WakeUp(pos); } waterBlock.PipeSupplied = true; return(toSet); }
public float OnPipeExit(Ray posDir, float amount) { var existingBlock = World.GetBlock(posDir.FirstPos) as EmptyBlock; if (existingBlock != null) { var target = World.FindPyramidPos(posDir.FirstPos); World.SetBlock(this.OriginType, target); return(1); } return(0); }
public int OnPipeExit(Ray posDir, int amount) { // need a pyramid check, but for now just do down var existingBlock = World.GetBlock(posDir.FirstPos) as EmptyBlock; if (existingBlock != null) { var target = World.FindPyramidPos(posDir.FirstPos); World.SetBlock(this.OriginType, target); return(1); } return(0); }
public float OnPipeExit(Ray posDir, float amount) { var pos = posDir.FirstPos + Vector3i.Down; var existingBlock = World.GetBlock(pos); var waterOuput = Mathf.Min((amount / WorldObjectManager.TickDeltaTime) / 1000f, .999f); // Set the existing block if it's there, or add a new block. if (existingBlock is EmptyBlock) { World.SetBlock(typeof(WaterBlock), pos, waterOuput, true); } else if (existingBlock is WaterBlock) { (existingBlock as WaterBlock).Water = waterOuput; (existingBlock as WaterBlock).PipeSupplied = true; } return(amount); }
public Collision CheckCollision(ICollidable collider) { if (collider is World.World) { World.World world = (World.World)collider; int sx = (int)this.BoundingBox.Min.X - 1, ex = (int)this.BoundingBox.Max.X + 1, sy = (int)this.BoundingBox.Min.Y - 1, ey = (int)this.BoundingBox.Max.Y + 1, sz = (int)this.BoundingBox.Min.Z - 1, ez = (int)this.BoundingBox.Max.Z + 1; for (int z = sz; z <= ez; z++) { for (int y = sy; y <= ey; y++) { for (int x = sx; x <= ex; x++) { Collision collision; if (!(world[x, y, z] is BlockAir) && (collision = Game.CollisionManager.GetCollision(world.GetBlock(x, y, z), this)) != null) { return(collision); } } } } return(null); } return(new Collision(collider)); }