Add battery shape/picture

This commit is contained in:
2024-10-04 00:25:44 +01:00
parent 127d85e7ce
commit ac550bc6a4
14 changed files with 241 additions and 271 deletions
+1 -1
View File
@@ -1 +1 @@
All good (601 modules, at 20:39:35)
All good (601 modules, at 00:25:15)
+1 -1
View File
File diff suppressed because one or more lines are too long
+4
View File
@@ -79,6 +79,10 @@ normalizeColor (V4 r g b a) = V4 (f r) (f g) (f b) (f a)
where
f = min 1 . max 0
mixColorsFrac :: Color -> Color -> Float -> Color
{-# INLINE mixColorsFrac #-}
mixColorsFrac c1 c2 x = mixColors x (1-x) c1 c2
mixColors :: Float -> Float -> Color -> Color -> Color
{-# INLINE mixColors #-}
mixColors rata ratb (V4 r0 g0 b0 a0) (V4 r2 g2 b2 a2) =
+3 -3
View File
@@ -1,5 +1,5 @@
module Dodge.Creature.State (
stateUpdate,
crUpdate,
doDamage,
) where
@@ -57,8 +57,8 @@ foldCr xs cr w = foldl' f w xs
at what point invSideEffects is applied wrt to when the creature moves
may affect whether the shield moves correctly
-}
stateUpdate :: (Creature -> World -> World) -> Creature -> World -> World
stateUpdate f =
crUpdate :: (Creature -> World -> World) -> Creature -> World -> World
crUpdate f =
foldCr
[ doDamage -- these two
, checkDeath -- must be in this order 24/7/22
+1 -2
View File
@@ -11,8 +11,7 @@ import Data.Aeson.TH
import Geometry.Data
data Scope
= NoScope
| OpticScope
= OpticScope
{ -- | a camera offset
_opticPos :: Point2 -- this should be relative to the camera rotation
-- this means that when the camera rotates when firing etc,
+1 -3
View File
@@ -64,9 +64,7 @@ data ItemUse
, _tgID :: Maybe Int
, _tgActive :: Bool
}
| UseBulletMod
{ _ubMod :: BulletMod
}
| UseBulletMod { _ubMod :: BulletMod }
deriving (Eq, Show, Read)
data TriggerType = AutoTrigger | HammerTrigger
+3 -3
View File
@@ -168,7 +168,7 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
]
]
cr
YourAI -> stateUpdate yourControl cr
YourAI -> crUpdate yourControl cr
InanimateAI -> id
where
drawwp = DoActionIfElse NoAction (WdCrBlfromCrBl CrIsAiming) (DoActionThen drawWeapon (WaitThen 50 NoAction))
@@ -184,7 +184,7 @@ humanoidAIList ::
World ->
World
humanoidAIList
= stateUpdate . impulsiveAIBefore . chainCreatureUpdates
= crUpdate . impulsiveAIBefore . chainCreatureUpdates
-- bit of a hack to get new random generators after each creature's update
defaultImpulsive ::
@@ -193,7 +193,7 @@ defaultImpulsive ::
World ->
World
defaultImpulsive
= fmap (fmap updateRandGen) . stateUpdate . impulsiveAIBefore . chainCreatureUpdates
= fmap (fmap updateRandGen) . crUpdate . impulsiveAIBefore . chainCreatureUpdates
where
updateRandGen w =
let (_, g) = randomR (0, 1 :: Int) (_randGen w)
+1 -3
View File
@@ -1,7 +1,7 @@
module Dodge.Item.Display (
itemDisplay,
itemString,
itemBaseName,
itemString,
basicItemDisplay,
) where
@@ -33,7 +33,6 @@ basicItemDisplay itm =
itemBaseName itm :
--catMaybes [maybeWarmupStatus itm, maybeRateStatus itm]
catMaybes [maybeWarmupStatus itm]
-- ++ moduleStrings itm
++ repeat "*"
itemString :: Item -> String
@@ -100,7 +99,6 @@ itemNumberDisplay cr itm = case iu of
UseAttach {} -> []
UseAmmoMag {} -> [maybe "" shortShow $ itm ^? itUse . amagLoadStatus . iaLoaded]
UseScope OpticScope {_opticZoom = x} -> [shortShow x]
UseScope {} -> []
UseTargeting {_tgPos = mp} -> [maybe "" shortShow mp]
-- this could be cleaner here...
UseBulletMod {} -> mempty
-2
View File
@@ -1,8 +1,6 @@
module Dodge.Item.Draw (
twoFlatHRot,
itemSPic,
itemEquipPict,
heldItemOffset,
) where
import Dodge.Data.ComposedItem
+7 -7
View File
@@ -44,19 +44,19 @@ itemSPic it = case it ^. itType of
ammoMagSPic :: Item -> AmmoMagType -> SPic
ammoMagSPic it = \case
TINMAG -> noPic $ upperPrismPolyTS 1 (reverse $ rectNSWE 0 (- y) (-1) 1)
DRUMMAG -> noPic $ upperPrismPolyTS 1 (reverse $ rectNSWE 0 (- y) (-1) 1)
TINMAG -> noPic $ upperPrismPolyTS 1 (rectNSWE 0 (- y) (-1) 1)
DRUMMAG -> noPic $ upperPrismPolyTS 1 (rectNSWE 0 (- y) (-1) 1)
CHEMFUELPOUCH -> noPic $ colorSH yellow (upperPrismPolyST 3 $ polyCirc 3 5)
-- , setLayer MidLayer . color black $ translate3 (V3 0 0 4) $ circleSolid (5 * am)
BATTERY -> colorSH blue (upperBox Tiny Superfluous 1 (rectNSWE 0 (-2) (-2) 2))
:!: setLayer BloomNoZWrite (setDepth 2 . color (mixColorsFrac green red am) $ circleSolid 2)
_ -> noPic $ upperPrismPolyTS 1 (reverse $ rectNSWE 0 (- y) (-1) 1)
where
y = fromIntegral y' * 0.3
y' = fromMaybe 0 $ it ^? itUse . amagLoadStatus . iaLoaded
am = fractionLoadedAmmo (it ^?! itUse . amagLoadStatus)
-- am = fractionLoadedAmmo (it ^?! itUse . amagLoadStatus)
--fractionLoadedAmmo :: ReloadStatus -> Float
--fractionLoadedAmmo rs = fromIntegral (_iaLoaded rs) / fromIntegral (_iaMax rs)
fractionLoadedAmmo :: ReloadStatus -> Float
fractionLoadedAmmo rs = fromIntegral (_iaLoaded rs) / fromIntegral (_iaMax rs)
--
--fractionLoadedAmmo2 :: ReloadStatus -> Float
--fractionLoadedAmmo2 rs =
+9 -17
View File
@@ -23,38 +23,30 @@ transToHandle itm = fromMaybe id $ do
V2 x y <- itm ^? itUse . heldAim . aimHandlePos
return (-.-.- V3 x y 0)
-- there is a lot of duplication going on here, and also need to check
-- rotations
heldItemRelativeOrient :: Item -> Creature -> (Point3, Q.Quaternion Float) -> (Point3, Q.Quaternion Float)
heldItemRelativeOrient itm cr (p,q)
| _posture (_crStance cr) == Aiming =
(p +.+.+ aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
(p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
| isTwoHandFlat =
( (+.+.+ V3 (_crRad cr) 0 handD)
. rotate3 (twoFlatHRot cr)
$ transToHandle itm p
( V3 (_crRad cr) 0 handD
+ rotate3 (twoFlatHRot cr) (transToHandle itm p)
, (Q.axisAngle (V3 0 0 1) (twoFlatHRot cr)) * q
)
| isOneHand =
( (+.+.+ V3 0 0 handD)
. (+.+.+ V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) 0)
. (+.+.+ V3 (-2) 0 0)
$ transToHandle itm p
( V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) handD
+ transToHandle itm p
, Q.qID * q
)
| otherwise =
( (+.+.+ V3 0 0 handD)
. (+.+.+ V3 (_crRad cr) 0 0)
. rotate3 (strideRot cr + 1.2)
. (+.+.+ V3 (-8) 0 0)
$ transToHandle itm p
( V3 (_crRad cr) 0 handD
+ rotate3 (strideRot cr + 1.2) (V3 (-8) 0 0 + transToHandle itm p)
, (Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2)) * q
)
where
handD = 15
handPos = case cr ^? crStance . carriage of
Just (Walking x LeftForward) -> f x * 50
_ -> 0
Just (Walking x LeftForward) -> f x * 50 -2
_ -> 0 - 2
isOneHand =
itm ^? itUseAimStance == Just OneHand
|| isNothing (itm ^? itUseAimStance)
+7 -10
View File
@@ -137,7 +137,6 @@ updateScopeZoom' i w
where
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itUse . uScope
resetscope (OpticScope _ _ defz) = OpticScope (V2 0 0) defz defz
resetscope otherAtt = otherAtt
doScopeZoom :: Int -> Point2 -> Scope -> Scope
doScopeZoom scrollamount mp sc = case scrollamount of
@@ -169,11 +168,11 @@ zoomOutLongGun sc = fromMaybe sc $ do
sc & opticPos %~ (\p -> p +.+ (zoomSpeed - 1) / curzoom *.* p)
& opticZoom *~ zoomSpeed
ifConfigWallRotate :: Configuration -> World -> World
ifConfigWallRotate cfig w
| _gameplay_rotate_to_wall cfig && not (SDL.ButtonRight `M.member` _mouseButtons (_input w)) =
rotateToOverlappingWall w
| otherwise = w
ifConfigWallRotate :: Configuration -> M.Map MouseButton Int -> World -> World
ifConfigWallRotate cfig mbs
| _gameplay_rotate_to_wall cfig && not (SDL.ButtonRight `M.member` mbs) =
rotateToOverlappingWall
| otherwise = id
rotateToOverlappingWall :: World -> World
rotateToOverlappingWall w =
@@ -205,13 +204,11 @@ rotateCamera cfig w
| keydown SDL.ScancodeQ && keydown SDL.ScancodeE = w
| keydown SDL.ScancodeQ = rotateCameraBy 0.025 w
| keydown SDL.ScancodeE = rotateCameraBy (-0.025) w
| otherwise = ifConfigWallRotate cfig w
| otherwise = ifConfigWallRotate cfig (w ^. input . mouseButtons) w
where
keydown scode = scode `M.member` _pressedKeys (_input w) && not (inInputFocus w)
zoomFromItem ::
ItZoom ->
Float
zoomFromItem :: ItZoom -> Float
zoomFromItem ItZoom{_izMax = zMax, _izMin = zMin, _izFac = zFac} =
min zMax $ max zMin zFac
-3
View File
@@ -12,9 +12,6 @@ import qualified Control.Foldl as L
-- | Draw an anticlockwise rectangle based on maximal N E S W values.
rectNESW :: Float -> Float -> Float -> Float -> [Point2]
rectNESW !a !b !c !d = [V2 b a,V2 b c,V2 d c,V2 d a]
-- | Draw a clockwise rectangle based on maximal N S E W values.
--rectNSEW :: Float -> Float -> Float -> Float -> [Point2]
--rectNSEW !n !s !e !w = rectNESW n e s w
-- | Draw an anticlockwise rectangle based on maximal N S W E values.
rectNSWE :: Float -> Float -> Float -> Float -> [Point2]
rectNSWE !n !s !w !e = [V2 w n, V2 w s, V2 e s, V2 e n]
+203 -216
View File
File diff suppressed because it is too large Load Diff