Improve sensor terminal messages

This commit is contained in:
2025-09-18 10:18:53 +01:00
parent 1564b1c721
commit 4494e47b43
9 changed files with 176 additions and 156 deletions
+23 -9
View File
@@ -103,7 +103,7 @@ mcDamSensorTriggerUpdate se mc = fromMaybe id $ do
mcProxSensorTriggerUpdate :: ProximitySensor -> Machine -> World -> World
mcProxSensorTriggerUpdate se mc = fromMaybe id $ do
trid <- mc ^? mcMounts . ix OTTrigger
bval <- se ^? proxToggle
bval <- se ^? proxToggle . _Just
return $ cWorld . lWorld . triggers . at trid ?~ bval
mcTriggerVal :: DamageSensor -> Maybe Bool
@@ -142,18 +142,25 @@ mcProxSensorUpdate se mc = case se ^. proxSensorType of
mcNoItemsTest :: Machine -> [Point2] -> World -> World
mcNoItemsTest mc ps w
| t && not (mc ^?! mcType . _McProxSensor . proxToggle) =
w & mcsenslens . proxToggle .~ True
| t && (falsetog || notog) =
w & mcsenslens . proxToggle ?~ True
& playsound dedaS
| not t && (mc ^?! mcType . _McProxSensor . proxToggle) =
w & mcsenslens . proxToggle .~ False
& mctermlens . tmFutureLines .:~ makeTermLine "SENSOR SUCCESS: ZONE CLEAR"
| not t && (truetog || notog) =
w & mcsenslens . proxToggle ?~ False
& playsound dedumS
& mctermlens . tmFutureLines .:~ makeTermLine "SENSOR FAIL: ITEM IN ZONE"
| otherwise = w
where
truetog = mc ^? mcType . _McProxSensor . proxToggle . _Just == Just True
falsetog = mc ^? mcType . _McProxSensor . proxToggle . _Just == Just False
notog = null (mc ^? mcType . _McProxSensor . proxToggle . _Just)
&& pointInPoly (cr ^. crPos) qs
t = ((cr ^. crInv == mempty) || not (pointInPoly (cr ^. crPos) qs))
&& not (any ((`pointInPoly` qs) . _flItPos) (w ^. cWorld . lWorld . floorItems))
cr = w ^?! cWorld . lWorld . creatures . ix 0
mcsenslens = cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McProxSensor
mctermlens = cWorld . lWorld . terminals . ix (mc ^?! mcMounts . ix OTTerminal)
playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing
qs = f ps
f = fmap ((+ _mcPos mc) . rotateV (_mcDir mc))
@@ -161,17 +168,24 @@ mcNoItemsTest mc ps w
mcProximitySensorUpdate
:: Machine -> ProximitySensor -> ProximityRequirement -> World -> World
mcProximitySensorUpdate mc sens pr w
| sens ^. proxToggle || dist (_crPos ycr) (_mcPos mc) > 40 = w
| truetog || dist (_crPos ycr) (_mcPos mc) > 40 = w
| mcProxTest w pr =
w
& mcsenslens . proxToggle .~ True
& mcsenslens . proxToggle ?~ True
& playsound dedaS
& mctermlens . tmFutureLines .:~ makeTermLine "SENSOR SUCCESS!"
| otherwise =
& mctermlens . tmFutureLines <>~
[makeTermLine "SENSOR SUCCESS, DEACTIVATED" ]
<> tlSetStatus (TerminalPressTo "QUIT")
<> tlDoEffect TmWdWdLeaveTerminal
| notog =
w & playsound dedumS
& mcsenslens . proxToggle ?~ False
& mctermlens . tmFutureLines
.:~ makeTermLine ( "SENSOR FAIL: REQUIRES " ++ sensorReqToString pr)
| otherwise = w
where
truetog = sens ^? proxToggle . _Just == Just True
notog = null (sens ^? proxToggle . _Just)
mctermlens = cWorld . lWorld . terminals . ix (mc ^?! mcMounts . ix OTTerminal)
mcsenslens = cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McProxSensor
playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing