Tweak turrets

This commit is contained in:
2022-07-28 13:46:22 +01:00
parent 8aeabf3f6c
commit ec4ff84c46
10 changed files with 337 additions and 308 deletions
+7 -4
View File
@@ -1,7 +1,8 @@
module Dodge.Machine.Draw
where
import Dodge.Item.HeldOffset
import Dodge.Item.Draw.SPic
import Dodge.Placement.TopDecoration
--import Dodge.Placement.Instance.Turret
import Shape
import Picture
import Geometry
@@ -38,11 +39,13 @@ terminalShape mc = colorSH col (prismPoly
col = _mcColor mc
drawTurret :: Turret -> Machine -> SPic
drawTurret _ mc =
( rotateSH (- _mcDir mc) . colorSH (_mcColor mc) $ upperPrismPoly 20 (square w)
, mempty -- setLayer 5 $ scale 0.5 0.5 $ text $ show $ _mcDir mc )
drawTurret tu mc =
( colorSH (_mcColor mc) $ upperPrismPoly 20 (square w)
, mempty
)
<> overPosSP (turretItemOffset it tu mc) (itemSPic it)
where
it = _tuWeapon tu
w = _mcWidth mc
sensorSPic :: (PaletteColor, DecorationShape) -> Machine -> SPic
+3 -9
View File
@@ -16,6 +16,7 @@ import Dodge.WorldEvent.Explosion
import Geometry
import qualified IntMapHelp as IM
import LensHelp
import Control.Monad
updateMachine :: Machine -> World -> World
updateMachine mc
@@ -32,7 +33,6 @@ mcTurretUpdate mc = case mc ^? mcType . _McTurret of
Just tu -> updateTurret (_tuTurnSpeed tu) mc
_ -> id
-- this needs a major cleanup
updateTurret :: Float -> Machine -> World -> World
updateTurret rotSpeed mc w
| _mcHP mc < 1 =
@@ -57,13 +57,12 @@ updateTurret rotSpeed mc w
mcid = _mcID mc
ypos = _crPos $ you w
mcpos = _mcPos mc
--mcdir = _mcDir mc
seesYou = hasLOSIndirect mcpos ypos w
(elecDams, dams) = partition isElectrical $ _mcDamage mc
dam = sum $ map _dmAmount dams
elecDam = sum $ map _dmAmount elecDams
doTurn
| seesYou = cWorld . machines . ix mcid . mcDir %~ turnTo rotSpeed mcpos ypos
| seesYou = cWorld . machines . ix mcid . mcType . _McTurret . tuDir %~ turnTo rotSpeed mcpos ypos
| otherwise = id
closeFireAngle = seesYou -- && angleVV (ypos -.- mcpos) (unitVectorAtAngle mcdir) < 1
updateFiringStatus
@@ -75,14 +74,9 @@ mcUseItem mc = fromMaybe id $ do
tu <- mc ^? mcType . _McTurret
let it = tu ^. tuWeapon
hit <- it ^? itType . iyBase . ibtHeld
guard (_tuFireTime tu > 0)
return $ mcUseHeld hit it mc
-- maybeFire
-- | _tuFireTime (_mcType mc) > 0 =
-- fromMaybe id $ do
-- return $ tuUseItem
-- | otherwise = id
mcSensorTriggerUpdate :: Machine -> World -> World
mcSensorTriggerUpdate mc = fromMaybe id $ do
trid <- mc ^? mcMounts . ix ObTrigger