Commit before changes to creature inventory update
This commit is contained in:
@@ -170,6 +170,17 @@ inventoryA = IM.fromList $ zip [0..]
|
||||
, makeTypeCraftNum 2 CAN
|
||||
, makeTypeCraftNum 2 PIPE
|
||||
]
|
||||
inventoryB :: IM.IntMap Item
|
||||
inventoryB = IM.fromList $ zip [0..]
|
||||
[ autoRifle
|
||||
, smg
|
||||
, makeTypeCraftNum 4 MICROCHIP
|
||||
, makeTypeCraftNum 2 TIN
|
||||
, makeTypeCraftNum 2 HARDWARE
|
||||
, makeTypeCraftNum 2 CAN
|
||||
, makeTypeCraftNum 2 PIPE
|
||||
, makeTypeCraftNum 1 CREATURESENSOR
|
||||
]
|
||||
|
||||
testInventory :: IM.IntMap Item
|
||||
testInventory = IM.fromList $ zip [0..]
|
||||
|
||||
@@ -51,7 +51,7 @@ foldCr xs cr w = foldr f w xs
|
||||
-- This should be made more sensible: should the movement side effects apply to
|
||||
-- the creature before or after it has moved?
|
||||
-- at what point invSideEffects is applied wrt to when the creature moves
|
||||
-- may effect whether the shield moves correctly
|
||||
-- may affect whether the shield moves correctly
|
||||
stateUpdate :: (Creature -> World -> World) -> Creature -> World -> World
|
||||
stateUpdate f = foldCr
|
||||
[ doDamage
|
||||
@@ -138,10 +138,10 @@ movementSideEff cr w
|
||||
(randAng,_) = randomR (0,2*pi) $ _randGen w
|
||||
|
||||
heldItemUpdate :: Int -> Item -> Item
|
||||
heldItemUpdate invid = (itUse %~ useUpdate) . (itIsHeld .~ True) . (itInvPos ?~ invid)
|
||||
heldItemUpdate invid = (itUse %~ useUpdate) . (itInvPos ?~ invid) . (itIsHeld .~ True)
|
||||
|
||||
invItemUpdate :: Int -> Item -> Item
|
||||
invItemUpdate invid = (itUse %~ useUpdate) . (itIsHeld .~ False) . (itInvPos ?~ invid)
|
||||
invItemUpdate invid = (itUse %~ useUpdate) . (itInvPos ?~ invid) . (itIsHeld .~ False)
|
||||
|
||||
useUpdate :: ItemUse -> ItemUse
|
||||
useUpdate = (useHammer . hammerPosition %~ moveHammerUp)
|
||||
@@ -156,15 +156,21 @@ invSideEff cr w = weaponReloadSounds cr
|
||||
. flip (foldr $ useEquipment cr) (IM.keys $ _crInvEquipped cr)
|
||||
$ IM.foldrWithKey f w (_crInv cr)
|
||||
where
|
||||
f i it w' = doitemupdate w' & case it ^? itEffect . itInvEffect of
|
||||
--upitemsw = w & creatures . ix (_crID cr) . crInv %~ IM.mapWithKey (itemUpdate cr)
|
||||
f i it w' = (doItemTargeting i cr . doitemupdate) w' & case it ^? itEffect . itInvEffect of
|
||||
Nothing -> id
|
||||
Just g -> g (heldItemUpdate i it) cr -- this is done twice!
|
||||
where
|
||||
doitemupdate
|
||||
| i == _crInvSel cr = doItemTargeting i cr . (itpointer %~ heldItemUpdate i)
|
||||
| otherwise = doItemTargeting i cr . (itpointer %~ invItemUpdate i)
|
||||
| i == _crInvSel cr = (itpointer %~ heldItemUpdate i)
|
||||
| otherwise = (itpointer %~ invItemUpdate i)
|
||||
itpointer = creatures . ix (_crID cr) . crInv . ix i
|
||||
|
||||
itemUpdate :: Creature -> Int -> Item -> Item
|
||||
itemUpdate cr i
|
||||
| i == _crInvSel cr = heldItemUpdate i
|
||||
| otherwise = invItemUpdate i
|
||||
|
||||
doItemTargeting :: Int -> Creature -> World -> World
|
||||
doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of
|
||||
Nothing -> w
|
||||
|
||||
@@ -23,6 +23,8 @@ applyTerminalString "LOADME" = (uvWorld . creatures . ix 0 . crInv .~ stackedInv
|
||||
. (uvWorld . creatures . ix 0 . crInvCapacity .~ 50)
|
||||
applyTerminalString "LA" = (uvWorld . creatures . ix 0 . crInv .~ inventoryA)
|
||||
. (uvWorld . creatures . ix 0 . crInvCapacity .~ 50)
|
||||
applyTerminalString "LB" = (uvWorld . creatures . ix 0 . crInv .~ inventoryB)
|
||||
. (uvWorld . creatures . ix 0 . crInvCapacity .~ 50)
|
||||
applyTerminalString "GODON" = uvWorld . creatures . ix 0 . crApplyDamage .~ applyNoDamage
|
||||
applyTerminalString "GODOFF" = uvWorld . creatures . ix 0 . crApplyDamage .~ defaultApplyDamage
|
||||
applyTerminalString "LOADTEST" = (uvWorld . creatures . ix 0 . crInv .~ testInventory)
|
||||
|
||||
+1
-1
@@ -308,7 +308,7 @@ updateCloud w c
|
||||
-- the following only tests for the first collision with a wall
|
||||
hitWl = collidePointAnyWallsReflect oldPos2 newPos2 $ wallsNearPoint newPos2 w
|
||||
finalPos = addZ (min 74 npz) $ maybe newPos2 fst hitWl
|
||||
-- allowing clouds to height 75 causes graphical glitches 22.05.23
|
||||
-- allowing clouds at/above height 75 causes graphical glitches 22.05.23
|
||||
finalVel = addZ nvz $ maybe newVel2 snd hitWl
|
||||
|
||||
--updateCloud :: World -> Cloud -> Maybe Cloud
|
||||
|
||||
Reference in New Issue
Block a user