pub occulted: PriOcculted,
}
-#[derive(Debug,Clone,Copy)]
-pub enum PriOcculted { Visible, Occulted, Displaced(Pos) }
+#[derive(Debug,Clone)]
+pub enum PriOcculted { Visible, Occulted, Displaced(Pos, ZLevel) }
impl PieceRenderInstructions {
pub fn new_visible(vpid: VisiblePieceId) -> PieceRenderInstructions {
-> Option<&'p dyn OccultedPieceTrait>
{
match self.occulted {
- PriOcculted::Visible => None,
- PriOcculted::Occulted | PriOcculted::Displaced(_) => {
+ PriOcculted::Visible => None,
+ PriOcculted::Occulted | PriOcculted::Displaced(..) => {
Some({
let occilk = p.occilk.as_ref()
.ok_or_else(|| internal_logic_error(format!(
pub fn angle(&self, gpc: &GPiece) -> VisiblePieceAngle {
match self.occulted {
- PriOcculted::Visible => gpc.angle,
- PriOcculted::Occulted | PriOcculted::Displaced(_) => default(),
+ PriOcculted::Visible => gpc.angle,
+ PriOcculted::Occulted | PriOcculted::Displaced(..) => default(),
}
}
-> Vec<UoDescription>
{
match self.occulted {
- PriOcculted::Visible => (),
- PriOcculted::Occulted | PriOcculted::Displaced(_) => return vec![],
+ PriOcculted::Visible => (),
+ PriOcculted::Occulted | PriOcculted::Displaced(..) => return vec![],
};
type WRC = WhatResponseToClientOp;
// kept in synch with Occultation::pieces
pub struct PieceOccult {
active: Option<OccId>, // kept in synch with Occultation::occulter
- passive: Option<(OccId, Notch)>, // kept in synch with Occultation::pieces
+ passive: Option<(OccId, Notch, Generation)>, // kept in synch with Occultation::pieces
}
#[derive(Clone,Debug,Serialize,Deserialize)]
Displaced(D),
Invisible,
}
-pub type OccultationKind = OccultationKindGeneral<Area>;
+pub type OccultationKind = OccultationKindGeneral<(Area, ZCoord)>;
impl Default for OccultationKind {
fn default() -> Self { OccK::Visible }
pub struct Notch = NotchNumber;
}
+ impl From<Notch> for u32 {
+ fn from(n: Notch) -> u32 { n.index().try_into().unwrap() }
+ }
+
type NotchPtr = Option<Notch>;
#[derive(Clone,Copy,Debug,Serialize,Deserialize)]
) -> Option<PieceRenderInstructions>
{
let occk = if_chain! {
- if let Some((occid, notch)) = gpc.occult.passive;
+ if let Some((occid, notch, zg)) = gpc.occult.passive;
if let Some(occultation) = occults.occults.get(occid);
then {
occultation.views.get_kind(player)
- .map_displaced(|area| {
+ .map_displaced(|(area, z)| {
let x: Coord = notch.index().try_into().unwrap(); // xxx
- let pos = area.0[0] + PosC([x*2, 0]); // xxx
- pos.unwrap()
+ let pos = (area.0[0] + PosC([x*2, 0])).unwrap(); // xxx
+ let z = z.plus_offset(notch.into())
+ .unwrap_or_else(|e| { // eek!
+ error!("z coordinate overflow ({:?}), bodging! {:?} {:?}",
+ e, piece, &z);
+ z.clone()
+ });
+ (pos, ZLevel { z, zg })
})
}
else {
}
};
+ let occk_dbg = occk.map_displaced(|(pos,z)|(*pos,z.zg));
let occulted = match occk {
OccKG::Invisible => {
trace_dbg!("piece_pri", player, piece, occk, gpc);
return None;
}
- OccKG::Visible => PriOcculted::Visible,
- OccKG::Scrambled => PriOcculted::Occulted,
- OccKG::Displaced(pos) => PriOcculted::Displaced(pos),
+ OccKG::Visible => PriOcculted::Visible,
+ OccKG::Scrambled => PriOcculted::Occulted,
+ OccKG::Displaced((pos,z)) => PriOcculted::Displaced(pos, z),
};
let vpid = gpl.idmap.fwd_or_insert(piece);
- trace_dbg!("piece_pri", player, piece, occk, vpid, occulted, gpc);
+ trace_dbg!("piece_pri", player, piece, occk_dbg, vpid, occulted, gpc);
Some(PieceRenderInstructions { vpid, occulted })
}
inner(ioccults, occults, player, gpl, piece, gpc, ipc)
let occulteds = OldNewOcculteds {
old:
- gpc.occult.passive.map(|(occid, notch)| Ok::<_,IE>((
+ gpc.occult.passive.map(|(occid, notch, _zg)| Ok::<_,IE>((
Occulted {
occid,
occ: goccults.occults.get(occid).ok_or_else(
.unwrap()
};
let passive = if let Some(occid) = occulteds.new {
+ let zg = gen.next();
let notch = notches(goccults, occid)
- .insert(gen.next(), piece);
- Some((occid, notch))
+ .insert(zg, piece);
+ Some((occid, notch, zg))
} else {
None
};
#[must_use]
pub struct NascentOccultation(Occultation);
-#[derive(Debug,Copy,Clone)]
+#[derive(Debug,Clone)]
pub struct UniformOccultationView(
- pub OccultationKind
+ pub OccultationKind,
);
-#[derive(Debug,Copy,Clone)]
+#[derive(Debug,Clone)]
pub struct OwnerOccultationView {
pub defview: OccultationKind,
pub owner: PlayerId,