42 lines
1.1 KiB
Haskell
42 lines
1.1 KiB
Haskell
module Dodge.Item.Weapon.Spawn where
|
|
import Dodge.Data
|
|
import Dodge.Item.Weapon.TriggerType
|
|
--import Dodge.Item.Weapon.Remote
|
|
import Dodge.Default.Weapon
|
|
--import Dodge.Item.Weapon.Grenade
|
|
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 cr = defaultGun
|
|
{ _itName = "SPAWNER"
|
|
, _wpMaxAmmo = 1
|
|
, _wpLoadedAmmo = 1
|
|
, _wpReloadTime = 80
|
|
, _wpReloadState = 0
|
|
, _itUseRate = 100
|
|
, _itUse = RightUse $ \_ -> spawnCrNextTo cr
|
|
, _itUseModifiers =
|
|
[ ammoCheckI
|
|
, hammerCheckI
|
|
]
|
|
}
|
|
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)
|