From fcac897ffb3f38941a748f532f9e103a0ac580cf Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 20 Mar 2021 22:58:21 +0000 Subject: [PATCH] PieceMoveable: Move calculation into a method on GPiece Signed-off-by: Ian Jackson --- src/gamestate.rs | 5 +++++ src/pcrender.rs | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gamestate.rs b/src/gamestate.rs index c5c861d8..fc2a98a7 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -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 { diff --git a/src/pcrender.rs b/src/pcrender.rs index 2d1ef7e0..77e9a0f2 100644 --- a/src/pcrender.rs +++ b/src/pcrender.rs @@ -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 -- 2.30.2