diff --git a/src/Dodge/Base.hs b/src/Dodge/Base.hs index 0e04d070e..4956a1cd6 100644 --- a/src/Dodge/Base.hs +++ b/src/Dodge/Base.hs @@ -6,6 +6,7 @@ Consider splitting. -} module Dodge.Base ( module Dodge.Base , module Dodge.Base.You + , module Dodge.Base.NewID , module Dodge.Base.WinScale , module Dodge.Base.Window , module Dodge.Base.Coordinate @@ -13,6 +14,7 @@ module Dodge.Base ) where import Dodge.Data import Dodge.Base.WinScale +import Dodge.Base.NewID import Dodge.Base.Coordinate import Dodge.Zone --import Dodge.Zone.Data diff --git a/src/Dodge/Base/NewID.hs b/src/Dodge/Base/NewID.hs new file mode 100644 index 000000000..96edac72d --- /dev/null +++ b/src/Dodge/Base/NewID.hs @@ -0,0 +1,21 @@ +module Dodge.Base.NewID where +import qualified IntMapHelp as IM +import LensHelp + +-- | place an new object into an intmap and update its id +plNewUpID :: ALens' b (IM.IntMap a) + -> ALens' a Int + -> a + -> b + -> (Int,b) +plNewUpID l li x w = (i,w & l #%~ IM.insert i (x & li #~ i)) + where + i = IM.newKey $ w ^# l + +-- | place an new object into an intmap and update its id +plNew :: ALens' b (IM.IntMap a) + -> ALens' a Int + -> a + -> b + -> b +plNew l li x = snd . plNewUpID l li x diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 3a327fa56..a90564e13 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -11,6 +11,7 @@ module Dodge.Creature ) where import Dodge.Creature.State.Data import Dodge.Creature.Update +import Dodge.Prop.Gib --import Dodge.Item.Weapon.Grenade import Dodge.Item.Weapon.Booster import Dodge.Item.Weapon.Utility @@ -196,6 +197,7 @@ inventoryX c = case c of [ blinkGun , unsafeBlinkGun , autoDetector WALLDETECTOR + , effectGun "GIBBER" (addGibsAt . _crPos) ] _ -> [] diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 89407dd9f..9ec7278df 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -5,7 +5,7 @@ module Dodge.Creature.State import Dodge.Data import Dodge.Hammer import Dodge.Reloading - +import Dodge.Prop.Gib import Dodge.Base import Dodge.Creature.State.WalkCycle import Dodge.Creature.Impulse.Movement @@ -75,13 +75,15 @@ checkDeath cr w & dropByState cr where removecr - | _crID cr == 0 = creatures . ix (_crID cr) . crUpdate .~ const id + | _crID cr == 0 = (creatures . ix (_crID cr) . crUpdate .~ const id) + . addGibsAt (_crPos cr) | otherwise = creatures . at (_crID cr) .~ Nothing addCorpse = IM.insertNewKey $ uncurryV translate (_crOldPos cr) $ rotate (_crDir cr) (_crCorpse cr) + internalUpdate :: Creature -> World -> World internalUpdate cr = creatures . ix (_crID cr) %~ ( (crHammerPosition %~ moveHammerUp) diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index e09f21945..f891dc47f 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -49,6 +49,7 @@ import Shape import Data.Tile --import qualified Data.Vector as V +import qualified Linear.Quaternion as Q import GHC.Generics import Control.Lens import Control.Monad.State @@ -836,6 +837,19 @@ data Prop , _pjID :: Int , _pjUpdate :: Prop -> World -> World } + | PropZ + { _pjPos :: Point2 + , _pjStartPos :: Point2 + , _pjVel :: Point2 + , _prDraw :: Prop -> SPic + , _pjID :: Int + , _pjUpdate :: Prop -> World -> World + , _pjPosZ :: Float + , _pjVelZ :: Float + , _pjTimer :: Int + , _pjQuat :: Q.Quaternion Float + , _pjQuatSpin :: Q.Quaternion Float + } | Drone { _pjPos :: Point2 , _pjStartPos :: Point2 diff --git a/src/Dodge/Item/Weapon/Utility.hs b/src/Dodge/Item/Weapon/Utility.hs index e331b8407..dab1b063e 100644 --- a/src/Dodge/Item/Weapon/Utility.hs +++ b/src/Dodge/Item/Weapon/Utility.hs @@ -118,6 +118,13 @@ unsafeBlinkGun = blinkGun effectGun :: String -> (Creature -> World -> World) -> Item effectGun name eff = defaultGun + { _itName = name ++ "Gun" + , _itUse = defaultrUse + & rUse .~ const eff + & useMods .~ [hammerCheckI] + } +effectGunCont :: String -> (Creature -> World -> World) -> Item +effectGunCont name eff = defaultGun { _itName = name ++ "Gun" , _itUse = defaultrUse {_rUse = const eff} } diff --git a/src/Dodge/Placement/PlaceSpot.hs b/src/Dodge/Placement/PlaceSpot.hs index 8da22d60a..aa7f3cfb1 100644 --- a/src/Dodge/Placement/PlaceSpot.hs +++ b/src/Dodge/Placement/PlaceSpot.hs @@ -14,6 +14,7 @@ import Dodge.Placement.PlaceSpot.TriggerDoor --import Dodge.LevelGen.Data import Dodge.Default.Wall import Dodge.ShiftPoint +import Dodge.Base.NewID --import Dodge.RandomHelp --import Dodge.Placements.Spot import Geometry @@ -152,15 +153,15 @@ plNewID l x w = (i,w & l #%~ IM.insert i x) where i = IM.newKey $ w ^# l --- | place an new object into an intmap and update its id -plNewUpID :: ALens' World (IM.IntMap a) - -> ALens' a Int - -> a - -> World - -> (Int,World) -plNewUpID l li x w = (i,w & l #%~ IM.insert i (x & li #~ i)) - where - i = IM.newKey $ w ^# l +---- | place an new object into an intmap and update its id +--plNewUpID :: ALens' World (IM.IntMap a) +-- -> ALens' a Int +-- -> a +-- -> World +-- -> (Int,World) +--plNewUpID l li x w = (i,w & l #%~ IM.insert i (x & li #~ i)) +-- where +-- i = IM.newKey $ w ^# l mvProp :: Point2 -> Float -> Prop -> Prop mvProp p a = (pjRot +~ a) . (pjPos %~ ( (p +.+) . rotateV a ))