Start refactor storing items in single intmap, done turrets
More checks required
This commit is contained in:
@@ -20,9 +20,11 @@ destroyMachine mc =
|
||||
. destroyMcType (mc ^. mcType) mc
|
||||
|
||||
destroyMcType :: MachineType -> Machine -> World -> World
|
||||
destroyMcType mt mc = case mt of
|
||||
McTurret tu -> copyItemToFloor (_mcPos mc) (_tuWeapon tu)
|
||||
_ -> id
|
||||
destroyMcType mt mc w = case mt of
|
||||
McTurret tu -> fromMaybe w $ do
|
||||
itm <- w ^? cWorld . lWorld . items . ix (tu ^. tuWeapon)
|
||||
return $ copyItemToFloor (_mcPos mc) itm w
|
||||
_ -> w
|
||||
|
||||
mcKillTerm :: Machine -> World -> World
|
||||
mcKillTerm mc w = fromMaybe w $ do
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
module Dodge.Machine.Draw (
|
||||
drawMachine,
|
||||
) where
|
||||
module Dodge.Machine.Draw ( drawMachine) where
|
||||
|
||||
import Dodge.Terminal.Color
|
||||
import Control.Lens
|
||||
@@ -18,7 +16,7 @@ drawMachine :: LWorld -> Machine -> SPic
|
||||
drawMachine lw mc = case _mcType mc of
|
||||
McStatic -> mempty
|
||||
McTerminal -> terminalSPic lw mc
|
||||
McTurret tu -> drawBaseMachine 20 mc <> drawTurret tu mc
|
||||
McTurret tu -> drawBaseMachine 20 mc <> drawTurret lw tu mc
|
||||
McSensor se -> drawBaseMachine 25 mc <> drawSensor se mc
|
||||
|
||||
drawSensor :: Sensor -> Machine -> SPic
|
||||
@@ -62,10 +60,10 @@ drawBaseMachine h mc =
|
||||
. square
|
||||
$ _mcWidth mc
|
||||
|
||||
drawTurret :: Turret -> Machine -> SPic
|
||||
drawTurret tu mc = overPosSP (turretItemOffset itm tu mc) (itemSPic itm)
|
||||
where
|
||||
itm = _tuWeapon tu
|
||||
drawTurret :: LWorld -> Turret -> Machine -> SPic
|
||||
drawTurret lw tu mc = fold $ do
|
||||
itm <- lw ^? items . ix (tu ^. tuWeapon)
|
||||
return $ overPosSP (turretItemOffset itm tu mc) (itemSPic itm)
|
||||
|
||||
sensorSPic :: (PaletteColor, DecorationShape) -> Machine -> SPic
|
||||
sensorSPic (pc, ds) mc =
|
||||
|
||||
@@ -83,12 +83,13 @@ isElectrical dm = case dm of
|
||||
_ -> False
|
||||
|
||||
mcUseItem :: Machine -> World -> World
|
||||
mcUseItem mc = fromMaybe id $ do
|
||||
mcUseItem mc w = fromMaybe w $ do
|
||||
tu <- mc ^? mcType . _McTurret
|
||||
let it = tu ^. tuWeapon
|
||||
let i = tu ^. tuWeapon
|
||||
it <- w ^? cWorld . lWorld . items . ix i
|
||||
hit <- it ^? itType
|
||||
guard (_tuFireTime tu > 0)
|
||||
return $ mcUseHeld hit it mc
|
||||
return $ mcUseHeld hit it mc w
|
||||
|
||||
mcSensorTriggerUpdate :: Sensor -> Machine -> World -> World
|
||||
mcSensorTriggerUpdate se mc = fromMaybe id $ do
|
||||
|
||||
Reference in New Issue
Block a user