chiark / gitweb /
updates: Provide facehint in PreparedUpdateEntry
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 1 Apr 2021 11:40:02 +0000 (12:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 2 Apr 2021 15:16:29 +0000 (16:16 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/pcrender.rs
src/updates.rs

index f5c889a07e16a68d8cfa085677e5e3e08020598d..2e1fa00d5ee02bc0c7bf589c2aa5fa2a232a88bc 100644 (file)
@@ -129,6 +129,7 @@ impl PieceRenderInstructions {
       pinned     : gpc.pinned,
       uos        : pri.ui_operations(gs, gpc, ipc)?,
       moveable   : gpc.moveable(),
+      facehint   : pri.facehint(gpc),
       occregion,
     };
     dbgc!(pri, ipc, gpc, r);
@@ -155,6 +156,13 @@ impl PieceRenderInstructions {
     }
   }
 
+  pub fn facehint(&self, gpc: &GPiece) -> Option<FaceId> {
+    match self.occulted {
+      PriOcculted::Visible(_)                            => Some(gpc.face),
+      PriOcculted::Occulted | PriOcculted::Displaced(..) => None,
+    }
+  }
+
   pub fn pos_zlevel<'r>(&'r self, gpc: &'r GPiece) -> (Pos, &'r ZLevel) {
     use PriOcculted as PO;
     match &self.occulted {
index 61e9509a55baee801154ad850288d16188a92d99..830f3bb2e22305fac55d3ad0f6ae27fd217986da 100644 (file)
@@ -100,6 +100,7 @@ pub struct PreparedPieceUpdateGeneral<U> {
 pub struct PreparedPieceState {
   pub pos: Pos,
   pub svg: Html,
+  pub facehint: Option<FaceId>,
   pub held: Option<PlayerId>,
   pub z: ZCoord,
   pub zg: Generation,