Magnets
This commit is contained in:
@@ -19,6 +19,7 @@ data ItAttachment
|
||||
| ItCharMode {_itCharMode :: Seq.Seq Char }
|
||||
| ItTargetPos { _itTargetPos :: Point2 }
|
||||
| ItInt { _itInt :: Int }
|
||||
| ItMInt { _itMInt :: Maybe Int }
|
||||
| ItFloat { _itFloat :: Float }
|
||||
| ItBool { _itBool :: Bool }
|
||||
| NoItAttachment
|
||||
|
||||
@@ -8,21 +8,39 @@ import Dodge.Item.Weapon.BatteryGuns
|
||||
import Dodge.Creature.Test
|
||||
import Dodge.Wall.Reflect
|
||||
import Dodge.Wall
|
||||
import Dodge.Magnet
|
||||
import Picture
|
||||
import Geometry
|
||||
import ShapePicture
|
||||
import Shape
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
|
||||
magShield :: Item
|
||||
magShield = defaultEquipment
|
||||
{ _itType = MAGSHIELD
|
||||
, _itName = "MAGSHIELD"
|
||||
, _itUse = EquipUse useMagShield
|
||||
, _itEquipPict = \_ _ -> (,) emptySH blank
|
||||
, _itID = Nothing
|
||||
, _itAttachment = ItMInt Nothing
|
||||
}
|
||||
useMagShield :: Creature -> Int -> World -> World
|
||||
useMagShield cr invid w = w & magnets . at mgid ?~ themagnet
|
||||
where
|
||||
themagnet = Magnet
|
||||
{_mgID = mgid
|
||||
,_mgUpdate = Just . (mgUpdate .~ const Nothing)
|
||||
,_mgPos = _crPos cr
|
||||
,_mgField = curveAroundField
|
||||
}
|
||||
mgid = case it ^? itAttachment . itMInt . _Just of
|
||||
Just mgid' -> mgid'
|
||||
Nothing -> IM.newKey $ _magnets w
|
||||
it = _crInv cr IM.! invid
|
||||
|
||||
|
||||
flameShield :: Item
|
||||
flameShield = defaultEquipment
|
||||
{ _itType = FLAMESHIELD
|
||||
|
||||
@@ -33,8 +33,14 @@ defaultAimParams = AimParams
|
||||
}
|
||||
|
||||
useAmmoParams :: Item -> Creature -> World -> World
|
||||
useAmmoParams it = withVelWthHiteff (muzvel *.* _amBulVel b) (_rifling $ _itParams it) (_amBulWth b) (_amBulEff b)
|
||||
useAmmoParams it = withVelWthHiteff
|
||||
(muzvel *.* _amBulVel b)
|
||||
(_rifling $ _itParams it)
|
||||
(_amBulWth b)
|
||||
muzlength
|
||||
(_amBulEff b)
|
||||
where
|
||||
muzlength = 20
|
||||
muzvel = _muzVel $ _itParams it
|
||||
b = _aoType $ _itConsumption it
|
||||
|
||||
@@ -49,14 +55,15 @@ withVelWthHiteff
|
||||
:: Point2 -- ^ Velocity, x direction is forward with respect to the creature
|
||||
-> Float -- ^ drag
|
||||
-> Float -- ^ Bullet width
|
||||
-> Float -- ^ Distance away from creature to create
|
||||
-> HitEffect -- ^ Bullet effect when hitting creature, wall etc
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
withVelWthHiteff vel drag width hiteff cr = particles .:~ newbul
|
||||
withVelWthHiteff vel drag width muzlength hiteff cr = particles .:~ newbul
|
||||
where
|
||||
newbul = aGenBulAt (Just (_crID cr)) pos (rotateV dir vel) drag hiteff width
|
||||
pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle dir
|
||||
pos = _crPos cr +.+ muzlength *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
|
||||
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
|
||||
|
||||
@@ -163,13 +163,13 @@ baseRifleShape = colorSH red $ upperPrismPoly 3 $ rectXH 25 2
|
||||
|
||||
|
||||
autoRifle :: Item
|
||||
autoRifle = rifle
|
||||
autoRifle = repeater
|
||||
& itName .~ "AUTORIFLE"
|
||||
& itType .~ AUTORIFLE
|
||||
& itUse . useMods %~ ((ammoCheckI :) . tail)
|
||||
-- & itUse . useDelay . rateMax .~ 6
|
||||
assaultRifle :: Item
|
||||
assaultRifle = rifle
|
||||
assaultRifle = repeater
|
||||
& itName .~ "ASSAULTRIFLE"
|
||||
& itType .~ ASSAULTRIFLE
|
||||
& itUse . useDelay . rateMax .~ 18
|
||||
|
||||
Reference in New Issue
Block a user