Cleanup, merge modules
This commit is contained in:
+21
-21
@@ -1,17 +1,17 @@
|
||||
module Dodge.Machine.Draw (drawMachine) where
|
||||
|
||||
import Dodge.Data.CWorld
|
||||
import Dodge.Terminal.Color
|
||||
import Control.Lens
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Dodge.Data.CWorld
|
||||
import Dodge.Item.Draw.SPic
|
||||
import Dodge.Item.HeldOffset
|
||||
import Dodge.Placement.TopDecoration
|
||||
import Dodge.Terminal.Color
|
||||
import Geometry
|
||||
import Picture
|
||||
import Shape
|
||||
import ShapePicture
|
||||
import qualified Data.Map.Strict as M
|
||||
|
||||
drawMachine :: CWorld -> Machine -> SPic
|
||||
drawMachine cw mc = case _mcType mc of
|
||||
@@ -24,18 +24,18 @@ drawMachine cw mc = case _mcType mc of
|
||||
lw = cw ^. lWorld
|
||||
gp = cw ^. cwGen . cwgParams . sensorCoding
|
||||
|
||||
drawDamSensor :: M.Map SensorType (PaletteColor, DecorationShape)
|
||||
-> DamageSensor -> Machine -> SPic
|
||||
drawDamSensor gp sens mc = --case sens of
|
||||
--DamSensor{_sensDraw = pcds} -> sensorSPic pcds
|
||||
fold $ do
|
||||
let st = sens ^. sensType
|
||||
x <- gp ^? ix st
|
||||
return $ sensorSPic x mc
|
||||
drawDamSensor ::
|
||||
M.Map SensorType (PaletteColor, DecorationShape) ->
|
||||
DamageSensor ->
|
||||
Machine ->
|
||||
SPic
|
||||
drawDamSensor gp sens mc = fold $ do
|
||||
let st = sens ^. sensType
|
||||
x <- gp ^? ix st
|
||||
return $ sensorSPic x mc
|
||||
|
||||
drawProxSensor :: ProximitySensor -> Machine -> SPic
|
||||
drawProxSensor sens = case sens of
|
||||
ProxSensor{} -> const mempty
|
||||
drawProxSensor _ = const mempty
|
||||
|
||||
terminalSPic :: LWorld -> Machine -> SPic
|
||||
terminalSPic lw = noPic . terminalShape lw
|
||||
@@ -56,14 +56,14 @@ terminalShape lw mc = fromMaybe mempty $ do
|
||||
<> screenbackground (getcol term)
|
||||
where
|
||||
getcol term = fromMaybe black $ termScreenColor term
|
||||
screenbackground col = colorSH
|
||||
col
|
||||
( prismBox
|
||||
Small
|
||||
Typical
|
||||
[V3 8 8 20, V3 (-8) 8 20, V3 0 (-8) 10]
|
||||
[V3 8 8 19, V3 (-8) 8 19, V3 0 (-8) 9]
|
||||
)
|
||||
screenbackground col =
|
||||
colorSH
|
||||
col
|
||||
$ prismBox
|
||||
Small
|
||||
Typical
|
||||
[V3 8 8 20, V3 (-8) 8 20, V3 0 (-8) 10]
|
||||
[V3 8 8 19, V3 (-8) 8 19, V3 0 (-8) 9]
|
||||
|
||||
drawBaseMachine :: Float -> Machine -> SPic
|
||||
drawBaseMachine h mc =
|
||||
|
||||
+10
-17
@@ -136,9 +136,9 @@ mcDamSensorUpdate :: DamageSensor -> Machine -> World -> World
|
||||
mcDamSensorUpdate se = senseDamage (_sensThreshold se) (_sensType se)
|
||||
|
||||
mcProxSensorUpdate :: ProximitySensor -> Machine -> World -> World
|
||||
mcProxSensorUpdate se mc = case se ^. proxRequirement of
|
||||
RequireNoItems xs -> mcNoItemsTest mc xs
|
||||
_ -> mcProximitySensorUpdate mc se
|
||||
mcProxSensorUpdate se mc = case se ^. proxSensorType of
|
||||
NoItemZone xs -> mcNoItemsTest mc xs
|
||||
SensorWithRequirement pr -> mcProximitySensorUpdate mc se pr
|
||||
|
||||
mcNoItemsTest :: Machine -> [Point2] -> World -> World
|
||||
mcNoItemsTest mc ps w
|
||||
@@ -158,10 +158,11 @@ mcNoItemsTest mc ps w
|
||||
qs = f ps
|
||||
f = fmap ((+ _mcPos mc) . rotateV (_mcDir mc))
|
||||
|
||||
mcProximitySensorUpdate :: Machine -> ProximitySensor -> World -> World
|
||||
mcProximitySensorUpdate mc sens w
|
||||
mcProximitySensorUpdate
|
||||
:: Machine -> ProximitySensor -> ProximityRequirement -> World -> World
|
||||
mcProximitySensorUpdate mc sens pr w
|
||||
| sens ^. proxToggle || dist (_crPos ycr) (_mcPos mc) > 40 = w
|
||||
| mcProxTest mc w (sens ^. proxRequirement) =
|
||||
| mcProxTest w pr =
|
||||
w
|
||||
& mcsenslens . proxToggle .~ True
|
||||
& playsound dedaS
|
||||
@@ -169,10 +170,7 @@ mcProximitySensorUpdate mc sens w
|
||||
| otherwise =
|
||||
w & playsound dedumS
|
||||
& mctermlens . tmFutureLines
|
||||
.:~ makeTermLine
|
||||
( "SENSOR FAIL: REQUIRES "
|
||||
++ sensorReqToString (mc ^?! mcType . _McProxSensor . proxRequirement)
|
||||
)
|
||||
.:~ makeTermLine ( "SENSOR FAIL: REQUIRES " ++ sensorReqToString pr)
|
||||
where
|
||||
mctermlens = cWorld . lWorld . terminals . ix (mc ^?! mcMounts . ix OTTerminal)
|
||||
mcsenslens = cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McProxSensor
|
||||
@@ -183,21 +181,16 @@ sensorReqToString :: ProximityRequirement -> String
|
||||
sensorReqToString = \case
|
||||
RequireHealth x -> "HEALTH ABOVE " ++ show x
|
||||
RequireEquipment x -> itemBaseName x
|
||||
RequireNoItems _ -> "NO NEARBY ITEMS"
|
||||
|
||||
mcProxTest :: Machine -> World -> ProximityRequirement -> Bool
|
||||
mcProxTest mc w = \case
|
||||
mcProxTest :: World -> ProximityRequirement -> Bool
|
||||
mcProxTest w = \case
|
||||
RequireHealth x -> _crHP cr >= x
|
||||
RequireEquipment ct ->
|
||||
any
|
||||
(\itm -> _itType itm == ct)
|
||||
((\k -> w ^?! cWorld . lWorld . items . ix k) <$> _crInv cr)
|
||||
RequireNoItems ps ->
|
||||
(w ^?! cWorld . lWorld . creatures . ix 0 . crInv == mempty)
|
||||
&& not (any ((`pointInPoly` f ps) . _flItPos) (w ^. cWorld . lWorld . floorItems))
|
||||
where
|
||||
cr = you w
|
||||
f = fmap ((+ _mcPos mc) . rotateV (_mcDir mc))
|
||||
|
||||
senseDamage :: Int -> SensorType -> Machine -> World -> World
|
||||
senseDamage threshold dt mc =
|
||||
|
||||
Reference in New Issue
Block a user