Move some item datatypes into dedicated module

This commit is contained in:
2021-11-29 16:50:44 +00:00
parent f40d486d68
commit 89a80a0c77
15 changed files with 90 additions and 124 deletions
+40
View File
@@ -54,4 +54,44 @@ data AimStance
| LeaveHolstered
deriving
(Eq,Show,Ord,Enum)
data ItZoom = ItZoom
{ _itZoomMax :: Float
, _itZoomMin :: Float
, _itZoomFac :: Float
}
data CurseStatus = Uncursed | UndroppableIdentified | UndroppableUnidentified
data AimParams = AimParams
{ _aimSpeed :: Float
, _aimRange :: Float
, _aimZoom :: ItZoom
, _aimStance :: AimStance
}
data UseDelay -- should just be Delay
= NoDelay
| FixedRate
{_rateMax :: Int
,_rateTime :: Int
}
| VariableRate
{_rateMax :: Int
,_rateTime :: Int
,_rateMaxMax :: Int
,_rateMinMax :: Int
}
| WarmUpNoDelay
{_warmTime :: Int
,_warmMax :: Int
}
data ItemType
= Weapon'
{ _wpSpread :: Float
, _wpRange :: Float
, _wpNumBarrels :: Int
}
| UtilityItem
| ConsumableItem
makeLenses ''HammerType
makeLenses ''ItZoom
makeLenses ''AimParams
makeLenses ''UseDelay
makeLenses ''ItemType
+3 -9
View File
@@ -10,7 +10,7 @@ import Dodge.Particle.TeslaArc
import Dodge.SoundLogic.LoadSound
import Dodge.WorldEvent
import Dodge.WorldEvent.Damage
import Dodge.Default
--import Dodge.Default
import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.AmmoParams
@@ -50,11 +50,9 @@ teslaGun = defaultGun
]
& useAim . aimSpeed .~ 0.4
& useAim . aimStance .~ TwoHandFlat
, _wpSpread = 0.001
, _wpRange = 20
, _itFloorPict = teslaGunPic
, _itZoom = defaultItZoom
}
-- , _itZoom = defaultItZoom
} & itType . wpSpread .~ 0.001
teslaGunPic :: Item -> SPic
teslaGunPic _ = noPic $ colorSH blue $
upperPrismPoly 5 (rectNESW xb y xa (-y))
@@ -81,8 +79,6 @@ lasGun = defaultAutoGun
& useAim . aimSpeed .~ 0.4
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
, _wpSpread = 0.001
, _wpRange = 20
, _itFloorPict = lasGunPic
, _itAttachment = ItCharMode $ Seq.fromList "/VZ"
, _itScroll = scrollCharMode
@@ -116,8 +112,6 @@ tractorGun = defaultAutoGun
& useAim . aimSpeed .~ 0.4
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
, _wpSpread = 0.00001
, _wpRange = 20
, _itFloorPict = tractorGunSPic
}
-- TODO own picture for tractor gun
+2 -2
View File
@@ -8,7 +8,7 @@ import Dodge.Item.Weapon.Targeting
import Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.ExtraEffect
import Dodge.Default
--import Dodge.Default
import Dodge.Particle.Bullet.Spawn
import Dodge.Particle.Bullet.HitEffect
import Dodge.WorldEvent.HitEffect
@@ -41,7 +41,7 @@ bezierGun = defaultGun
, _itAttachment = NoItAttachment
, _itScroll = \_ _ -> removeItTarget
, _itEffect = rbSetTarget
, _itZoom = defaultItZoom
-- , _itZoom = defaultItZoom
, _itConsumption = defaultAmmo
{ _wpMaxAmmo = 50
}
+1 -2
View File
@@ -119,10 +119,9 @@ boosterGun = defaultGun
, _wpReloadTime = 20
}
, _itUse = luseInstantNoH $ boostSelfL 10
, _wpSpread = 0.05
, _wpRange = 20
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)]
, _itEffect = resetAttachmentID
, _itType = UtilityItem
}
resetAttachmentID :: ItEffect
resetAttachmentID = ItInvEffect f 0
+11 -25
View File
@@ -61,15 +61,13 @@ autoGun = defaultAutoGun
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
, _wpSpread = autogunSpread
, _wpRange = 20
, _itFloorPict = autoGunPic
, _itZoom = defaultItZoom
-- , _itZoom = defaultItZoom
, _itEquipPict = pictureWeaponOnAim
, _itAttachment = ItCharMode $ Seq.fromList "MS"
, _itScroll = scrollCharMode
, _itInvDisplay = basicWeaponDisplay
}
} & itType . wpSpread .~ autogunSpread
autoGunPic :: Item -> SPic
autoGunPic it = noPic $
colorSH red (prismPoly
@@ -99,16 +97,13 @@ pistol = defaultGun
, randSpreadDir
, withMuzFlareI
]
, _wpSpread = 0.02
, _wpRange = 20
, _itFloorPict = pistolPic
, _itZoom = defaultItZoom
-- , _itZoom = defaultItZoom
, _itEquipPict = pictureWeaponAim pistolPic
, _itID = Nothing
, _itInvDisplay = basicWeaponDisplay
, _itInvColor = white
, _itTargeting = Nothing
, _itWorldTrigger = Nothing
}
pistolPic :: Item -> SPic
pistolPic it = noPic $ colorSH green (prismPoly
@@ -146,7 +141,6 @@ hvAutoGun = defaultAutoGun
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& useDelay .~ VariableRate {_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
, _wpRange = 20
, _itFloorPict = hvAutoGunPic
}
hvAutoGunPic :: Item -> SPic
@@ -180,12 +174,11 @@ ltAutoGun = defaultAutoGun
, withSidePushI 50
, modClock 2 withMuzFlareI
]
, _wpSpread = 0.5
, _wpRange = 20
, _itFloorPict = ltAutoGunPic
, _itZoom = defaultItZoom
-- , _itZoom = defaultItZoom
}
& itDimension . muzzleLength .~ 10
& itType . wpSpread .~ 0.5
ltAutoGunPic :: Item -> SPic
ltAutoGunPic it =
( colorSH green $ prismPoly
@@ -243,7 +236,6 @@ miniGun = defaultAutoGun
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
, _wpRange = 20
, _itFloorPict = miniGunPictItem
, _itEquipPict = pictureWeaponAim miniGunPictItem
} & itDimension . muzzleLength .~ 15
@@ -306,11 +298,9 @@ spreadGun = defaultGun
, withMuzFlareI
, spreadNumI
]
, _wpSpread = spreadGunSpread
, _wpRange = 20
, _itFloorPict = spreadGunPic
, _wpNumBarrels = 50
}
} & itType . wpSpread .~ spreadGunSpread
& itType . wpNumBarrels .~ 50
spreadGunPic :: Item -> SPic
spreadGunPic it =
( colorSH green (upperPrismPoly 5 $ map toV2[(-3,0),(3,6),(3,-6)])
@@ -343,12 +333,9 @@ multGun = defaultGun
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
, _wpSpread = spreadGunSpread
, _wpRange = 20
, _itFloorPict = multGunSPic
, _itZoom = defaultItZoom
, _wpNumBarrels = 5
}
-- , _itZoom = defaultItZoom
} & itType . wpNumBarrels .~ 5
multGunSPic :: Item -> SPic
multGunSPic it =
( colorSH red (
@@ -389,13 +376,12 @@ longGun = defaultGun
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
, _wpRange = 200
, _itFloorPict = longGunSPic
, _itZoom = defaultItZoom
-- , _itZoom = defaultItZoom
, _itScroll = zoomLongGun
, _itAttachment = ItScope (V2 0 0) 0 1 False
, _itEffect = itemLaserScopeEffect
}
} & itType . wpRange .~ 200
longGunSPic :: Item -> SPic
longGunSPic _ =
( colorSH orange $ upperPrismPoly 5 $ rectWH 12 2
-2
View File
@@ -37,8 +37,6 @@ lasDrones = defaultGun
& useAim . aimSpeed .~ 0.2
& useAim . aimRange .~ 0.5
& useAim . aimStance .~ TwoHandTwist
, _wpSpread = 0.02
, _wpRange = 20
, _itFloorPict = lasDronesPic
, _itEffect = NoItEffect
}
+1 -1
View File
@@ -37,7 +37,7 @@ grenade = Throwable
[ useTimeCheck
]
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = f fuseTime, _itZoomMin = f fuseTime}
, _itZoom = defaultItZoom
-- , _itZoom = defaultItZoom
, _itEquipPict = pictureWeaponOnAim' $ \_ -> grenadePic fuseTime
, _itID = Nothing
, _itAttachment = ItFuse fuseTime
-4
View File
@@ -57,8 +57,6 @@ launcher = defaultGun
& useAim . aimSpeed .~ 0.2
& useAim . aimRange .~ 0.5
& useAim . aimStance .~ TwoHandTwist
, _wpSpread = 0.02
, _wpRange = 20
, _itFloorPict = launcherPic
, _itEffect = NoItEffect
}
@@ -258,8 +256,6 @@ remoteLauncher = defaultGun
& useAim . aimSpeed .~ 0.2
& useAim . aimRange .~ 0.5
& useAim . aimStance .~ TwoHandTwist
, _wpSpread = 0.02
, _wpRange = 20
, _itFloorPict = launcherPic
, _itAttachment = ItScope (V2 0 0) 0 1 True
}
+4 -8
View File
@@ -3,7 +3,6 @@ import Dodge.Data
import Dodge.Picture.Layer
import Dodge.Default
import Dodge.Item.Draw
import Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.UseEffect
@@ -32,10 +31,8 @@ radar = defaultGun
]
& useAim . aimRange .~ 1
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
, _wpSpread = autogunSpread
, _wpRange = 20
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
, _itZoom = defaultItZoom { _itZoomMax = 1}
-- , _itZoom = defaultItZoom { _itZoomMax = 1}
, _itEquipPict = pictureWeaponOnAim' $ \_ -> (,) emptySH $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
}
{- |
@@ -54,9 +51,8 @@ sonar = defaultGun
]
& useAim . aimRange .~ 1
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
, _wpRange = 20
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
, _itZoom = defaultItZoom {_itZoomMax = 1}
-- , _itZoom = defaultItZoom {_itZoomMax = 1}
, _itEquipPict = pictureWeaponOnAim' $ \_ -> (,) emptySH $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
}
{- |
@@ -71,7 +67,7 @@ autoSonar = defaultEquipment
, _itEquipPict = \_ _ -> (,) emptySH blank
, _itEffect = autoSonarEffect
, _itID = Nothing
, _itZoom = defaultItZoom {_itZoomMax = 1}
-- , _itZoom = defaultItZoom {_itZoomMax = 1}
}
{- |
Automatically sends out pulses that display walls. -}
@@ -85,5 +81,5 @@ autoRadar = defaultEquipment
, _itEquipPict = \_ _ -> (,) emptySH blank
, _itEffect = autoRadarEffect
, _itID = Nothing
, _itZoom = defaultItZoom {_itZoomMax = 1}
-- , _itZoom = defaultItZoom {_itZoomMax = 1}
}
+8 -8
View File
@@ -48,11 +48,13 @@ poisonSprayer = defaultAutoGun
& useAim . aimSpeed .~ 0.2
& useAim . aimRange .~ 0
& useAim . aimStance .~ TwoHandTwist
, _wpRange = 8
, _itType = Weapon'
{ _wpRange = 8
, _wpSpread = 0.1
, _wpNumBarrels = 3
}
, _itFloorPict = flamerPic
, _itZoom = defaultItZoom
, _wpSpread = 0.1
, _wpNumBarrels = 3
-- , _itZoom = defaultItZoom
}
flamer :: Item
flamer = defaultAutoGun
@@ -73,12 +75,10 @@ flamer = defaultAutoGun
& useAim . aimSpeed .~ 0.5
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 5, _itZoomMin = 1.5}
& useAim . aimStance .~ TwoHandTwist
, _wpSpread = 0
, _wpRange = 8
, _itFloorPict = flamerPic
, _itZoom = defaultItZoom
-- , _itZoom = defaultItZoom
, _itAttachment = NoItAttachment
}
} & itType . wpRange .~ 8
flamerPic :: Item -> SPic
flamerPic it =
( colorSH yellow $
+6 -6
View File
@@ -320,7 +320,7 @@ withMuzFlareI f it cr w = makeTlsTimeRadColPos 3 100 (V3 1 1 0.5) flashPos
randSpreadDir :: ChainEffect
randSpreadDir f it cr w = f it (cr & crDir +~ a) $ set randGen g w
where
acc = _wpSpread it
acc = _wpSpread $ _itType it
(a, g) = randomR (-acc,acc) $ _randGen w
{- | Applies the effect to a randomly rotated creature. -}
withRandomDirI
@@ -391,8 +391,8 @@ spreadNumI eff item cr w = foldr f w dirs
[-spread,-spread+(2*spread/fromIntegral numBul)..spread]
(randomRs (0,spread/fromIntegral numBul) (_randGen w))
f dir = eff item (cr & crDir +~ dir)
spread = _wpSpread item
numBul = _wpNumBarrels item
spread = _wpSpread $ _itType item
numBul = _wpNumBarrels $ _itType item
numI :: ChainEffect
numI eff item cr w = foldr f w poss
where
@@ -401,7 +401,7 @@ numI eff item cr w = foldr f w poss
poss :: [V2 Float]
poss = map (rotateV (_crDir cr) . V2 0 . (*5) . (+ cp) . fromIntegral) [0 .. numBul - 1]
f pos = eff item (cr & crPos %~ (+.+ pos))
numBul = _wpNumBarrels item
numBul = _wpNumBarrels $ _itType item
{- | Uses '_wpSpread' as a parameter for the current offset angle. -}
randWalkAngle
:: Float -- ^ Max offset angle
@@ -412,10 +412,10 @@ randWalkAngle
-> World
randWalkAngle ma aspeed f cr w = w
& f (cr & crDir +~ a)
& creatures . ix cid . crInv . ix i . wpSpread .~ newa
& creatures . ix cid . crInv . ix i . itType . wpSpread .~ newa
where
cid = _crID cr
a = _wpSpread $ _crInv (_creatures w IM.! cid) IM.! i
a = _wpSpread $ _itType $ _crInv (_creatures w IM.! cid) IM.! i
(walka, _) = randomR (-aspeed,aspeed) (_randGen w)
newa = min ma $ max (negate ma) (a + walka)
i = _crInvSel $ _creatures w IM.! cid
+2 -6
View File
@@ -63,8 +63,7 @@ shrinkGun = defaultGun
}
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
& useHammer .~ upHammer
, _wpSpread = 0.05
, _wpRange = 20
, _itType = UtilityItem
, _itFloorPict = shrinkGunPic
, _itAttachment = ItBool True
}
@@ -96,8 +95,7 @@ blinkGun = defaultGun
, _itUse = defaultlUse
{_lUse = hammerCheckL $ shootL aSelfL
} & useHammer .~ upHammer
, _wpSpread = 0.05
, _wpRange = 20
, _itType = UtilityItem
, _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
}
@@ -129,8 +127,6 @@ forceFieldGun = defaultGun
, _wpReloadState = 0
}
, _itUse = undefined
, _wpSpread = 0.02
, _wpRange = 20
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]
}
-- grapGun = defaultGun