This commit is contained in:
2022-06-08 22:14:50 +01:00
parent b90e8a2118
commit 970858e129
9 changed files with 41 additions and 40 deletions
+1
View File
@@ -86,6 +86,7 @@ combineTwoModuleMaps = mergeA
g _ md EMPTYMODULE = ([],md) g _ md EMPTYMODULE = ([],md)
g _ md2 md1 = ([rm "REPLACES" md1 ++ rm " WITH" md2],md2) g _ md2 md1 = ([rm "REPLACES" md1 ++ rm " WITH" md2],md2)
rm str md = str ++ " "++fullModuleName md rm str md = str ++ " "++fullModuleName md
-- g above could be a monoid of some description...
fullModuleName :: ItemModuleType -> String fullModuleName :: ItemModuleType -> String
fullModuleName = fromMaybe "EMPTYMODULE" . moduleName fullModuleName = fromMaybe "EMPTYMODULE" . moduleName
+7 -5
View File
@@ -211,12 +211,14 @@ equipmentEffects :: Creature -> World -> World
equipmentEffects cr = flip (foldr $ useEquipment cr) (IM.keys $ _crInvEquipped cr) equipmentEffects cr = flip (foldr $ useEquipment cr) (IM.keys $ _crInvEquipped cr)
-- a loop going over all inventory items -- a loop going over all inventory items
invSideEff :: Creature -> World -> World invSideEff :: Creature -> World -> World
invSideEff cr w = weaponReloadSounds cr invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
$ IM.foldrWithKey f w (_crInv cr)
where where
f i it w' = doItemTargeting i cr w' & case it ^? itEffect . itInvEffect of f i it w' = doItemTargeting i cr w' & maybe id (\g -> g it cr) (it ^? itEffect . ieInv)
Nothing -> id -- Nothing -> id
Just g -> g it cr -- Just g -> g it cr
-- f i it w' = doItemTargeting i cr w' & case it ^? itEffect . ieInv of
-- Nothing -> id
-- Just g -> g it cr
itemUpdate :: Creature -> Int -> Item -> Item itemUpdate :: Creature -> Int -> Item -> Item
itemUpdate cr i itemUpdate cr i
+15 -18
View File
@@ -436,8 +436,8 @@ data PressPlate = PressPlate
} }
data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int} data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int}
data ItemPos data ItemPos
= InInv { _itCrId :: Int , _itInvId :: Int } = InInv { _ipCrId :: Int , _ipInvId :: Int }
| OnFloor { _itFlID :: Int } | OnFloor { _ipFlID :: Int }
data ItemUse data ItemUse
= RightUse = RightUse
{ _rUse :: Item -> Creature -> World -> World { _rUse :: Item -> Creature -> World -> World
@@ -549,30 +549,27 @@ data ReloadType
-- I believe this is called every frame, not sure when though -- I believe this is called every frame, not sure when though
data ItEffect data ItEffect
= NoItEffect = NoItEffect
-- | ItSimpleInvEffect
-- {_itInvEffect :: Item -> Creature -> World -> World
-- }
| ItInvEffect | ItInvEffect
{_itInvEffect :: Item -> Creature -> World -> World {_ieInv :: Item -> Creature -> World -> World
,_itEffectCounter :: Int ,_ieCounter :: Int
} }
| ItRewindEffect | ItRewindEffect
{_itInvEffect :: Item -> Creature -> World -> World {_ieInv :: Item -> Creature -> World -> World
,_itStoredWorlds :: [World] ,_ieStoredWorlds :: [World]
} }
| ItEffect | ItEffect
{_itInvEffect :: Item -> Creature -> World -> World {_ieInv :: Item -> Creature -> World -> World
,_itFloorEffect :: Int -> World -> World ,_ieFloor :: Int -> World -> World
,_itEffectCounter :: Int ,_ieCounter :: Int
} }
| ItInvEffectID | ItInvEffectID
{_itInvEffect :: Item -> Creature -> World -> World {_ieInv :: Item -> Creature -> World -> World
,_itEffectID :: Maybe Int ,_ieMID :: Maybe Int
} } -- the duplication of ieMID may cause errors...
| ItInvEffectDrop | ItInvEffectDrop
{ _itInvEffect :: Item -> Creature -> World -> World { _ieInv :: Item -> Creature -> World -> World
, _itEffectDrop :: Item -> Creature -> World -> World , _ieDrop :: Item -> Creature -> World -> World
, _itEffectMID :: Maybe Int , _ieMID :: Maybe Int
} }
data IntID a = IntID Int a data IntID a = IntID Int a
+1 -1
View File
@@ -70,7 +70,7 @@ rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itCons
rmf <- itm ^? itUse . eqEq . eqOnRemove rmf <- itm ^? itUse . eqEq . eqOnRemove
return $ rmf itm cr return $ rmf itm cr
doanyitemeffect = fromMaybe id $ do doanyitemeffect = fromMaybe id $ do
rmf <- itm ^? itEffect . itEffectDrop rmf <- itm ^? itEffect . ieDrop
return $ rmf itm cr return $ rmf itm cr
removeAnySlotEquipment = case w ^? creatures . ix cid . crInvEquipped . ix invid of removeAnySlotEquipment = case w ^? creatures . ix cid . crInvEquipped . ix invid of
Just epos -> creatures . ix cid . crEquipment . at epos .~ Nothing Just epos -> creatures . ix cid . crEquipment . at epos .~ Nothing
+8 -8
View File
@@ -136,8 +136,8 @@ flatShieldEquipSPic _ =
) )
effectOnEquip :: (Creature -> Item -> World -> World) -> ItEffect effectOnEquip :: (Creature -> Item -> World -> World) -> ItEffect
effectOnEquip f = ItInvEffectID effectOnEquip f = ItInvEffectID
{ _itInvEffect = g f { _ieInv = g f
, _itEffectID = Nothing , _ieMID = Nothing
} }
where where
g f' itm cr w g f' itm cr w
@@ -167,9 +167,9 @@ shieldWallDamage dm _ crid w = case _dmType dm of
_ -> w _ -> w
createShieldWall :: Creature -> Int -> World -> World createShieldWall :: Creature -> Int -> World -> World
createShieldWall cr invid w = case _itEffectID $ _itEffect it of createShieldWall cr invid w = case _ieMID $ _itEffect it of
Nothing -> let (wlid,w') = createWall ((shieldWall crid) {_wlLine = wlline,_wlID = wlid}) w Nothing -> let (wlid,w') = createWall ((shieldWall crid) {_wlLine = wlline,_wlID = wlid}) w
in w' & creatures . ix crid . crInv . ix invid . itEffect . itEffectID ?~ wlid in w' & creatures . ix crid . crInv . ix invid . itEffect . ieMID ?~ wlid
Just wid -> moveWallID wid wlline w Just wid -> moveWallID wid wlline w
where where
crid = _crID cr crid = _crID cr
@@ -183,10 +183,10 @@ createShieldWall cr invid w = case _itEffectID $ _itEffect it of
therot | crIsAiming cr = vNormal therot | crIsAiming cr = vNormal
| otherwise = rotateV (twoFlatHRot cr) . vNormal | otherwise = rotateV (twoFlatHRot cr) . vNormal
removeShieldWall :: Creature -> Int -> World -> World removeShieldWall :: Creature -> Int -> World -> World
removeShieldWall cr invid w = case _itEffectID $ _itEffect it of removeShieldWall cr invid w = case _ieMID $ _itEffect it of
Nothing -> w Nothing -> w
Just wid -> w & deleteWallID wid Just wid -> w & deleteWallID wid
& creatures . ix crid . crInv . ix invid . itEffect . itEffectID .~ Nothing & creatures . ix crid . crInv . ix invid . itEffect . ieMID .~ Nothing
where where
crid = _crID cr crid = _crID cr
it = _crInv (_creatures w IM.! crid) IM.! invid it = _crInv (_creatures w IM.! crid) IM.! invid
@@ -196,8 +196,8 @@ effectOnOffHeld
-> (Creature -> Int -> World -> World) -- ^ effect when not held -> (Creature -> Int -> World -> World) -- ^ effect when not held
-> ItEffect -> ItEffect
effectOnOffHeld f f' = ItInvEffectID effectOnOffHeld f f' = ItInvEffectID
{ _itInvEffect = g { _ieInv = g
, _itEffectID = Nothing , _ieMID = Nothing
} }
where where
g itm cr w g itm cr w
+3 -3
View File
@@ -49,7 +49,7 @@ boostSelfL x itm cr w = case boostPoint x cr w of
(crPos .~ p) (crPos .~ p)
. (crInv . ix invid %~ . (crInv . ix invid %~
ammoEff ammoEff
. (itEffect . itEffectCounter .~ 1) . (itEffect . ieCounter .~ 1)
. (itAttachment .~ ItInt pid) . (itAttachment .~ ItInt pid)
) )
@@ -124,8 +124,8 @@ resetAttachmentID :: ItEffect
resetAttachmentID = ItInvEffect f 0 resetAttachmentID = ItInvEffect f 0
where where
f itm cr w f itm cr w
| _itEffectCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment | _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment
| otherwise = w & pointToIt . itEffect . itEffectCounter -~ 1 | otherwise = w & pointToIt . itEffect . ieCounter -~ 1
where where
iteff = _itEffect itm iteff = _itEffect itm
invid = fromJust $ _itInvPos itm invid = fromJust $ _itInvPos itm
+3 -3
View File
@@ -117,16 +117,16 @@ throwGrenade thePayload cr w = setWp $ removePict $ over props addG w
fuseTime = _itFuseTime $ _itAttachment $ _crInv cr IM.! j fuseTime = _itFuseTime $ _itAttachment $ _crInv cr IM.! j
throwArmReset :: Int -> ItEffect throwArmReset :: Int -> ItEffect
throwArmReset x = ItInvEffect {_itInvEffect = f ,_itEffectCounter = x } throwArmReset x = ItInvEffect {_ieInv = f ,_ieCounter = x }
where where
f itm cr = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i f itm cr = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i
where where
i = fromJust $ _itInvPos itm i = fromJust $ _itInvPos itm
counterDown it counterDown it
| _itEffectCounter (_itEffect it) == 0 = it | _ieCounter (_itEffect it) == 0 = it
& itUse . useHammer . hammerPosition .~ HammerUp & itUse . useHammer . hammerPosition .~ HammerUp
& itEquipPict .~ pictureWeaponAim (\_ -> grenadePic 50) & itEquipPict .~ pictureWeaponAim (\_ -> grenadePic 50)
| otherwise = it & itEffect . itEffectCounter -~ 1 | otherwise = it & itEffect . ieCounter -~ 1
--flameGrenade :: Item --flameGrenade :: Item
--flameGrenade = grenade { --flameGrenade = grenade {
+1 -1
View File
@@ -324,7 +324,7 @@ moveRemoteShell cid itid pj w
newPos = oldPos +.+ vel newPos = oldPos +.+ vel
newdir newdir
| SDL.ButtonRight `S.member` _mouseButtons w | SDL.ButtonRight `S.member` _mouseButtons w
&& w ^? creatures . ix cid . crInvSel == w ^? itemPositions . ix itid . itInvId && w ^? creatures . ix cid . crInvSel == w ^? itemPositions . ix itid . ipInvId
= _cameraRot w + argV (_mousePos w) = _cameraRot w + argV (_mousePos w)
| otherwise = _pjDir pj | otherwise = _pjDir pj
accel = rotateV newdir (V2 2 0) accel = rotateV newdir (V2 2 0)
+2 -1
View File
@@ -116,7 +116,8 @@ subInventoryDisplay subinv cfig w = case subinv of
where where
closeobjectcursor = case selectedCloseObject w of closeobjectcursor = case selectedCloseObject w of
Nothing -> mempty Nothing -> mempty
Just (i,co) -> listCursorNS clObjFloatIn 0 cfig (selNumPos i w) (closeObjectCol co) topInvW (invSelSize i w) Just (i,co) -> listCursorNS
clObjFloatIn 0 cfig (selNumPos i w) (closeObjectCol co) topInvW (invSelSize i w)
itcol = fromMaybe (greyN 0.5) (it ^? _Just . itInvColor) itcol = fromMaybe (greyN 0.5) (it ^? _Just . itInvColor)
cr = you w cr = you w
it = yourItem w it = yourItem w