This commit is contained in:
2025-06-26 12:17:08 +01:00
parent d0f20da9f1
commit ab82bcbe20
9 changed files with 103 additions and 117 deletions
-1
View File
@@ -29,7 +29,6 @@ import Geometry.Data
data ItemUse
= UseHeld
| UseEquip
| UseAttach {_uaParams :: AttachParams}
| UseInt {_uInt :: Int}
| UseNothing
+1 -1
View File
@@ -22,7 +22,7 @@ import Geometry
import Picture
defaultEquipment :: Item
defaultEquipment = defaultHeldItem & itUse .~ UseEquip
defaultEquipment = defaultHeldItem & itUse .~ UseNothing
defaultFlIt :: FloorItem
defaultFlIt = FlIt{_flItRot = 0, _flIt = defaultHeldItem, _flItPos = V2 0 0, _flItID = 0}
+25 -17
View File
@@ -82,13 +82,15 @@ hammerCheck ::
World
hammerCheck f pt it cr w
| BurstTrigger is <- itemTriggerType (it ^. ldtValue)
, pt == InitialPress = w & f it cr & cWorld . lWorld . delayedEvents .++~ map g is
, pt == InitialPress =
w & f it cr & cWorld . lWorld . delayedEvents .++~ map g is
| BurstTrigger{} <- itemTriggerType (it ^. ldtValue) = w
| VolleyGunTrigger i <- itemTriggerType (it ^. ldtValue)
, pt == InitialPress = let (is,gen) = getVolleyBurst i (w ^. randGen)
in w & f it cr
& cWorld . lWorld . delayedEvents .++~ map g is
& randGen .~ gen
, pt == InitialPress =
let (is, gen) = getVolleyBurst i (w ^. randGen)
in w & f it cr
& cWorld . lWorld . delayedEvents .++~ map g is
& randGen .~ gen
| VolleyGunTrigger{} <- itemTriggerType (it ^. ldtValue) = w
| t <- itemTriggerType (it ^. ldtValue)
, t == HammerTrigger || t == AlwaysSingleTrigger
@@ -99,10 +101,10 @@ hammerCheck f pt it cr w
where
g x = (x, WdWdBurstFireRepetition (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
getVolleyBurst :: (Random a, RandomGen b, Num a) => Int -> b -> ([a], b)
getVolleyBurst i g = let (is,g') = runState (replicateM (i-1) (state $ randomR (0,6))) g
in (scanl1 (+) is, g')
getVolleyBurst i g =
let (is, g') = runState (replicateM (i -1) (state $ randomR (0, 6))) g
in (scanl1 (+) is, g')
{- | Applies a world effect after an item use cooldown check.
input buffering?
@@ -224,7 +226,7 @@ heldItemMuzzles = \case
BLUNDERBUSS -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15)]
GRAPECANNON _ -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15)]
TORCH -> dbwMuzzles & ix 0 . mzPos .~ V2 10 0
VOLLEYGUN {} -> error "should get volleygun muzzles earlier"
VOLLEYGUN{} -> error "should get volleygun muzzles earlier"
FLAMETHROWER -> flameMuzzles
FLAMESPITTER -> flameMuzzles & ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
RLAUNCHER ->
@@ -340,15 +342,21 @@ doHeldUseEffect t cr w = case t ^. ldtValue . itType of
Just [_] -> fromMaybe w $ do
let (is, g) = runState (shuffle [0 .. j -1]) $ w ^. randGen
i <- itm ^? itLocation . ilInvID
return $ w
& randGen .~ g
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itParams . unfiredBarrels %~ const is
Just (_:_:_) -> fromMaybe w $ do
return $
w
& randGen .~ g
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itParams
. unfiredBarrels
%~ const is
Just (_ : _ : _) -> fromMaybe w $ do
i <- itm ^? itLocation . ilInvID
return $ w
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itParams . unfiredBarrels %~ tail
return $
w
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itParams
. unfiredBarrels
%~ tail
_ -> w
HELD ALTERIFLE -> fromMaybe w $ do
i <- t ^? ldtValue . itLocation . ilInvID
+1 -3
View File
@@ -233,9 +233,7 @@ closeButtonToSelectionItem w i = do
btText :: Button -> String
btText bt = case _btEvent bt of
ButtonPress {} -> "BUTTON"
ButtonSwitch {_btOn = t} -> case t of
True -> "SWITCH\\"
False -> "SWITCH/"
ButtonSwitch {_btOn = t} -> if t then "SWITCH\\" else "SWITCH/"
ButtonAccessTerminal -> "TERMINAL"
closeItemToTextPictures :: FloorItem -> ([String], Color)
+4 -24
View File
@@ -1,7 +1,6 @@
module Dodge.LevelGen.Switch (
makeSwitch,
makeButton,
makeSwitchSPic,
drawSwitchWire,
) where
@@ -21,9 +20,7 @@ makeButton ::
Button
makeButton col eff =
defaultButton
{ -- { _btEvent = ButtonPress BtInactive ButtonDoNothing click1S eff col
_btEvent = ButtonPress False eff col
-- , _btState = BtOff
{ _btEvent = ButtonPress False eff col
}
-- TODO remove duplication
@@ -41,23 +38,6 @@ drawSwitchWire col1 col2 bt
]
)
makeSwitchSPic ::
Color ->
Color ->
-- | Switch on effect
WdWd ->
-- | Switch off effect
WdWd ->
Button
makeSwitchSPic c1 c2 effOn effOff =
defaultButton & btEvent .~ ButtonSwitch effOn effOff c1 c2 False
makeSwitch ::
Color ->
Color ->
-- | Switch on effect
WdWd ->
-- | Switch off effect
WdWd ->
Button
makeSwitch col1 col2 = makeSwitchSPic col1 col2
makeSwitch :: Color -> Color -> WdWd -> WdWd -> Button
makeSwitch c1 c2 fon foff =
defaultButton & btEvent .~ ButtonSwitch fon foff c1 c2 False
+1 -1
View File
@@ -100,7 +100,7 @@ damageFlesh dm _ w = w & case dm of
]
. makeDustAt Flesh 50 (addZ 20 (outTo p t))
Blunt _ p _ -> randsound p [hitS]
Shattering _ _ _ -> id
Shattering {} -> id
Crushing{} -> id
Explosive{} -> id
Sparking{} -> id
+2 -2
View File
@@ -18,7 +18,7 @@ triggerSwitchSPic c1 c2 ps = psPtCont ps (PutTrigger False) $
pContID
ps
( PutButton
( makeSwitchSPic
( makeSwitch
c1 c2
(SetTrigger True $ trigid tp)
(SetTrigger False $ trigid tp)
@@ -36,7 +36,7 @@ triggerSwitchSPicLight c1 c2 ps = psPtCont ps (PutTrigger False) $
Just $
pContID
ps
(PutButton (makeSwitchSPic c1 c2 (oneff lsid $ trigid tp) (offeff lsid $ trigid tp)))
(PutButton (makeSwitch c1 c2 (oneff lsid $ trigid tp) (offeff lsid $ trigid tp)))
(const Nothing)
where
thels = lsColPosRad (V3 0.5 0 0) (V3 0 0 78) 75
+1 -2
View File
@@ -15,6 +15,5 @@ doWdBl wb w = case wb of
dr <- w ^? cWorld . lWorld . doors . ix i
return (DoorHalfway == _drStatus dr)
WdBlCrFilterNearPoint r p t -> any (crNearPoint r p) (IM.filter (doCrBl t) (w ^. cWorld . lWorld . creatures))
WdBlBtOn btid -> (w ^?! cWorld . lWorld . buttons . ix btid . btEvent . btOn) -- unsafe
-- WdBlBtNotOff btid -> (w ^?! cWorld . lWorld . buttons . ix btid . btState) /= BtOff -- unsafe
WdBlBtOn btid -> w ^?! cWorld . lWorld . buttons . ix btid . btEvent . btOn -- unsafe
WdBlNegate x -> not $ doWdBl x w