35 lines
990 B
Haskell
35 lines
990 B
Haskell
module Dodge.Item.Weapon.Spawn where
|
|
|
|
import Dodge.Default.Item
|
|
import Control.Lens
|
|
import Dodge.Data.World
|
|
import Geometry
|
|
import qualified IntMapHelp as IM
|
|
|
|
{- |
|
|
Creates a creature next to the creature using the item.
|
|
-}
|
|
spawnGun :: Creature -> Item
|
|
spawnGun _ =
|
|
defaultHeldItem
|
|
& itUse . heldDelay . rateMax .~ 100
|
|
-- & itUse . heldUse .~ HeldDoNothing --(\_ -> spawnCrNextTo cr)
|
|
-- & itUse . heldMods .~ DoNothingMod
|
|
& itType .~ LEFT SPAWNER
|
|
|
|
spawnCrNextTo ::
|
|
-- | Creature to spawn
|
|
Creature ->
|
|
-- | existing creature that will be spawned next to
|
|
Creature ->
|
|
World ->
|
|
World
|
|
spawnCrNextTo cr sCr w = w & cWorld . lWorld . creatures %~ IM.insert k newCr
|
|
where
|
|
k = IM.newKey $ w ^?! cWorld . lWorld . creatures -- _creatures (_cWorld w)
|
|
newCr =
|
|
cr
|
|
& crID .~ k
|
|
& crPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
|
|
& crOldPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
|