let (region, views) = (||{
dbgc!("claiming region");
let region = self.shape.outline.region(gpc.pos)?;
+ let displace = OccDisplacement::Rect { area: region };
let views = OwnerOccultationView {
owner: player,
owner_view: OccK::Visible,
- defview: OccK::Displaced((region, gpc.zlevel.z.clone())),
+ defview: OccK::Displaced((displace, gpc.zlevel.z.clone())),
}.views()?;
dbgc!("claiming got region", ®ion, &views);
Ok::<_,IE>((region, views))
Displaced(D),
Invisible,
}
-pub type OccultationKind = OccultationKindGeneral<(Area, ZCoord)>;
+pub type OccultationKind = OccultationKindGeneral<(OccDisplacement,ZCoord)>;
+
+#[derive(Clone,Debug,Serialize,Deserialize)]
+#[derive(Eq,PartialEq,Hash)]
+pub enum OccDisplacement {
+ Rect {
+ area: Area,
+ },
+}
impl PieceOccult {
pub fn is_active(&self) -> bool { self.active.is_some() }
if let Some(zg) = occultation.notch_zg(notch);
then {
occultation.views.get_kind(player)
- .map_displaced(|(area, z)| {
- let x: Coord = (notch.index() % 3).try_into().unwrap(); // xxx
- let pos = (area.0[0] + PosC([x*4, 0])).unwrap(); // xxx
- let pos = (pos + PosC([5,5])).unwrap(); // xxx
- let z = z.plus_offset(notch.into())
+ .map_displaced(|(displace, z)| {
+ let notch: NotchNumber = notch.into();
+ let pos = displace.place(notch);
+ let z = z.plus_offset(notch)
.unwrap_or_else(|e| { // eek!
error!("z coordinate overflow ({:?}), bodging! {:?} {:?}",
e, piece, &z);
Some(PieceRenderInstructions { vpid, occulted })
}
+impl OccDisplacement {
+ fn place(&self, notch: NotchNumber) -> Pos {
+ use OccDisplacement as OD;
+ match self {
+ OD::Rect{area} => {
+ let x: Coord = (notch % 3).try_into().unwrap(); // xxx
+ let pos = (area.0[0] + PosC([x*4, 0])).unwrap(); // xxx
+ let pos = (pos + PosC([5,5])).unwrap(); // xxx
+ pos
+ },
+ }
+ }
+}
+
impl ShowUnocculted {
/// override
pub const fn new_visible() -> ShowUnocculted {