Start to add basic gibbing

This commit is contained in:
2022-06-03 18:00:07 +01:00
parent b50e53f400
commit dd985c6a49
7 changed files with 60 additions and 11 deletions
+2
View File
@@ -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
+21
View File
@@ -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
+2
View File
@@ -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)
]
_ -> []
+4 -2
View File
@@ -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)
+14
View File
@@ -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
+7
View File
@@ -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}
}
+10 -9
View File
@@ -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 ))