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