delegate! {
to self.surround_outline {
+ // see also PieceTraitbbox_preview (below, which would noormally
+ // ccall this, but we override it.
fn bbox_approx(&self) -> Result<Rect, IE>;
fn shape(&self) -> Option<Shape>;
}
)?)
//.map_err(|e| internal_error_bydebug(&e))?
}
+
+ // This is not consistent with the surround_path: the surround_path
+ // does not include the cooldown circle, but this does.
+ //
+ // OutlineTrait::bbox_approx is used in lots of places, eg
+ //
+ // * Pieces are added with the CLI. (Size also returned via ListPieces.)
+ // * "Organise" function.
+ // * Finding pieces that have been clicked on in the client.
+ // etc.
+ //
+ // So we have to have a different entrypoint for just this:
+ #[throws(IE)]
+ fn bbox_preview(&self) -> Rect {
+ let r: Coord = cast(self.cooldown_radius.ceil())
+ .ok_or(CoordinateOverflow)?;
+ let br = PosC::new(r,r);
+ let tl = (-br)?;
+ Rect{ corners: [tl,br] }
+ }
}
#[typetag::serde(name="Die")]
fn loaded_hook_preview(&self, _gpc: &mut GPiece) -> Result<(),IE> {
Ok(())
}
+ // Specialised by dice.rs.
+ fn bbox_preview(&self) -> Result<Rect, IE> { self.bbox_approx() }
/// Not called if the whole game is destroyed.
/// You can use Drop of course but it's not usually much use since
pub use nix::sys::time::TimeSpec;
pub use nix::time::clock_gettime;
pub use num_derive::{ToPrimitive, FromPrimitive};
-pub use num_traits::{Bounded, FromPrimitive, ToPrimitive};
+pub use num_traits::{cast, Bounded, FromPrimitive, ToPrimitive};
pub use paste::paste;
pub use rand::distributions::Alphanumeric;
pub use rand::thread_rng;