Refactor creature draw, pass World to function
This commit is contained in:
@@ -80,6 +80,8 @@ pistol = Weapon
|
||||
, _itEffect = wpRecock
|
||||
, _itInvDisplay = basicWeaponDisplay
|
||||
, _itInvColor = white
|
||||
, _itTargeting = Nothing
|
||||
, _itWorldTrigger = Nothing
|
||||
}
|
||||
defaultAutoGun :: Item
|
||||
defaultAutoGun = autoGun
|
||||
@@ -260,13 +262,13 @@ tractorGun = defaultAutoGun
|
||||
, _itEquipPict = pictureWeaponOnAim $ color blue $ pictures [polygon $ rectNESW 1.5 6 (-1.5) 0 ]
|
||||
}
|
||||
useTargetPos
|
||||
:: (Point2 -> Creature -> World -> World)
|
||||
:: (Maybe Point2 -> Creature -> World -> World)
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itAttachment . _Just . itTargetPos of
|
||||
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting . _Just of
|
||||
Nothing -> w
|
||||
Just p -> f p cr w
|
||||
Just (g,_) -> f (g w) cr w
|
||||
|
||||
bezierGun :: Item
|
||||
bezierGun = defaultAutoGun
|
||||
@@ -276,7 +278,7 @@ bezierGun = defaultAutoGun
|
||||
. withMuzFlare
|
||||
. withRecoil 40
|
||||
. torqueBefore 0.05 -- I believe that this doesn't affect
|
||||
$ shootBezier p -- <- the start point
|
||||
$ shootBezier $ fromJust p -- <- the start point
|
||||
, _itAttachment = Nothing
|
||||
, _itScrollUp = removeItAttachment 0
|
||||
, _itScrollDown = removeItAttachment 0
|
||||
|
||||
@@ -8,7 +8,7 @@ import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Item.Weapon.Decoration
|
||||
import Dodge.Item.Weapon.UseEffect
|
||||
import Dodge.Item.Attachment.Data
|
||||
--import Dodge.Item.Attachment.Data
|
||||
import Dodge.WorldEvent.Flash
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Picture
|
||||
@@ -109,7 +109,15 @@ rbSetTarget = ItInvEffect
|
||||
setTarg _ cr invid w
|
||||
| _crInvSel cr /= invid = w
|
||||
| SDL.ButtonRight `S.member` _mouseButtons w = w
|
||||
& creatures . ix (_crID cr) . crInv . ix invid . itAttachment
|
||||
%~ maybe (Just $ ItTargetPos $ mouseWorldPos w) Just
|
||||
| otherwise = w & creatures . ix (_crID cr) . crInv . ix invid . itAttachment .~ Nothing
|
||||
& creatures . ix (_crID cr) . crInv . ix invid . itTargeting
|
||||
%~ maybe (Just $ targetCurrentMousePos w) Just
|
||||
| otherwise = w & creatures . ix (_crID cr) . crInv . ix invid . itTargeting .~ Nothing
|
||||
|
||||
targetCurrentMousePos
|
||||
:: World
|
||||
-> (World -> Maybe Point2, Item -> Int -> Creature -> World -> Picture)
|
||||
targetCurrentMousePos w = (f, \_ _ _ _ -> cursorPic)
|
||||
where
|
||||
f _ = Just mwp
|
||||
mwp = mouseWorldPos w
|
||||
cursorPic = line [mwp +.+ (5,5), mwp -.- (5,5)]
|
||||
|
||||
@@ -33,7 +33,7 @@ launcher = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 20
|
||||
, _itUseTime = 0
|
||||
, _itUse = \_ -> shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeExplosionAt
|
||||
, _itUse = \it -> shootWithSound (fromIntegral launcherSound) $ aRocketWithItemParams it
|
||||
, _wpSpread = 0.02
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
@@ -48,30 +48,20 @@ launcher = defaultGun
|
||||
}
|
||||
}
|
||||
flameLauncher :: Item
|
||||
flameLauncher = launcher
|
||||
{ _itName = "FLROCKO"
|
||||
, _itUse = \_ -> shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeFlameExplosionAt
|
||||
}
|
||||
|
||||
flameLauncher = launcher & wpAmmo . amPayload .~ makeFlameExplosionAt
|
||||
poisonLauncher :: Item
|
||||
poisonLauncher = launcher
|
||||
{ _itName = "POISROCK"
|
||||
, _itUse = \_ -> shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makePoisonExplosionAt
|
||||
}
|
||||
|
||||
poisonLauncher = launcher & wpAmmo . amPayload .~ makePoisonExplosionAt
|
||||
teslaLauncher :: Item
|
||||
teslaLauncher = launcher
|
||||
{ _itName = "TESLROCK"
|
||||
, _itUse = \_ -> shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeTeslaExplosionAt
|
||||
}
|
||||
teslaLauncher = launcher & wpAmmo . amPayload .~ makeTeslaExplosionAt
|
||||
|
||||
aRocketWithPayload
|
||||
:: (Point2 -> World -> World) -- ^ Payload
|
||||
aRocketWithItemParams
|
||||
:: Item -- ^ Firing item
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
aRocketWithPayload pl cr w = over projectiles (IM.insert i theShell) w
|
||||
aRocketWithItemParams it cr w = over projectiles (IM.insert i theShell) w
|
||||
where
|
||||
pl = _amPayload $ _wpAmmo it
|
||||
cid = _crID cr
|
||||
i = IM.newKey $ _projectiles w
|
||||
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
||||
|
||||
Reference in New Issue
Block a user