chiark / gitweb /
PieceMoveable: Move calculation into a method on GPiece
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 22:58:21 +0000 (22:58 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 22:58:21 +0000 (22:58 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/gamestate.rs
src/pcrender.rs

index c5c861d8d9cd1fcc0e0ffa05c1d6aafd92483d26..fc2a98a75d55f84ab387a7f8d8224f65b3b231f1 100644 (file)
@@ -314,6 +314,11 @@ impl GPiece {
     self.xdata.get_mut_exp()?
   }
 
+  pub fn moveable(&self) -> PieceMoveable {
+    if self.occult.is_active() { PieceMoveable::No }
+    else { self.moveable }
+  }
+
   pub fn dummy() -> Self {
     let gen_dummy = Generation(1);
     GPiece {
index 2d1ef7e0ba8d0c535ecd07d3aafbd3154a8e8cc6..77e9a0f25fd9ce55cf67359197af117e2484b28e 100644 (file)
@@ -115,8 +115,6 @@ impl PieceRenderInstructions {
                          -> PreparedPieceState {
     let pri = self;
     let (pos, zlevel) = pri.pos_zlevel(gpc);
-    let moveable = if gpc.occult.is_active() { PieceMoveable::No }
-                   else { gpc.moveable };
     let r = PreparedPieceState {
       pos        : pos,
       held       : gpc.held,
@@ -126,7 +124,7 @@ impl PieceRenderInstructions {
       angle      : pri.angle(gpc).to_compass(),
       pinned     : gpc.pinned,
       uos        : pri.ui_operations(gs, gpc, ipc)?,
-      moveable,
+      moveable   : gpc.moveable(),
     };
     dbgc!(pri, ipc, gpc, r);
     r