Commit before door refactor
This commit is contained in:
@@ -220,8 +220,13 @@ itemUpdate cr i
|
|||||||
| i == crSel cr = baseupdate True
|
| i == crSel cr = baseupdate True
|
||||||
| otherwise = baseupdate False
|
| otherwise = baseupdate False
|
||||||
where
|
where
|
||||||
baseupdate bool = (itUse %~ useUpdate) . (itInvPos ?~ i) . (itIsHeld .~ bool)
|
baseupdate bool = updateAutoRecharge . (itUse %~ useUpdate) . (itInvPos ?~ i) . (itIsHeld .~ bool)
|
||||||
|
updateAutoRecharge :: Item -> Item
|
||||||
|
updateAutoRecharge it = case _itConsumption it of
|
||||||
|
AutoRecharging l m t p
|
||||||
|
| l < m && p <= 0 -> it & itConsumption .~ AutoRecharging (l+1) m t t
|
||||||
|
| l < m -> it & itConsumption . arProgress -~ 1
|
||||||
|
_ -> it
|
||||||
doItemTargeting :: Int -> Creature -> World -> World
|
doItemTargeting :: Int -> Creature -> World -> World
|
||||||
doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of
|
doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of
|
||||||
Nothing -> w
|
Nothing -> w
|
||||||
|
|||||||
@@ -491,6 +491,12 @@ data ItemConsumption
|
|||||||
, _laCycle :: [LoadAction]
|
, _laCycle :: [LoadAction]
|
||||||
, _laProgress :: Maybe [LoadAction]
|
, _laProgress :: Maybe [LoadAction]
|
||||||
}
|
}
|
||||||
|
| AutoRecharging
|
||||||
|
{ _arLoaded :: Int
|
||||||
|
, _arMax :: Int
|
||||||
|
, _arTime :: Int
|
||||||
|
, _arProgress :: Int
|
||||||
|
}
|
||||||
| ChargeableAmmo
|
| ChargeableAmmo
|
||||||
{ _wpMaxCharge :: Int
|
{ _wpMaxCharge :: Int
|
||||||
, _wpCharge :: Int
|
, _wpCharge :: Int
|
||||||
@@ -1011,6 +1017,7 @@ data Door = Door
|
|||||||
, _drClosePos :: (Point2,Point2)
|
, _drClosePos :: (Point2,Point2)
|
||||||
, _drHP :: Int
|
, _drHP :: Int
|
||||||
, _drDeath :: Door -> World -> World
|
, _drDeath :: Door -> World -> World
|
||||||
|
, _drSpeed :: Float
|
||||||
}
|
}
|
||||||
data DoorStatus = DoorOpen | DoorClosed | DoorHalfway | DoorInt Int
|
data DoorStatus = DoorOpen | DoorClosed | DoorHalfway | DoorInt Int
|
||||||
deriving (Eq, Ord, Show)
|
deriving (Eq, Ord, Show)
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ defaultDoor = Door
|
|||||||
, _drClosePos = (0,0)
|
, _drClosePos = (0,0)
|
||||||
, _drHP = 10000
|
, _drHP = 10000
|
||||||
, _drDeath = const id
|
, _drDeath = const id
|
||||||
|
, _drSpeed = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import Geometry
|
|||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
|
defaultLeftLoadable :: ItemConsumption
|
||||||
|
defaultLeftLoadable = AutoRecharging 10 10 100 100
|
||||||
|
|
||||||
defaultLoadable :: ItemConsumption
|
defaultLoadable :: ItemConsumption
|
||||||
defaultLoadable = LoadableAmmo
|
defaultLoadable = LoadableAmmo
|
||||||
{ _laAmmoType = GenericAmmo
|
{ _laAmmoType = GenericAmmo
|
||||||
@@ -103,6 +106,7 @@ defaultAimParams = AimParams
|
|||||||
-- TODO change this
|
-- TODO change this
|
||||||
defaultLeftItem :: Item
|
defaultLeftItem :: Item
|
||||||
defaultLeftItem = defaultWeapon
|
defaultLeftItem = defaultWeapon
|
||||||
|
& itConsumption .~ defaultLeftLoadable
|
||||||
|
|
||||||
defaultWeapon :: Item
|
defaultWeapon :: Item
|
||||||
defaultWeapon = defaultItem
|
defaultWeapon = defaultItem
|
||||||
|
|||||||
+10
-4
@@ -2,8 +2,9 @@
|
|||||||
--{-# OPTIONS_GHC -Wno-unused-imports #-}
|
--{-# OPTIONS_GHC -Wno-unused-imports #-}
|
||||||
{- | The tree of rooms that make up a level. -}
|
{- | The tree of rooms that make up a level. -}
|
||||||
module Dodge.Floor
|
module Dodge.Floor
|
||||||
( initialRoomTree
|
-- ( initialRoomTree
|
||||||
) where
|
-- )
|
||||||
|
where
|
||||||
import Dodge.Cleat
|
import Dodge.Cleat
|
||||||
--import Geometry.Data
|
--import Geometry.Data
|
||||||
--import Dodge.Data
|
--import Dodge.Data
|
||||||
@@ -40,9 +41,15 @@ initialAnoTree :: Annotation
|
|||||||
initialAnoTree = OnwardList
|
initialAnoTree = OnwardList
|
||||||
$ intersperse (AnTree corDoor)
|
$ intersperse (AnTree corDoor)
|
||||||
[ IntAnno $ AnTree . startRoom
|
[ IntAnno $ AnTree . startRoom
|
||||||
|
, AnRoom slowDoorRoom
|
||||||
, AnTree firstBreather
|
, AnTree firstBreather
|
||||||
|
, AnTree $ telRoomLev 1 >>= rToOnward "telRoomLev" . pure . cleatOnward
|
||||||
|
]
|
||||||
|
|
||||||
|
extraAnoList :: [Annotation]
|
||||||
|
extraAnoList =
|
||||||
-- , (SpecificRoom . return . tToBTree $ treePost [corridor,corridor,cleatOnward corridor])
|
-- , (SpecificRoom . return . tToBTree $ treePost [corridor,corridor,cleatOnward corridor])
|
||||||
, AnRoom $ roomCCrits 10
|
[ AnRoom $ roomCCrits 10
|
||||||
, AnTree $ tToBTree "spawners" <$> spawnerRoom
|
, AnTree $ tToBTree "spawners" <$> spawnerRoom
|
||||||
, AnRoom pistolerRoom
|
, AnRoom pistolerRoom
|
||||||
, AnRoom doubleCorridorBarrels
|
, AnRoom doubleCorridorBarrels
|
||||||
@@ -101,7 +108,6 @@ initialAnoTree = OnwardList
|
|||||||
-- ,[TreasureAno [addArmour autoCrit,addArmour autoCrit] [launcher]]
|
-- ,[TreasureAno [addArmour autoCrit,addArmour autoCrit] [launcher]]
|
||||||
-- ,[Corridor]
|
-- ,[Corridor]
|
||||||
,AnTree $ randomFourCornerRoom [] >>= rToOnward "randomFourCornerRoom" . pure . cleatOnward
|
,AnTree $ randomFourCornerRoom [] >>= rToOnward "randomFourCornerRoom" . pure . cleatOnward
|
||||||
,AnTree $ telRoomLev 1 >>= rToOnward "telRoomLev" . pure . cleatOnward
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{- | A test level tree. -}
|
{- | A test level tree. -}
|
||||||
|
|||||||
@@ -40,10 +40,18 @@ itemDisplay it = itemDisplayWithNumber (showConsumption (_itConsumption it)) it
|
|||||||
showSelectedConsumption :: Creature -> ItemConsumption -> String
|
showSelectedConsumption :: Creature -> ItemConsumption -> String
|
||||||
showSelectedConsumption cr ic = case ic of
|
showSelectedConsumption cr ic = case ic of
|
||||||
LoadableAmmo{} -> showReloadProgress cr ic
|
LoadableAmmo{} -> showReloadProgress cr ic
|
||||||
|
AutoRecharging {} -> showAutoRechargeProgress ic
|
||||||
ChargeableAmmo{} -> show $ _wpCharge ic
|
ChargeableAmmo{} -> show $ _wpCharge ic
|
||||||
ItemItselfConsumable{} -> show (_icAmount ic)
|
ItemItselfConsumable{} -> show (_icAmount ic)
|
||||||
NoConsumption -> ""
|
NoConsumption -> ""
|
||||||
|
|
||||||
|
showAutoRechargeProgress :: ItemConsumption -> String
|
||||||
|
showAutoRechargeProgress ic
|
||||||
|
| l < _arMax ic = show (_arProgress ic) ++ "C" ++ show l
|
||||||
|
| otherwise = show l
|
||||||
|
where
|
||||||
|
l = _arLoaded ic
|
||||||
|
|
||||||
showReloadProgress :: Creature -> ItemConsumption -> String
|
showReloadProgress :: Creature -> ItemConsumption -> String
|
||||||
showReloadProgress cr ic = case cr ^?! crInvSel . iselAction of
|
showReloadProgress cr ic = case cr ^?! crInvSel . iselAction of
|
||||||
ReloadAction i la _ -> show i ++ showLoadActionType la (_laLoaded ic)
|
ReloadAction i la _ -> show i ++ showLoadActionType la (_laLoaded ic)
|
||||||
@@ -59,6 +67,7 @@ showLoadProgress x mlas = case mlas ^? _Just . ix 0 of
|
|||||||
showConsumption :: ItemConsumption -> String
|
showConsumption :: ItemConsumption -> String
|
||||||
showConsumption ic = case ic of
|
showConsumption ic = case ic of
|
||||||
LoadableAmmo{} -> showLoadProgress (_laLoaded ic) (_laProgress ic)
|
LoadableAmmo{} -> showLoadProgress (_laLoaded ic) (_laProgress ic)
|
||||||
|
AutoRecharging {} -> showAutoRechargeProgress ic
|
||||||
ChargeableAmmo{} -> show $ _wpCharge ic
|
ChargeableAmmo{} -> show $ _wpCharge ic
|
||||||
ItemItselfConsumable{} -> show (_icAmount ic)
|
ItemItselfConsumable{} -> show (_icAmount ic)
|
||||||
NoConsumption -> ""
|
NoConsumption -> ""
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ ammoHammerCheck eff it cr w
|
|||||||
setHammerDown = creatures . ix cid . crInv . ix (crSel cr) . itUse
|
setHammerDown = creatures . ix cid . crInv . ix (crSel cr) . itUse
|
||||||
. useHammer . hammerPosition .~ HammerDown
|
. useHammer . hammerPosition .~ HammerDown
|
||||||
|
|
||||||
|
itUseCharge :: Int -> Item -> Item
|
||||||
|
itUseCharge x = itConsumption . arLoaded %~ (max 0 . subtract x)
|
||||||
|
|
||||||
itUseAmmo :: Int -> Item -> Item
|
itUseAmmo :: Int -> Item -> Item
|
||||||
itUseAmmo x = itConsumption . laLoaded %~ (max 0 . subtract x)
|
itUseAmmo x = itConsumption . laLoaded %~ (max 0 . subtract x)
|
||||||
@@ -353,7 +355,7 @@ shootL
|
|||||||
-> World
|
-> World
|
||||||
shootL f item cr w
|
shootL f item cr w
|
||||||
| fireCondition = f item cr w & pointerToItem %~
|
| fireCondition = f item cr w & pointerToItem %~
|
||||||
( itUseAmmo 1
|
( itUseCharge 1
|
||||||
. (itUse . useDelay . rateTime .~ _rateMax (_useDelay (_itUse item))) )
|
. (itUse . useDelay . rateTime .~ _rateMax (_useDelay (_itUse item))) )
|
||||||
-- | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
-- | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
@@ -361,9 +363,8 @@ shootL f item cr w
|
|||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
invid = fromJust $ _itInvPos item
|
invid = fromJust $ _itInvPos item
|
||||||
pointerToItem = creatures . ix cid . crInv . ix invid
|
pointerToItem = creatures . ix cid . crInv . ix invid
|
||||||
fireCondition = crWeaponReady cr
|
fireCondition = _rateTime (_useDelay (_itUse item)) == 0
|
||||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
&& _arLoaded (_itConsumption item) > 0
|
||||||
&& _laLoaded (_itConsumption item) > 0
|
|
||||||
-- reloadCondition = _laLoaded (_itConsumption item) == 0
|
-- reloadCondition = _laLoaded (_itConsumption item) == 0
|
||||||
withItem :: (Item -> ChainEffect) -> ChainEffect
|
withItem :: (Item -> ChainEffect) -> ChainEffect
|
||||||
withItem g f it = g it f it
|
withItem g f it = g it f it
|
||||||
|
|||||||
@@ -30,6 +30,13 @@ putDoubleDoorThen pathing col cond soff a b speed cont
|
|||||||
doorbetween pa pb = pt0 $ PutSlideDr pathing col cond soff pa pb speed
|
doorbetween pa pb = pt0 $ PutSlideDr pathing col cond soff pa pb speed
|
||||||
half = 0.5 *.* (a +.+ b)
|
half = 0.5 *.* (a +.+ b)
|
||||||
|
|
||||||
|
--doorBetween pathing col cond soff pa pb speed g = case divideLine 80 pa pb of
|
||||||
|
-- [x,y] -> \_ -> Just (pt0 (PutSlideDr pathing col cond soff x y speed) g)
|
||||||
|
-- (x:y:zs) -> foldr f g (zip (x:y:zs) (y:zs))
|
||||||
|
-- where
|
||||||
|
-- f :: (Point2,Point2) -> (Placement -> Maybe Placement) -> (Placement -> Maybe Placement)
|
||||||
|
-- f (a,b) h = \pl -> Just (pt0 (PutSlideDr pathing col cond (soff - dist y pb) a b speed) h)
|
||||||
|
|
||||||
putAutoDoor :: Point2 -> Point2 -> Placement
|
putAutoDoor :: Point2 -> Point2 -> Placement
|
||||||
putAutoDoor a b = PlacementUsingPos (addZ 0 a)
|
putAutoDoor a b = PlacementUsingPos (addZ 0 a)
|
||||||
$ \az -> PlacementUsingPos (addZ 0 b)
|
$ \az -> PlacementUsingPos (addZ 0 b)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module Dodge.Placement.PlaceSpot.TriggerDoor
|
|||||||
, plSlideDoor
|
, plSlideDoor
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.Base
|
||||||
import Dodge.Default.Wall
|
import Dodge.Default.Wall
|
||||||
import Dodge.Default.Door
|
import Dodge.Default.Door
|
||||||
import Dodge.Wall.Move
|
import Dodge.Wall.Move
|
||||||
@@ -74,14 +75,21 @@ doorMechanismStepwise nsteps drid wlids pss dr w
|
|||||||
newps = uncurry (rectanglePairs 9) (pss !! n)
|
newps = uncurry (rectanglePairs 9) (pss !! n)
|
||||||
-- it is not at all clear that the zoning selects the correct walls
|
-- it is not at all clear that the zoning selects the correct walls
|
||||||
|
|
||||||
doorMechanism :: Int -> Float -> [(Int,(Point2,Point2),(Point2,Point2))] -> Door -> World -> World
|
doorMechanism :: [(Int,(Point2,Point2),(Point2,Point2))] -> Door -> World -> World
|
||||||
doorMechanism drid speed wlidOpCps dr w
|
doorMechanism wlidOpCps dr w
|
||||||
| toOpen && dstatus /= DoorOpen = moveUpdate $ foldl' doOpen w wlidOpCps
|
| toOpen && dstatus /= DoorOpen = moveUpdate $ foldl' doOpen w wlidOpCps
|
||||||
& doors . ix drid . drPos %~ mvPs speed (_drOpenPos dr)
|
& doors . ix drid . drPos %~ mvPs speed (_drOpenPos dr)
|
||||||
| not toOpen && dstatus /= DoorClosed = moveUpdate $ foldl' doClose w wlidOpCps
|
| not toOpen && dstatus /= DoorClosed = moveUpdate $ foldl' doClose w wlidOpCps
|
||||||
& doors . ix drid . drPos %~ mvPs speed (_drClosePos dr)
|
& doors . ix drid . drPos %~ mvPs speed (_drClosePos dr)
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
where
|
where
|
||||||
|
toOpen = _drTrigger dr w
|
||||||
|
mvDir
|
||||||
|
| toOpen && dist dpos dop > 1 = Just $ mvPointTowardAtSpeed speed dop dpos
|
||||||
|
| dist dpos dcp > 1 = Just $ mvPointTowardAtSpeed speed dcp dpos
|
||||||
|
| otherwise = Nothing
|
||||||
|
speed = _drSpeed dr
|
||||||
|
drid = _drID dr
|
||||||
moveUpdate = playSound . setStatus
|
moveUpdate = playSound . setStatus
|
||||||
playSound = soundContinue (WallSound drid) dpos slideDoorS (Just 1)
|
playSound = soundContinue (WallSound drid) dpos slideDoorS (Just 1)
|
||||||
dpos = snd $ _drPos dr
|
dpos = snd $ _drPos dr
|
||||||
@@ -91,7 +99,6 @@ doorMechanism drid speed wlidOpCps dr w
|
|||||||
| dist dpos dop < 1 = doors . ix drid . drStatus .~ DoorOpen
|
| dist dpos dop < 1 = doors . ix drid . drStatus .~ DoorOpen
|
||||||
| dist dpos dcp < 1 = doors . ix drid . drStatus .~ DoorClosed
|
| dist dpos dcp < 1 = doors . ix drid . drStatus .~ DoorClosed
|
||||||
| otherwise = doors . ix drid . drStatus .~ DoorHalfway
|
| otherwise = doors . ix drid . drStatus .~ DoorHalfway
|
||||||
toOpen = _drTrigger dr w
|
|
||||||
dstatus = _drStatus dr
|
dstatus = _drStatus dr
|
||||||
doOpen w' (wlid,opp, _) = moveWallIDToward wlid speed opp w'
|
doOpen w' (wlid,opp, _) = moveWallIDToward wlid speed opp w'
|
||||||
doClose w' (wlid,_ ,clp) = moveWallIDToward wlid speed clp w'
|
doClose w' (wlid,_ ,clp) = moveWallIDToward wlid speed clp w'
|
||||||
@@ -116,10 +123,11 @@ plSlideDoor isPathable col cond shiftOffset a b speed gw
|
|||||||
, _drWallIDs = IS.fromList wlids
|
, _drWallIDs = IS.fromList wlids
|
||||||
, _drStatus = DoorClosed
|
, _drStatus = DoorClosed
|
||||||
, _drTrigger = cond
|
, _drTrigger = cond
|
||||||
, _drMech = doorMechanism drid speed (zip3 wlids shiftedPairs pairs)
|
, _drMech = doorMechanism (zip3 wlids shiftedPairs pairs)
|
||||||
, _drPos = (a,b)
|
, _drPos = (a,b)
|
||||||
, _drOpenPos = (shiftLeft a,shiftLeft b)
|
, _drOpenPos = (shiftLeft a,shiftLeft b)
|
||||||
, _drClosePos = (a,b)
|
, _drClosePos = (a,b)
|
||||||
|
, _drSpeed = speed
|
||||||
}
|
}
|
||||||
addDoorWalls w' = foldl' (addDoorWall drid col isPathable) w' $ zip wlids pairs
|
addDoorWalls w' = foldl' (addDoorWall drid col isPathable) w' $ zip wlids pairs
|
||||||
pairs = rectanglePairs 9 a b
|
pairs = rectanglePairs 9 a b
|
||||||
|
|||||||
@@ -111,15 +111,14 @@ addButtonSlowDoor x h rm = do
|
|||||||
(rprBool (isUnusedLnkType InLink))
|
(rprBool (isUnusedLnkType InLink))
|
||||||
$ \btplmnt -> Just $ putDoubleDoorThen False col (cond' $ fromJust $ _plMID btplmnt)
|
$ \btplmnt -> Just $ putDoubleDoorThen False col (cond' $ fromJust $ _plMID btplmnt)
|
||||||
30 (V2 0 h) (V2 x h) 2
|
30 (V2 0 h) (V2 x h) 2
|
||||||
$ \dr1 dr2 -> amountedlight dr1 50
|
$ \dr1 dr2 ->
|
||||||
|
amountedlight dr1 50
|
||||||
$ amountedlight dr1 (-50)
|
$ amountedlight dr1 (-50)
|
||||||
$ amountedlight dr2 50
|
$ amountedlight dr2 50
|
||||||
$ amountedlight dr2 (-50)
|
$ amountedlight dr2 (-50)
|
||||||
Nothing
|
Nothing
|
||||||
getdoorpos drid w = let Just (a,b) = w ^? doors . ix drid . drPos
|
getdoorpos drid w = let Just (a,b) = w ^? doors . ix drid . drPos
|
||||||
in (b, argV (a-.-b))
|
in (b, argV (a-.-b))
|
||||||
--butPosCond = useRoomPosCond $ \rp _ -> isUnusedLnk' rp && yV2 (_rpPos rp) < 0.5 * h
|
|
||||||
--butPosCond _ = True -- y < h
|
|
||||||
col = dim $ light red
|
col = dim $ light red
|
||||||
cond' btid w = w ^? buttons . ix btid . btState /= Just BtOff
|
cond' btid w = w ^? buttons . ix btid . btState /= Just BtOff
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module Dodge.Wall.Move
|
|||||||
, moveWallIDUnsafe
|
, moveWallIDUnsafe
|
||||||
, moveWall
|
, moveWall
|
||||||
, moveWallIDToward
|
, moveWallIDToward
|
||||||
|
, translateWallID
|
||||||
, mvPs
|
, mvPs
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
@@ -11,6 +12,7 @@ import Dodge.Base
|
|||||||
import Geometry
|
import Geometry
|
||||||
import Dodge.Wall.Zone
|
import Dodge.Wall.Zone
|
||||||
|
|
||||||
|
import Data.Maybe
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
|
|
||||||
@@ -29,6 +31,16 @@ moveWall wlid wl wlline w = w & walls . ix wlid .~ newwl
|
|||||||
& insertWallInZones newwl
|
& insertWallInZones newwl
|
||||||
where
|
where
|
||||||
newwl = wl {_wlLine = wlline}
|
newwl = wl {_wlLine = wlline}
|
||||||
|
|
||||||
|
translateWallID :: Int -> Point2 -> World -> World
|
||||||
|
translateWallID wlid p w = fromMaybe w $ do
|
||||||
|
oldwl <- w ^? walls . ix wlid
|
||||||
|
let newwl = oldwl & wlLine . each +~ p
|
||||||
|
return $ w
|
||||||
|
& walls . ix wlid .~ newwl
|
||||||
|
& deleteWallFromZones oldwl
|
||||||
|
& insertWallInZones newwl
|
||||||
|
|
||||||
moveWallIDToward :: Int -> Float -> (Point2,Point2) -> World -> World
|
moveWallIDToward :: Int -> Float -> (Point2,Point2) -> World -> World
|
||||||
moveWallIDToward wlid speed ep w = moveWall wlid wl newwlline w
|
moveWallIDToward wlid speed ep w = moveWall wlid wl newwlline w
|
||||||
where
|
where
|
||||||
|
|||||||
Reference in New Issue
Block a user