Remove left click/hotkey item data types

This commit is contained in:
2024-12-19 21:55:18 +00:00
parent 910c683eac
commit 3da9490dd4
34 changed files with 708 additions and 883 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
"_gameplay_rotate_to_wall": true,
"_graphics_bloom": true,
"_graphics_cloud_shadows": true,
"_graphics_distortion_resolution": "HalfRes",
"_graphics_distortion_resolution": "FullRes",
"_graphics_distortions": true,
"_graphics_downsize_resolution": "EighthRes",
"_graphics_num_shadow_casters": "NumShadowCasters20",
+5 -5
View File
@@ -2,11 +2,11 @@ digraph {
graph [rankdir=LR];
subgraph 1 {
1 [shape=box
,label="LEFT {_ibtLeft = SCROLLWATCH}"];
,label="HELD {_ibtHeld = TIMESCROLLER}"];
2 [shape=box
,label="LEFT {_ibtLeft = STOPWATCH}"];
,label="HELD {_ibtHeld = TIMESTOPPER}"];
3 [shape=box
,label="LEFT {_ibtLeft = REWINDWATCH}"];
,label="HELD {_ibtHeld = REWINDER}"];
11 [shape=box
,label="EQUIP {_ibtEquip = FUELPACK}"];
15 [shape=box
@@ -64,9 +64,9 @@ digraph {
81 [shape=box
,label="HELD {_ibtHeld = TESLAGUN}"];
83 [shape=box
,label="LEFT {_ibtLeft = BLINKER}"];
,label="HELD {_ibtHeld = BLINKER}"];
86 [shape=box
,label="LEFT {_ibtLeft = BLINKERUNSAFE}"];
,label="HELD {_ibtHeld = BLINKERUNSAFE}"];
88 [shape=box
,label="EQUIP {_ibtEquip = MAGSHIELD}"];
91 [shape=box
+1 -1
View File
File diff suppressed because one or more lines are too long
+8 -8
View File
@@ -14,9 +14,9 @@ import LensHelp
watchCombinations :: [([(ItAmount, ItemType)], Item)]
watchCombinations =
[ po [LEFT STOPWATCH, LEFT REWINDWATCH] scrollWatch
, po [CRAFT TIMEMODULE, CRAFT MICROCHIP, CRAFT HARDDRIVE] scrollWatch
, po [CRAFT TIMEMODULE, CRAFT MICROCHIP, CRAFT RAM] scrollWatch
[ po [HELD TIMESTOPPER, HELD REWINDER] timeScroller
, po [CRAFT TIMEMODULE, CRAFT MICROCHIP, CRAFT HARDDRIVE] timeScroller
, po [CRAFT TIMEMODULE, CRAFT MICROCHIP, CRAFT RAM] timeScroller
]
where
po xs it = (map o xs, it)
@@ -92,8 +92,8 @@ itemCombinations =
-- , po [HELD LASGUN, HELD LASGUN, HELD LASGUN, cr HARDWARE] lasCircle
, p [o $ cr TRANSFORMER, p 2 $ cr CAN] sparkGun
, p [o (HELD SPARKGUN), p 2 $ cr PIPE] teslaGun
, p [o $ cr TELEPORTMODULE, p 2 $ cr MICROCHIP] blinkGun
, p [o $ LEFT BLINKER, p 2 $ cr MICROCHIP] unsafeBlinkGun
, p [o $ cr TELEPORTMODULE, p 2 $ cr MICROCHIP] blinker
, p [o $ HELD BLINKER, p 2 $ cr MICROCHIP] unsafeBlinker
, po [cr MAGNET, cr TIN] magShield
, p [p 2 $ cr PIPE, o $ cr PLATE, o $ cr MOTOR] powerLegs
, p [p 4 $ cr CAN] plateCraft
@@ -103,9 +103,9 @@ itemCombinations =
, po [cr MICROCHIP, cr PRISM] (makeTypeCraft LIGHTSENSOR)
, po [cr MICROCHIP, cr MICROPHONE] (makeTypeCraft SOUNDSENSOR)
, po [cr MICROCHIP, cr THERMOMETER] (makeTypeCraft HEATSENSOR)
, po [cr MICROCHIP, cr TRANSMITTER, cr LIGHTSENSOR] (clickDetector ITEMDETECTOR)
, po [cr MICROCHIP, cr TRANSMITTER, cr SOUNDSENSOR] (clickDetector WALLDETECTOR)
, po [cr MICROCHIP, cr TRANSMITTER, cr HEATSENSOR] (clickDetector CREATUREDETECTOR)
, po [cr MICROCHIP, cr TRANSMITTER, cr LIGHTSENSOR] (detector ITEMDETECTOR)
, po [cr MICROCHIP, cr TRANSMITTER, cr SOUNDSENSOR] (detector WALLDETECTOR)
, po [cr MICROCHIP, cr TRANSMITTER, cr HEATSENSOR] (detector CREATUREDETECTOR)
, po [AMMOMAG BATTERY, cr LED] torch
, po [hd TORCH, eq HAT] headLamp
-- , po [cr LIGHTER, cr THERMOMETER, cr MICROCHIP] (energyBallCraft IncBall)
+9 -8
View File
@@ -141,9 +141,11 @@ inventoryX c = case c of
[ wristInvisibility
]
'D' ->
[ blinkGun
, unsafeBlinkGun
, clickDetector WALLDETECTOR
[ blinker
, unsafeBlinker
, pulseChecker
, detector WALLDETECTOR
, battery
]
'E' -> fold
[ makeTypeCraftNum 3 PIPE
@@ -301,19 +303,18 @@ stackedInventory =
, megaShellMag
, megaShellMag
, pipe
, scrollWatch
, rewindWatch
, stopWatch
, timeScroller
, rewinder
, timeStopper
, tractorGun
, autoPistol
, tinMag
, pistol
, tinMag
, teslaGun
, blinkGun
, blinker
, miniGunX 3
, beltMag
, boosterGun
, flatShield
-- , lasWide 20
, poisonSprayer
-43
View File
@@ -1,13 +1,10 @@
module Dodge.Creature.Impulse.UseItem (
useRootItem,
useItemLeftClick,
useItemHotkey,
) where
import Control.Lens
import Control.Monad
import Data.Maybe
import Dodge.Cuse
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import Dodge.Data.World
@@ -17,8 +14,6 @@ import Dodge.Hotkey
import Dodge.Inventory
import Dodge.Item.Grammar
import Dodge.Item.Location
import Dodge.Luse
import Dodge.SelectUse
import qualified IntMapHelp as IM
useRootItem :: Int -> World -> World
@@ -97,41 +92,3 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
itRef = cr ^?! crManipulation . manObject . imSelectedItem -- unsafe!! TODO change?
onequip itm' = doItmCrWdWd ((_eeOnEquip . _uequipEffect . _itUse) itm') itm'
onremove itm' = doItmCrWdWd ((_eeOnRemove . _uequipEffect . _itUse) itm') itm'
-- need to make sure that the root item is not erroneously selected in the
-- following
useItemLeftClick :: Creature -> World -> World
useItemLeftClick cr w = fromMaybe w $ do
guard . not $ _crInvLock cr
invid <- cr ^? crManipulation . manObject . imSelectedItem
itm <- cr ^? crInv . ix invid
ituse <- cr ^? crInv . ix invid . itUse
case ituse of
UseHeld{} -> return w
UseConsume eff -> return $ useC eff itm cr w
UseEquip{} -> return $ doequipmentchange invid
UseHotkey{} -> return $ doequipmentchange invid
UseNothing{} -> return w
UseAttach{} -> do
return $ selectUse itm cr w
_ -> Nothing
where
doequipmentchange invid = fromMaybe w $ do
guard (_crHammerPosition cr == HammerUp)
return $ toggleEquipmentAt invid cr w
-- & f
-- where
-- f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
useItemHotkey :: Int -> Int -> World -> World
useItemHotkey crid invid w = fromMaybe w $ do
cr <- w ^? cWorld . lWorld . creatures . ix crid
itm <- cr ^? crInv . ix invid
luse <- itm ^? itUse . leftUse
return $
w
& cWorld . lWorld . creatures . ix crid . crInv . ix invid . itUse . leftHammer .~ HammerDown
& useL luse itm cr
-- TODO determine itmShouldBeUsed with reference to config options
+10 -9
View File
@@ -417,22 +417,23 @@ setRBCreatureTargeting cr w ituse
Just $ hasLOS cpos (_crPos cr) w
itemUpdate :: Item -> Item
itemUpdate = updateAutoRecharge . (itUse %~ useUpdate)
--itemUpdate = updateAutoRecharge . (itUse %~ useUpdate)
itemUpdate = itUse %~ useUpdate
useUpdate :: ItemUse -> ItemUse
useUpdate =
(heldHammer %~ moveHammerUp)
. (leftHammer %~ moveHammerUp)
. (leftDelay . rateTime %~ decreaseToZero)
-- . (leftHammer %~ moveHammerUp)
-- . (leftDelay . rateTime %~ decreaseToZero)
. (heldDelay . warmTime %~ decreaseToZero)
. (heldDelay . rateTime %~ decreaseToZero)
updateAutoRecharge :: Item -> Item
updateAutoRecharge it = case it ^? itUse . leftConsumption of
Just (AutoRecharging l m t p)
| l < m && p <= 0 -> it & itUse . leftConsumption .~ AutoRecharging (l + 1) m t t
| l < m -> it & itUse . leftConsumption . arProgress -~ 1
_ -> it
--updateAutoRecharge :: Item -> Item
--updateAutoRecharge it = case it ^? itUse . leftConsumption of
-- Just (AutoRecharging l m t p)
-- | l < m && p <= 0 -> it & itUse . leftConsumption .~ AutoRecharging (l + 1) m t t
-- | l < m -> it & itUse . leftConsumption . arProgress -~ 1
-- _ -> it
updateMovement :: Creature -> Creature
updateMovement cr
+12 -3
View File
@@ -2,6 +2,10 @@ module Dodge.Creature.YourControl (
yourControl,
) where
import Dodge.Data.ComposedItem
import Dodge.HeldUse
import Dodge.Data.DoubleTree
import Dodge.Item.Grammar
import Control.Monad
import Data.Foldable
import qualified Data.Map.Strict as M
@@ -39,14 +43,19 @@ yourControl _ w
handleHotkeys :: World -> World
handleHotkeys w
| SDL.ButtonRight `M.member` _mouseButtons (_input w) = foldl' tryAssignHotkey w allHotkeys
-- | SDL.ButtonRight `M.member` _mouseButtons (_input w)
| SDL.ScancodeLShift `M.member` _pressedKeys (_input w)
|| SDL.ScancodeRShift `M.member` _pressedKeys (_input w)
= foldl' tryAssignHotkey w allHotkeys
| otherwise = foldl' useHotKey w (M.intersection thehotkeys (w ^. input . pressedKeys))
where
--thehotkeys = M.mapKeys hotkeyToScancode $ w ^?! cWorld . lWorld . creatures . ix 0 . crHotkeys
thehotkeys = M.mapKeys hotkeyToScancode $ w ^. cWorld . lWorld . hotkeys
useHotKey :: World -> Int -> World
useHotKey w invid = useItemHotkey 0 invid w
useHotKey w invid = fromMaybe w $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0
itmloc <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
return $ heldEffectNoHammerCheck (bimap (^. iatType) (^. _1) itmloc) cr w
allHotkeys :: [SDL.Scancode]
allHotkeys = map hotkeyToScancode [minBound .. maxBound]
-3
View File
@@ -54,10 +54,7 @@ data Creature = Creature
, _crManipulation :: Manipulation
, _crInvCapacity :: Int
, _crInvLock :: Bool
-- , _crInvEquipped :: IM.IntMap EquipPosition
, _crEquipment :: M.Map EquipPosition Int
-- , _crInvHotkeys :: IM.IntMap Hotkey
-- , _crHotkeys :: M.Map Hotkey Int
, _crState :: CreatureState
, _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic
, _crMaterial :: Material
+12 -11
View File
@@ -14,7 +14,7 @@ import Dodge.Data.Item.Targeting
data ItemType
= HELD {_ibtHeld :: HeldItemType}
| LEFT {_ibtLeft :: LeftItemType}
-- | LEFT {_ibtLeft :: LeftItemType}
| EQUIP {_ibtEquip :: EquipItemType}
| CONSUMABLE {_ibtConsumable :: ConsumableItemType}
| CRAFT {_ibtCraft :: CraftType}
@@ -116,18 +116,17 @@ data EquipItemType
| WRIST_ECG
deriving (Eq, Ord, Show, Read)
data LeftItemType
= BOOSTER
| STOPWATCH
| REWINDWATCH
| SCROLLWATCH
| BLINKER
| BLINKERUNSAFE
| SPAWNER
deriving (Eq, Ord, Show, Read) --Generic, Flat)
--data LeftItemType
-- = STOPWATCH
-- | SCROLLWATCH
-- | SPAWNER
-- deriving (Eq, Ord, Show, Read) --Generic, Flat)
data HeldItemType
= BANGSTICK {_xNum :: Int}
| REWINDER
| TIMESTOPPER
| TIMESCROLLER
| PISTOL
| MACHINEPISTOL
| AUTOPISTOL
@@ -163,6 +162,8 @@ data HeldItemType
| FLATSHIELD
| KEYCARD Int
| DETECTOR Detector
| BLINKER
| BLINKERUNSAFE
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Detector
@@ -180,7 +181,7 @@ deriveJSON defaultOptions ''AmmoMagType
deriveJSON defaultOptions ''AttachType
deriveJSON defaultOptions ''Detector
deriveJSON defaultOptions ''EquipItemType
deriveJSON defaultOptions ''LeftItemType
--deriveJSON defaultOptions ''LeftItemType
deriveJSON defaultOptions ''HeldItemType
deriveJSON defaultOptions ''ItemType
+3 -3
View File
@@ -18,9 +18,9 @@ data ItEffect = ItEffect
data ItInvEffect
= NoInvEffect
| ChargeIfEquipped
| ChargeIfInInventory
| SetCharge Int
-- | ChargeIfEquipped
-- | ChargeIfInInventory
-- | SetCharge Int
| EffectRootNotroot ItInvEffect ItInvEffect
| CreateShieldWall
| RemoveShieldWall
+6 -25
View File
@@ -20,35 +20,16 @@ data Euse
| EMagShield
| EWristShield
| EHeadLamp
-- | EFuelSource {_euseFuelAmount :: Int, _euseFuelMax :: Int}
-- | EBatterySource {_euseBatteryAmount :: Int, _euseBatteryMax :: Int}
-- | EAmmoSource
-- { _euseAmmoAmount :: Int
-- , _euseAmmoMax :: Int
-- , _euseAmmoLink :: Maybe Int
-- }
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Luse
= LDoNothing
| LRewind
| LTimePause
| LTimeScroll
| LBlink
| LUnsafeBlink
| LBoost
deriving (Eq, Ord, Show, Read) --Generic, Flat)
--data HeldMod
-- = PistolMod
---- | FireRemoteShellMod
-- | ExplodeRemoteShellMod
-- | DoNothingMod
--data Luse
-- = LDoNothing
-- | LRewind
-- | LTimePause
-- | LTimeScroll
-- deriving (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''Euse
deriveJSON defaultOptions ''Cuse
--deriveJSON defaultOptions ''HeldMod
deriveJSON defaultOptions ''Euse
--deriveJSON defaultOptions ''Huse
deriveJSON defaultOptions ''Luse
--deriveJSON defaultOptions ''Luse
+20 -7
View File
@@ -40,14 +40,15 @@ data ItemUse
-- , _heldAmmoTypes :: IM.IntMap AmmoType
, _heldParams :: HeldParams
, _heldTriggerType :: TriggerType
, _useCondition :: UseCondition
}
| UseHotkey
{ _leftUse :: Luse
, _leftDelay :: UseDelay
, _leftHammer :: HammerPosition
, _uequipEffect :: EquipEffect
, _leftConsumption :: LeftConsumption
}
-- | UseHotkey
-- { _leftUse :: Luse
-- , _leftDelay :: UseDelay
-- , _leftHammer :: HammerPosition
-- , _uequipEffect :: EquipEffect
-- , _leftConsumption :: LeftConsumption
-- }
| UseConsume { _cUse :: Cuse }
| UseEquip { _uequipEffect :: EquipEffect }
| UseAttach {_uaParams :: AttachParams}
@@ -56,6 +57,11 @@ data ItemUse
| UseBulletMod { _ubMod :: BulletMod }
deriving (Eq, Show, Read)
data UseCondition
= MustBeHeld
| UseableAnytime
deriving (Eq, Show, Read)
data TriggerType = AutoTrigger | HammerTrigger
deriving (Eq, Show, Read)
@@ -142,6 +148,11 @@ data MuzzleEffect
}
| MuzzleShatter
| MuzzleDetector
| MuzzleBlink
| MuzzleUnsafeBlink
| MuzzleRewind
| MuzzleStopper
| MuzzleScroller
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data AmmoPerShot
@@ -192,6 +203,8 @@ makeLenses ''AttachParams
makeLenses ''AmmoParams
makeLenses ''MuzzleEffect
makeLenses ''AmmoPerShot
makeLenses ''UseCondition
deriveJSON defaultOptions ''UseCondition
deriveJSON defaultOptions ''MuzzleEffect
deriveJSON defaultOptions ''FlareType
deriveJSON defaultOptions ''TriggerType
+3 -3
View File
@@ -2,7 +2,7 @@ module Dodge.Default.Item (
defaultHeldItem,
singleAmmo,
defaultBulletWeapon,
defaultLeftItem,
-- defaultLeftItem,
defaultCraftItem,
defaultConsumable,
module Dodge.Default.Item.Use,
@@ -28,8 +28,8 @@ defaultHeldItem =
, _itParams = NoParams
}
defaultLeftItem :: Item
defaultLeftItem = defaultHeldItem & itUse .~ defaultLeftUse
--defaultLeftItem :: Item
--defaultLeftItem = defaultHeldItem & itUse .~ defaultLeftUse
defaultCraftItem :: Item
defaultCraftItem = defaultHeldItem & itUse .~ UseNothing
+9 -8
View File
@@ -11,14 +11,14 @@ import Dodge.Default.Item.Use.AimParams
import Dodge.Default.Item.Use.Consumption
import Dodge.Default.Item.Use.Equipment
defaultLeftUse :: ItemUse
defaultLeftUse = UseHotkey
{ _leftUse = LDoNothing
, _leftDelay = FixedRate{_rateMax = 8, _rateTime = 0}
, _leftHammer = HammerUp
, _uequipEffect = defaultEquip
, _leftConsumption = defaultLeftLoadable
}
--defaultLeftUse :: ItemUse
--defaultLeftUse = UseHotkey
-- { _leftUse = LDoNothing
-- , _leftDelay = FixedRate{_rateMax = 8, _rateTime = 0}
-- , _leftHammer = HammerUp
-- , _uequipEffect = defaultEquip
-- , _leftConsumption = defaultLeftLoadable
-- }
defaultEquipUse :: ItemUse
defaultEquipUse = UseEquip
@@ -42,4 +42,5 @@ defaultHeldUse = UseHeld
, _weaponRepeat = []
}
, _heldTriggerType = HammerTrigger
, _useCondition = MustBeHeld
}
+7 -6
View File
@@ -7,6 +7,8 @@ module Dodge.HeldUse (
mcUseHeld,
) where
import Dodge.Luse
import Dodge.Creature.Action.Blink
import Dodge.RadarSweep
import Color
import Control.Monad
@@ -245,6 +247,11 @@ useLoadedAmmo itmtree cr (cme, w) (mzid, Just (mz, x, magtree)) = (,) (cme & cme
MuzzleNozzle{} -> useGasParams mid mz itm cr $ walkNozzle mzid mz itm cr w
MuzzleShatter -> shootShatter itm cr w
MuzzleDetector -> itemDetectorEffect itm cr w
MuzzleBlink -> unsafeBlinkAction cr w
MuzzleUnsafeBlink -> blinkActionMousePos cr w
MuzzleRewind -> useRewindGun (itm ^. itID) w
MuzzleStopper -> useStopWatch itm cr w
MuzzleScroller -> useTimeScrollGun itm cr w
where
mid = magtree ^? ldtValue . itLocation . ilInvID
itm = itmtree ^. ldtValue
@@ -433,12 +440,6 @@ mcUseHeld hit = case hit of
LASER -> mcShootLaser
_ -> \_ _ -> id
--useHeld :: Huse -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
--useHeld hu = case hu of
-- HeldDoNothing -> const $ const id
-- HeldDetectorEffect dt -> detectorEffect dt . _ldtValue
-- HeldForceField -> useForceFieldGun . _ldtValue
useGasParams :: Maybe Int -> Muzzle -> Item -> Creature -> World -> World
useGasParams mmagid mz itm cr w =
createGas
+7 -15
View File
@@ -14,14 +14,11 @@ import Control.Monad
assignNewHotkey :: Int -> LWorld -> LWorld
assignNewHotkey invid w = assignHotkey invid (newHotkey w) w
--newHotkey :: Creature -> Hotkey
--newHotkey cr = fromMaybe maxBound $ find (not . (`M.member` usedhks)) [minBound .. maxBound]
-- where
-- usedhks = cr ^?! crHotkeys
newHotkey :: LWorld -> Hotkey
newHotkey lw = fromMaybe maxBound $ find (not . (`M.member` usedhks)) [minBound .. maxBound]
where
usedhks = lw ^. hotkeys
newHotkey lw = fromMaybe maxBound $
find
(not . (`M.member` (lw ^. hotkeys)))
[minBound .. maxBound]
-- this will not remove the hotkey from its old slot, assumes there is a hotkey
-- to swap with instead
@@ -29,16 +26,11 @@ newHotkey lw = fromMaybe maxBound $ find (not . (`M.member` usedhks)) [minBound
assignHotkey :: Int -> Hotkey -> LWorld -> LWorld
assignHotkey invid hk lw = fromMaybe lw $ do
--guard (invid `IM.member` (cr ^. crInvEquipped))
guard $ isJust $ lw ^? creatures . ix 0 . crInv . ix invid . itLocation . ilEquipPosition . _Just
_ <- lw ^? creatures . ix 0 . crInv . ix invid . itUse . leftUse
guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUse . useCondition
== Just UseableAnytime
-- _ <- lw ^? creatures . ix 0 . crInv . ix invid . itUse . leftUse
return $ (setHotkey invid hk . moveOldHotkey invid hk) lw
--moveOldHotkey :: Int -> Hotkey -> Creature -> Creature
--moveOldHotkey invid hk w = fromMaybe w $ do
-- oldhk <- w ^? crInvHotkeys . ix invid
-- oldid <- w ^? crHotkeys . ix hk
-- return $ w & setHotkey oldid oldhk
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
moveOldHotkey invid hk w = fromMaybe w $ do
oldhk <- w ^? imHotkeys . ix invid
+30 -31
View File
@@ -1,8 +1,7 @@
module Dodge.ItEffect
( doInvEffect
) where
module Dodge.ItEffect (
doInvEffect,
) where
import qualified IntMapHelp as IM
import Control.Lens
import Dodge.Data.World
import Dodge.Euse
@@ -10,9 +9,9 @@ import Dodge.Euse
doInvEffect :: ItInvEffect -> Item -> Creature -> World -> World
doInvEffect iie = case iie of
NoInvEffect -> const $ const id
ChargeIfEquipped -> chargeIfEquipped
ChargeIfInInventory -> chargeIfInInventory
SetCharge i -> setItemCharge i
-- ChargeIfEquipped -> chargeIfEquipped
-- ChargeIfInInventory -> chargeIfInInventory
-- SetCharge i -> setItemCharge i
EffectRootNotroot f g -> rootNotrootEff f g
CreateShieldWall -> createShieldWall
RemoveShieldWall -> removeShieldWall
@@ -36,27 +35,27 @@ effectWhileAttached f it
-- , _futureWorlds = []
-- }
setItemCharge :: Int -> Item -> Creature -> World -> World
setItemCharge i itm cr w =
w & ptrWpCharge %~ const i
where
invid = _ilInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
chargeIfInInventory :: Item -> Creature -> World -> World
chargeIfInInventory itm cr w =
w & ptrWpCharge %~ (min maxcharge . (+ 1))
where
invid = _ilInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
chargeIfEquipped :: Item -> Creature -> World -> World
chargeIfEquipped itm cr w
| invid `IM.member` (w ^. cWorld . lWorld . imHotkeys) = w &
ptrWpCharge %~ (min maxcharge . (+ 1))
| otherwise = w & ptrWpCharge .~ 0
where
invid = _ilInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
--setItemCharge :: Int -> Item -> Creature -> World -> World
--setItemCharge i itm cr w =
-- w & ptrWpCharge %~ const i
-- where
-- invid = _ilInvID $ _itLocation itm
-- ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
--
--chargeIfInInventory :: Item -> Creature -> World -> World
--chargeIfInInventory itm cr w =
-- w & ptrWpCharge %~ (min maxcharge . (+ 1))
-- where
-- invid = _ilInvID $ _itLocation itm
-- ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
-- maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
--
--chargeIfEquipped :: Item -> Creature -> World -> World
--chargeIfEquipped itm cr w
-- | invid `IM.member` (w ^. cWorld . lWorld . imHotkeys) = w &
-- ptrWpCharge %~ (min maxcharge . (+ 1))
-- | otherwise = w & ptrWpCharge .~ 0
-- where
-- invid = _ilInvID $ _itLocation itm
-- ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
-- maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
+1 -11
View File
@@ -21,7 +21,7 @@ import Dodge.Item.Weapon
itemFromBase :: ItemType -> Item
itemFromBase = \case
HELD ht -> itemFromHeldType ht
LEFT lt -> itemFromLeftType lt
-- LEFT lt -> itemFromLeftType lt
EQUIP et -> itemFromEquipType et
CONSUMABLE et -> itemFromConsumableType et
CRAFT cr -> makeTypeCraft cr
@@ -72,13 +72,3 @@ itemFromEquipType et = case et of
BULLETBELTPACK -> bulletBeltPack
BULLETBELTBRACER -> bulletBeltBracer
WRIST_ECG -> pulseChecker
itemFromLeftType :: LeftItemType -> Item
itemFromLeftType lt = case lt of
BOOSTER -> boosterGun
STOPWATCH -> stopWatch
REWINDWATCH -> rewindWatch
SCROLLWATCH -> scrollWatch
BLINKER -> blinkGun
BLINKERUNSAFE -> unsafeBlinkGun
SPAWNER -> error "need to datify creatures first"
+1 -9
View File
@@ -48,7 +48,6 @@ itemBaseName itm = case _itType itm of
HELD hit -> case hit ^? xNum of
Just i -> takeWhile (/= ' ') (show hit) ++ show i
Nothing -> show hit
LEFT lit -> show lit
EQUIP eit -> showEquipItem eit
CONSUMABLE cit -> show cit
ATTACH ait -> showAttachItem ait itm
@@ -72,13 +71,6 @@ showEquipItem eit = case eit of
INVISIBILITYEQUIPMENT esite -> "INVISIBILITY " ++ show esite
_ -> show eit
showAutoRechargeProgress :: LeftConsumption -> String
showAutoRechargeProgress lc = case lc of
AutoRecharging{}
| _arLoaded lc < _arMax lc -> show (_arProgress lc) ++ "C" ++ show (_arLoaded lc)
| otherwise -> show (_arLoaded lc)
ChargeableAmmo{} -> show (_wpCharge lc)
itemNumberDisplay :: Creature -> ComposedItem -> [String]
itemNumberDisplay cr ci = case (ci ^. _2, itm ^?! itUse, itm ^. itType) of
(_,_,EQUIP WRIST_ECG) -> [displayPulse $ cr ^?! crType . avatarPulse . pulseProgress]
@@ -87,7 +79,7 @@ itemNumberDisplay cr ci = case (ci ^. _2, itm ^?! itUse, itm ^. itType) of
_ | hasammo -> [maybe "" shortShow
$ itm ^? itConsumables . magLoadStatus . iaLoaded]
(_,UseHeld{},_) -> []
(_,UseHotkey{_leftConsumption=lc},_) -> [showAutoRechargeProgress lc]
-- (_,UseHotkey{_leftConsumption=lc},_) -> [showAutoRechargeProgress lc]
(_,UseEquip{},_) -> mempty
(_,UseNothing,_) -> []
(_,UseConsume {},_) -> []
+5 -6
View File
@@ -35,7 +35,6 @@ itemSPic :: Item -> SPic
itemSPic it = case it ^. itType of
CRAFT _ -> defSPic
HELD ht -> heldItemSPic ht it
LEFT lt -> leftItemSPic lt it
EQUIP et -> equipItemSPic et it
CONSUMABLE{} -> defSPic
ATTACH{} -> defSPic
@@ -95,11 +94,6 @@ equipItemSPic et _ = case et of
backpackShape :: Shape
backpackShape = upperPrismPolyMT 10 $ rectNSWE 5 (-5) (-4) 4
leftItemSPic :: LeftItemType -> Item -> SPic
leftItemSPic lt _ = case lt of
BLINKER -> defSPic
_ -> defSPic
--ammoPosition :: Item -> HeldItemType -> AmmoPosition
--ammoPosition itm hit = case hit of
-- FLATSHIELD -> NoAmmoPosition
@@ -207,6 +201,11 @@ heldItemSPic ht it = case ht of
LAUNCHERX _ -> launcherPic it
POISONSPRAYER -> flamerPic it
DRONELAUNCHER -> defSPic
BLINKER -> defSPic
BLINKERUNSAFE -> defSPic
REWINDER -> defSPic
TIMESTOPPER -> defSPic
TIMESCROLLER -> defSPic
SHATTERGUN -> shatterGunSPic
DETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2)
KEYCARD _ -> noShape (setDepth 0 $ translate (-5) (-5) $ rotate (pi / 2.5) keyPic)
-2
View File
@@ -1,5 +1,4 @@
module Dodge.Item.Equipment (
module Dodge.Item.Equipment.Booster,
magShield,
powerLegs,
wristInvisibility,
@@ -22,7 +21,6 @@ import Dodge.Item.Weapon.Bullet
import Geometry.Data
import Dodge.Data.Item
import Dodge.Default
import Dodge.Item.Equipment.Booster
import LensHelp
magShield :: Item
-14
View File
@@ -1,14 +0,0 @@
module Dodge.Item.Equipment.Booster (
boosterGun,
) where
import Control.Lens
import Dodge.Data.Item
import Dodge.Default.Item
boosterGun :: Item
boosterGun =
defaultLeftItem
& itUse . leftUse .~ LBoost
& itUse . leftDelay .~ NoDelay
& itType .~ LEFT BOOSTER
+3 -3
View File
@@ -86,9 +86,10 @@ getAmmoLinks itm =
itemToFunction :: Item -> ItemStructuralFunction
itemToFunction itm = case itm ^. itType of
HELD DETECTOR{} -> GadgetPlatformSF
HELD LASER -> WeaponTargetingSF
HELD{} -> HeldPlatformSF
HELD{} -> case itm ^? itUse . useCondition of
Just MustBeHeld -> HeldPlatformSF
_ -> GadgetPlatformSF
AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itConsumables . magType
ATTACH REMOTESCREEN -> RemoteScreenSF
ATTACH BULLETSYNTH -> AmmoModifierSF BulletAmmo
@@ -99,7 +100,6 @@ itemToFunction itm = case itm ^. itType of
BULLETMOD BulletModPayload{} -> AmmoPayloadSF BulletAmmo
BULLETMOD BulletModEffect{} -> AmmoEffectSF BulletAmmo
TARGETING{} -> WeaponTargetingSF
LEFT{} -> EquipmentPlatformSF
EQUIP WRIST_ECG -> TriggerSF
EQUIP{} -> EquipmentPlatformSF
_ -> UncomposableIsolateSF
+7 -1
View File
@@ -11,6 +11,7 @@ module Dodge.Item.Held (
module Dodge.Item.Held.BatteryGuns,
) where
import Dodge.Item.Weapon.Utility
import Dodge.Data.Item
import Dodge.Item.Held.Launcher
import Dodge.Item.Held.BatteryGuns
@@ -24,6 +25,11 @@ import Dodge.Item.Held.SprayGuns
itemFromHeldType :: HeldItemType -> Item
itemFromHeldType ht = case ht of
REWINDER -> rewinder
TIMESTOPPER -> timeStopper
TIMESCROLLER -> timeScroller
BLINKERUNSAFE -> unsafeBlinker
BLINKER -> blinker
KEYCARD i -> keyCard i
TORCH -> torch
SHATTERGUN -> shatterGun
@@ -64,5 +70,5 @@ itemFromHeldType ht = case ht of
-- REMOTELAUNCHER -> remoteLauncher
POISONSPRAYER -> poisonSprayer
DRONELAUNCHER -> undefined
DETECTOR d -> clickDetector d
DETECTOR d -> detector d
FLATSHIELD -> flatShield
+3 -2
View File
@@ -32,9 +32,10 @@ torch =
{- |
Sends out pulses that display walls.
-}
clickDetector :: Detector -> Item
clickDetector dt =
detector :: Detector -> Item
detector dt =
defaultHeldItem
& itUse . useCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
+8 -14
View File
@@ -23,7 +23,6 @@ itmSpaceInfo itm = case itInvHeight itm of
itmBaseInfo :: Item -> String
itmBaseInfo itm = case itm ^. itType of
HELD hit -> heldInfo hit
LEFT lit -> leftInfo lit
EQUIP eit -> equipInfo eit
CONSUMABLE cit -> consumableInfo cit
CRAFT fit -> craftInfo fit
@@ -48,6 +47,8 @@ showInt i = case i of
heldInfo :: HeldItemType -> String
heldInfo hit = case hit of
BLINKERUNSAFE -> "A device that allows local teleportation. Potentially hazardous around walls."
BLINKER -> "A device that allows local teleportation."
BANGSTICK 1 -> "A firearm with a short barrel that requires reloading after each shot."
BANGSTICK i -> over _head toUpper (showInt i) ++ " small gun barrels strapped together. Each barrel must be individually loaded, but not all need be loaded for the weapon to fire. All loaded barrels discharge simultaneously, with significant spread."
PISTOL -> "A small firearm fed by a magazine. The entire magazine must be replaced when reloading the weapon."
@@ -90,16 +91,9 @@ heldInfo hit = case hit of
TORCH -> "A stick with a light on the end."
FLATSHIELD -> "A panel of metal that blocks unwanted objects from the front of the user."
KEYCARD i -> "A keycard. It is labelled " ++ show i ++ "."
leftInfo :: LeftItemType -> String
leftInfo lit = case lit of
BOOSTER -> "A device that allows travel at speed."
STOPWATCH -> "A device that temporarily pauses time."
REWINDWATCH -> "A device that rewinds time a short amount."
SCROLLWATCH -> "A device that can be used to scroll through recent events."
BLINKER -> "A device that allows local teleportation."
BLINKERUNSAFE -> "A device that allows local teleportation. Potentially hazardous around walls."
SPAWNER -> "A device that spawns creatures."
TIMESTOPPER -> "A device that temporarily pauses time."
REWINDER -> "A device that rewinds time a short amount."
TIMESCROLLER -> "A device that can be used to scroll through recent events."
equipInfo :: EquipItemType -> String
equipInfo eit = case eit of
@@ -197,9 +191,9 @@ detectorInfo d = case d of
itmUsageInfo :: Item -> String
itmUsageInfo itm = case itm ^. itType of
HELD _ -> heldPositionInfo itm
LEFT _ ->
"This item can be equipped" ++ itmEquipSiteInfo itm
++ ". When equipped, it can be activated."
-- LEFT _ ->
-- "This item can be equipped" ++ itmEquipSiteInfo itm
-- ++ ". When equipped, it can be activated."
EQUIP _ -> "This item can be equipped " ++ itmEquipSiteInfo itm ++ "."
CONSUMABLE _ -> "This item can be consumed."
CRAFT _ -> ""
+41 -41
View File
@@ -23,8 +23,8 @@ module Dodge.Item.Weapon.TriggerType (
-- withPositionWallCheck,
-- withPosDirWallCheck,
--withWarmUp,
hammerCheckL,
shootL,
-- hammerCheckL,
-- shootL,
useTimeCheck,
-- ammoCheckI,
-- modClock,
@@ -79,8 +79,8 @@ lockInvFor i f it cr =
-- pos = addZ 0 $ _crPos cr +.+ (_crRad cr + 15) *.* unitVectorAtAngle dir
-- ps = replicateM 20 randOnUnitSphere & evalState $ _randGen w
itUseCharge :: Int -> Item -> Item
itUseCharge x = itUse . leftConsumption . arLoaded %~ (max 0 . subtract x)
--itUseCharge :: Int -> Item -> Item
--itUseCharge x = itUse . leftConsumption . arLoaded %~ (max 0 . subtract x)
--{- | Fires at an increasing rate.
--Has different effect after first fire.
@@ -145,41 +145,41 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
itRef = item ^?! ldtValue . itLocation . ilInvID
userate = fromMaybe 0 $ item ^? ldtValue . itUse . heldDelay . rateMax
{- | Applies a world effect after a hammer position check.
Arbitrary inventory position.
-}
hammerCheckL ::
-- | Underlying effect
(Item -> Creature -> World -> World) ->
Item ->
Creature ->
World ->
World
hammerCheckL f itm cr w = case itm ^? itUse . leftHammer of
Just HammerUp -> f itm cr w
_ -> w
--{- | Applies a world effect after a hammer position check.
--Arbitrary inventory position.
---}
--hammerCheckL ::
-- -- | Underlying effect
-- (Item -> Creature -> World -> World) ->
-- Item ->
-- Creature ->
-- World ->
-- World
--hammerCheckL f itm cr w = case itm ^? itUse . leftHammer of
-- Just HammerUp -> f itm cr w
-- _ -> w
{- | Applies a world effect after an ammo check.
Arbitrary inventory position -- cannot be replaced with ammoUseCheck.
-}
shootL ::
-- | Underlying effect
(Item -> Creature -> World -> World) ->
Item ->
Creature ->
World ->
World
shootL f item cr w
| fireCondition =
f item cr w & cWorld . lWorld . creatures . ix cid . crInv . ix invid
%~ ( itUseCharge 1
. (itUse . leftDelay . rateTime .~ _rateMax (_leftDelay (_itUse item)))
)
-- | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
| otherwise = w
where
cid = _crID cr
invid = _ilInvID $ _itLocation item
fireCondition =
_rateTime (_leftDelay (_itUse item)) == 0
&& _arLoaded (_leftConsumption (_itUse item)) > 0
--{- | Applies a world effect after an ammo check.
--Arbitrary inventory position -- cannot be replaced with ammoUseCheck.
---}
--shootL ::
-- -- | Underlying effect
-- (Item -> Creature -> World -> World) ->
-- Item ->
-- Creature ->
-- World ->
-- World
--shootL f item cr w
-- | fireCondition =
-- f item cr w & cWorld . lWorld . creatures . ix cid . crInv . ix invid
-- %~ ( itUseCharge 1
-- . (itUse . leftDelay . rateTime .~ _rateMax (_leftDelay (_itUse item)))
-- )
-- -- | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
-- | otherwise = w
-- where
-- cid = _crID cr
-- invid = _ilInvID $ _itLocation item
-- fireCondition =
-- _rateTime (_leftDelay (_itUse item)) == 0
-- && _arLoaded (_leftConsumption (_itUse item)) > 0
+40 -46
View File
@@ -1,57 +1,51 @@
module Dodge.Item.Weapon.Utility
( stopWatch
, rewindWatch
, scrollWatch
, blinkGun
, unsafeBlinkGun
( timeStopper
, rewinder
, timeScroller
, blinker
, unsafeBlinker
) where
import Control.Lens
import Dodge.Data.Item
import Dodge.Default
stopWatch :: Item
stopWatch =
defaultLeftItem
& itUse
.~ ( defaultLeftUse
& leftUse .~ LTimePause
& uequipEffect . eeSite .~ GoesOnWrist
)
& itEffect . ieInv .~ ChargeIfEquipped
& itEffect . ieOnDrop .~ SetCharge 0
& itType .~ LEFT STOPWATCH
& itUse . leftConsumption
.~ ChargeableAmmo
{ _wpMaxCharge = 100
, _wpCharge = 0
}
scrollWatch :: Item
scrollWatch =
stopWatch
& itUse . leftUse .~ LTimeScroll
& itType .~ LEFT SCROLLWATCH
blinker :: Item
blinker =
defaultHeldItem
& itUse . useCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldParams .~ DefaultHeldParams
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleBlink
& itUse . heldAim . aimMuzzles . ix 0 . mzAmmoPerShot .~ UseExactly 10000000
& itType .~ HELD BLINKER
rewindWatch :: Item
rewindWatch =
stopWatch
& itUse . leftUse .~ LRewind --useRewindGun
& itType .~ LEFT REWINDWATCH
unsafeBlinker :: Item
unsafeBlinker =
blinker
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleUnsafeBlink
& itType .~ HELD BLINKERUNSAFE
-- & itUse . uequipEffect . eeViewDist ?~ 400
blinkGun :: Item
blinkGun =
defaultLeftItem
{ _itUse =
defaultLeftUse
& leftUse .~ LBlink
& uequipEffect . eeSite .~ GoesOnWrist
}
& itType .~ LEFT BLINKER
rewinder :: Item
rewinder =
blinker
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleRewind
& itType .~ HELD REWINDER
& itUse . heldAim . aimMuzzles . ix 0 . mzAmmoPerShot .~ UseExactly 100000
unsafeBlinkGun :: Item
unsafeBlinkGun =
blinkGun
& itType .~ LEFT BLINKERUNSAFE
& itUse . leftUse .~ LUnsafeBlink
& itUse . uequipEffect . eeViewDist ?~ 400
timeStopper :: Item
timeStopper =
blinker
& itType .~ HELD TIMESTOPPER
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleStopper
timeScroller :: Item
timeScroller =
timeStopper
& itType .~ HELD TIMESCROLLER
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleScroller
+1 -1
View File
@@ -17,7 +17,7 @@ lockRoomMultiItems =
[
( blinkAcrossChallenge
, takeOne
[ [LEFT BLINKERUNSAFE, HELD $ DETECTOR WALLDETECTOR]
[ [HELD BLINKERUNSAFE, HELD $ DETECTOR WALLDETECTOR]
]
)
]
+20 -86
View File
@@ -1,28 +1,28 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Luse (
useL,
-- useL,
useRewindGun,
useStopWatch,
useTimeScrollGun
) where
import Dodge.Creature.Action
import NewInt
import Dodge.Data.World
import Dodge.Item.Weapon.TriggerType
--import Dodge.Item.Weapon.TriggerType
import LensHelp
useL :: Luse -> Item -> Creature -> World -> World
useL = \case
LDoNothing -> const $ const id
LRewind -> useRewindGun
LTimePause -> hammerCheckL useStopWatch
LTimeScroll -> hammerCheckL useTimeScrollGun
LBlink -> hammerCheckL (shootL $ const blinkActionMousePos)
LUnsafeBlink -> hammerCheckL (shootL $ const unsafeBlinkAction)
LBoost -> boostSelfL 10
--useL :: Luse -> Item -> Creature -> World -> World
--useL = \case
-- LDoNothing -> const $ const id
-- LRewind -> useRewindGun
-- LTimePause -> hammerCheckL useStopWatch
-- LTimeScroll -> hammerCheckL useTimeScrollGun
useStopWatch :: Item -> Creature -> World -> World
useStopWatch itm _ =
timeFlow
.~ PausedTimeFlow
{ _timeFlowCharge = itm ^?! itUse . leftConsumption . wpCharge
{ _timeFlowCharge = 100
, _scrollItemID = _itID itm
}
@@ -31,17 +31,19 @@ useTimeScrollGun itm _ =
timeFlow
.~ ItemScrollTimeFlow
{ _scrollSmoothing = 0
, _reverseAmount = itm ^?! itUse . leftConsumption . wpCharge
--, _reverseAmount = itm ^?! itUse . leftConsumption . wpCharge
, _reverseAmount = 100
, _futureWorlds = []
, _scrollItemID = _itID itm
}
useRewindGun :: Item -> Creature -> World -> World
useRewindGun itm _ =
useRewindGun :: NewInt ItmInt -> World -> World
useRewindGun i =
timeFlow
.~ RewindLeftClick
{ _reverseAmount = itm ^?! itUse . leftConsumption . wpCharge
, _scrollItemID = _itID itm
-- { _reverseAmount = itm ^?! itUse . leftConsumption . wpCharge
{ _reverseAmount = 100
, _scrollItemID = i
}
--useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of
@@ -52,71 +54,3 @@ useRewindGun itm _ =
-- & cwTime . rewindWorlds .~ ws
-- _ -> w
boostSelfL ::
-- | boost amount
Float ->
Item ->
Creature ->
World ->
World
boostSelfL = undefined
--boostSelfL x itm cr w = case boostPoint x cr w of
-- Left p -> crEff p (itUse . leftConsumption . arLoaded .~ 0)
-- Right p -> crEff p (itUse . leftConsumption . arLoaded -~ 1)
-- where
-- invid = _ipInvID $ _itLocation itm
-- cid = _crID cr
-- cpos = _crPos cr
-- r = _crRad cr
-- pid =
-- fromMaybe
-- (IM.newKey $ _props (_cWorld w))
-- (cr ^? crInv . ix invid . itAttachment . atInt)
-- crEff p ammoEff =
-- addBoostShockwave pid p (r *.* normalizeV (p -.- cpos)) w
-- & cWorld . creatures . ix cid
-- %~ (crPos .~ p)
-- . ( crInv . ix invid
-- %~ ammoEff
-- . (itEffect . ieCounter .~ 1)
-- . (itAttachment .~ AttachInt pid)
-- )
---- | Move a creature towards the mouse position, with shockwave
--boostPoint ::
-- -- | boost amount
-- Float ->
-- Creature ->
-- World ->
-- Either Point2 Point2
--boostPoint x cr w = case mayp2 of
-- Nothing -> Right p1
-- Just p2 -> Left $ mvPointTowardAtSpeed r cpos $ fst p2
-- where
-- cpos = _crPos cr
-- r = 1.5 * _crRad cr
-- p1 = cpos +.+ x *.* squashNormalizeV (mouseWorldPos (w ^. input) (w ^. wCam) -.- cpos)
-- mayp2 = bouncePoint (const True) 1 cpos p1 w
--addBoostShockwave ::
-- Int ->
-- Point2 ->
-- Point2 ->
-- World ->
-- World
--addBoostShockwave pjid p v w =
-- w & cWorld . lWorld . linearShockwaves
-- %~ IM.insertWith f pjid thePJ
-- where
-- thePJ =
-- LinearShockwave
-- { _lwPos = p
-- , _lwID = pjid
-- , _lwPoints = [(p, v)]
-- , _lwTimer = maxT
-- }
-- f newVal oldVal = newVal & lwPoints %~ (++ _lwPoints oldVal)
--maxT :: Int
--maxT = 20
+3 -2
View File
@@ -1,6 +1,7 @@
{-# OPTIONS_GHC -Wno-unused-imports #-}
module Dodge.TestString where
import qualified SDL as SDL
import Linear
import Dodge.ListDisplayParams
import Dodge.SelectionSections
@@ -22,11 +23,11 @@ import qualified Data.Aeson.Encode.Pretty as AEP
import Control.Lens
import Dodge.Data.Universe
import qualified IntMapHelp as IM
import qualified Data.Map.Strict as M
testStringInit :: Universe -> [String]
testStringInit u =
[show $ u ^? uvWorld . hud . hudElement . diSections . ix (-1) . ssItems . ix 0 . siWidth
]
(map show $ M.toList $ u ^. uvWorld . input . pressedKeys)
-- fromMaybe mempty $ do
-- cr <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0
-- let itms = IM.elems $ cr ^. crInv
+19 -14
View File
@@ -25,7 +25,7 @@ import Dodge.DrWdWd
import Dodge.EnergyBall
import Dodge.Flame
import Dodge.Inventory
import Dodge.Item.Location
--import Dodge.Item.Location
import Dodge.Laser.Update
import Dodge.LinearShockwave.Update
import Dodge.ListDisplayParams
@@ -188,13 +188,15 @@ timeFlowUpdate u = case u ^. uvWorld . timeFlow of
PausedTimeFlow _ itmloc -> over uvWorld (pauseTime itmloc) u
pauseTime :: NewInt ItmInt -> World -> World
pauseTime itmloc w
| justPressedButtonLeft || outofcharge = w & timeFlow .~ NormalTimeFlow
| otherwise = w & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix (_unNInt itmloc)) . itUse . leftConsumption . wpCharge -~ 1
--pauseTime itmloc w
pauseTime _ w
-- | justPressedButtonLeft || outofcharge = w & timeFlow .~ NormalTimeFlow
| justPressedButtonLeft = w & timeFlow .~ NormalTimeFlow
| otherwise = w -- & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix (_unNInt itmloc)) . itUse . leftConsumption . wpCharge -~ 1
where
justPressedButtonLeft = w ^? input . mouseButtons . ix ButtonLeft == Just 0
outofcharge = maybe True (== 0) charge
charge = w ^? pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix (_unNInt itmloc)) . itUse . leftConsumption . wpCharge
-- outofcharge = maybe True (== 0) charge
-- charge = w ^? pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix (_unNInt itmloc)) . itUse . leftConsumption . wpCharge
doItemTimeScroll :: Int -> World -> World
doItemTimeScroll smoothing w = case w ^? input . mouseButtons . ix ButtonLeft of
@@ -224,12 +226,14 @@ scrollTimeBack w = case w ^? pastWorlds . _head of
& mupdateitem x
_ -> w
where
mupdateitem x = fromMaybe id $ do
i <- w ^? timeFlow . scrollItemID . unNInt
let pointituse = pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse
return $
(pointituse . leftConsumption . wpCharge .~ (x -1))
. (pointituse . leftHammer .~ HammerDown)
--mupdateitem x = fromMaybe id $ do
mupdateitem _ = fromMaybe id $ do
--i <- w ^? timeFlow . scrollItemID . unNInt
_ <- w ^? timeFlow . scrollItemID . unNInt
-- let pointituse = pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse
return $ id
-- (pointituse . leftConsumption . wpCharge .~ (x -1))
-- . (pointituse . leftHammer .~ HammerDown)
scrollTimeForward :: World -> World
scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of
@@ -243,8 +247,9 @@ scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of
where
ramount = (w ^?! timeFlow . reverseAmount) + 1
mupdateitem = fromMaybe id $ do
i <- w ^? timeFlow . scrollItemID . unNInt
return $ pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount
--i <- w ^? timeFlow . scrollItemID . unNInt
_ <- w ^? timeFlow . scrollItemID . unNInt
return $ id -- pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount
-- | The update step.
functionalUpdate :: Universe -> Universe
+413 -441
View File
File diff suppressed because it is too large Load Diff