34 lines
959 B
Haskell
34 lines
959 B
Haskell
module Dodge.Item.Weapon.Spawn where
|
|
import Dodge.Data
|
|
import Dodge.Default.Weapon
|
|
import Geometry
|
|
import qualified IntMapHelp as IM
|
|
|
|
import Data.Function
|
|
import Control.Lens
|
|
|
|
|
|
{- |
|
|
Creates a creature next to the creature using the item. -}
|
|
spawnGun :: Creature -> Item
|
|
spawnGun _ = defaultWeapon
|
|
& itUse . useDelay . rateMax .~ 100
|
|
& itUse . rUse .~ HeldDoNothing --(\_ -> spawnCrNextTo cr)
|
|
& itUse . useMods .~ HeldModNothing
|
|
-- [ ammoCheckI
|
|
-- , hammerCheckI
|
|
-- ]
|
|
& itType . iyBase .~ LEFT SPAWNER
|
|
spawnCrNextTo
|
|
:: Creature -- ^ Creature to spawn
|
|
-> Creature -- ^ existing creature that will be spawned next to
|
|
-> World
|
|
-> World
|
|
spawnCrNextTo cr sCr w = w & creatures %~ IM.insert k newCr
|
|
where
|
|
k = IM.newKey $ _creatures w
|
|
newCr = cr
|
|
& crID .~ k
|
|
& crPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
|
|
& crOldPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
|