Simplify analyser terminal

This commit is contained in:
2025-09-01 23:24:11 +01:00
parent cbcc7e4fd6
commit 8398f0b852
18 changed files with 246 additions and 188 deletions
+29 -17
View File
@@ -1,9 +1,7 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Machine.Update (
updateMachine,
) where
import Dodge.Terminal.Color
module Dodge.Machine.Update (updateMachine) where
import Control.Monad
import Data.List (partition)
import Data.Maybe
@@ -11,9 +9,12 @@ import Dodge.Base.Collide
import Dodge.Base.You
import Dodge.Data.World
import Dodge.HeldUse
import Dodge.Item.Display
import Dodge.Machine.Destroy
import Dodge.Movement.Turn
import Dodge.SoundLogic
import Dodge.Terminal
import Dodge.Terminal.Color
import Geometry
import LensHelp
@@ -40,6 +41,7 @@ terminalScreenGlow mc w = fromMaybe w $ do
return $
w & cWorld . lWorld . lights
.:~ LSParam (_mcPos mc `v2z` 20) 30 (V3 x y z)
-- w & cWorld . lWorld . tempLightSources
-- .:~ TLS
-- { _tlsParam = LSParam (_mcPos mc `v2z` 20) 30 (V3 x y z)
@@ -140,21 +142,32 @@ mcProximitySensorUpdate mc w = case ( _proxStatus sens
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . sensToggle .~ True
& playsound dedaS
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ IsClose
& cWorld . lWorld . terminals . ix (mc ^?! mcMounts . ix OTTerminal) . tmFutureLines .:~ makeTermLine "SENSOR SUCCESS!"
(NotClose, _, False, True) ->
w & playsound dedumS
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ IsClose
(_, _, _, False) -> w & cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ NotClose
(_, _, _, False) ->
w & cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ NotClose
& cWorld . lWorld . terminals . ix (mc ^?! mcMounts . ix OTTerminal) . tmFutureLines
.:~ makeTermLine ("SENSOR FAIL: REQUIRES " ++ sensorReqToString (mc ^?! mcType . _McSensor . proxRequirement))
_ -> w
where
playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing
ycr = you w
sens = mc ^?! mcType . _McSensor
sensorReqToString :: ProximityRequirement -> String
sensorReqToString = \case
RequireHealth x -> "HEALTH ABOVE " ++ show x
RequireEquipment x -> itemBaseName x
mcProxTest :: Machine -> World -> Bool
mcProxTest mc w = case mc ^? mcType . _McSensor . proxRequirement of
Just (RequireHealth x) -> _crHP cr >= x
Just (RequireEquipment ct) -> any (\itm -> _itType itm == ct)
((\k -> w ^?! cWorld . lWorld . items . ix k) <$> _crInv cr)
Just (RequireEquipment ct) ->
any
(\itm -> _itType itm == ct)
((\k -> w ^?! cWorld . lWorld . items . ix k) <$> _crInv cr)
_ -> False
where
cr = you w
@@ -179,24 +192,23 @@ senseDamage threshold dt mc =
sensorTypeDamages :: SensorType -> Damage -> Bool
sensorTypeDamages = \case
LaserSensor -> \case
LaserSensor -> \case
Lasering{} -> True
_ -> False
ElectricSensor -> \case
Electrical {} -> True
Electrical{} -> True
_ -> False
ThermalSensor -> \case
Flaming {} -> True
Sparking {} -> True
Explosive {} -> True
Flaming{} -> True
Sparking{} -> True
Explosive{} -> True
_ -> False
PhysicalSensor -> \case
Piercing {} -> True
Blunt {} -> True
Crushing {} -> True
Explosive {} -> True
Piercing{} -> True
Blunt{} -> True
Crushing{} -> True
Explosive{} -> True
_ -> False
--damageUsing :: DamageType -> Damage -> Either Int Int
--damageUsing dt dm