Start work on clouds, damage, sensors

This commit is contained in:
2025-06-06 22:53:41 +01:00
parent d2d4642380
commit 7bee1549bf
25 changed files with 325 additions and 312 deletions
+13 -2
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Machine.Update (
updateMachine,
) where
@@ -151,7 +152,8 @@ mcProxTest mc w = case mc ^? mcType . _McSensor . proxRequirement of
where
cr = you w
senseDamage :: Int -> DamageType -> Machine -> World -> World
--senseDamage :: Int -> DamageType -> Machine -> World -> World
senseDamage :: Int -> SensorType -> Machine -> World -> World
senseDamage threshold dt mc =
(cWorld . lWorld . machines . ix mcid %~ upmc)
. updatels
@@ -162,12 +164,21 @@ senseDamage threshold dt mc =
| x > 0 = x
| otherwise = -5
where
x = sum . map _dmAmount $ filter ((== dt) . _dmType) (_mcDamage mc)
f d = d `elem` sensorTypeDamages dt
x = sum . map _dmAmount $ filter (f . _dmType) (_mcDamage mc)
ni = fromIntegral (mc ^?! mcType . _McSensor . sensAmount) / fromIntegral threshold
updatels = fromMaybe id $ do
lsid <- mc ^? mcMounts . ix ObLightSource
return $ cWorld . lWorld . lightSources . ix lsid . lsParam . lsCol .~ V3 ni ni ni
sensorTypeDamages :: SensorType -> [DamageType]
sensorTypeDamages = \case
LaserSensor -> [LASERING]
ElectricSensor -> [ELECTRICAL]
ThermalSensor -> [FLAMING,SPARKING,EXPLOSIVE]
PhysicalSensor -> [PIERCING,BLUNT,CUTTING,CRUSHING,EXPLOSIVE,CONCUSSIVE]
--damageUsing :: DamageType -> Damage -> Either Int Int
--damageUsing dt dm
-- | _dmType dm == dt = Left $ _dmAmount dm