Add compass item

This commit is contained in:
2026-04-14 21:07:46 +01:00
parent ce8ddc6414
commit 02e26c368c
9 changed files with 31 additions and 4 deletions
+2 -1
View File
@@ -3,6 +3,7 @@
module Dodge.Data.ComposedItem where module Dodge.Data.ComposedItem where
import Color.Data
import Control.Lens import Control.Lens
import Dodge.Data.AmmoType import Dodge.Data.AmmoType
import Dodge.Data.Item import Dodge.Data.Item
@@ -26,7 +27,7 @@ data ItemSF -- Structural Function
| JoystickSF | JoystickSF
| RemoteDetonatorSF | RemoteDetonatorSF
| SmokeReducerSF | SmokeReducerSF
| NoSF | NoSF Color
| AmmoModifierSF AmmoType | AmmoModifierSF AmmoType
| AmmoTargetingSF AmmoType | AmmoTargetingSF AmmoType
| AmmoPayloadSF AmmoType | AmmoPayloadSF AmmoType
+1
View File
@@ -33,6 +33,7 @@ data ItemType
| DETECTOR {_ibtDetector :: Detector} | DETECTOR {_ibtDetector :: Detector}
| ARHUD | ARHUD
| LASER | LASER
| COMPASS
deriving (Eq, Ord, Show, Read) deriving (Eq, Ord, Show, Read)
data InventoryPathing data InventoryPathing
+16
View File
@@ -8,6 +8,7 @@ module Dodge.Inventory.SelectionList (
getItemValue, getItemValue,
) where ) where
import Geometry.Vector
import Dodge.Creature.MaxHP import Dodge.Creature.MaxHP
import Dodge.Data.Equipment.Misc import Dodge.Data.Equipment.Misc
import Numeric import Numeric
@@ -83,6 +84,7 @@ itemExternalValue :: Item -> World -> Creature -> Maybe (Either Int String)
itemExternalValue itm w cr itemExternalValue itm w cr
| EQUIP WRIST_ECG <- itm ^. itType = Just . Right . | EQUIP WRIST_ECG <- itm ^. itType = Just . Right .
displayPulse $ cr ^?! crType . avatarPulse . pulseProgress displayPulse $ cr ^?! crType . avatarPulse . pulseProgress
| COMPASS <- itm ^. itType = Just . Right . radToCompass . normalizeAngle $ w ^. wCam . camRot
| Just t <- itm ^? itType . ibtIntroScanType = Just $ introScanValue cr t | Just t <- itm ^? itType . ibtIntroScanType = Just $ introScanValue cr t
| ITEMSCAN <- itm ^. itType | ITEMSCAN <- itm ^. itType
, Just ExamineInventory <- w ^? hud . subInventory , Just ExamineInventory <- w ^? hud . subInventory
@@ -106,6 +108,20 @@ itemExternalValue itm w cr
Just . Left $ ugateCalc x y Just . Left $ ugateCalc x y
| otherwise = mempty | otherwise = mempty
radToCompass :: Float -> String
radToCompass x
| x > f 7 = "N"
| x > f 6 = "NE"
| x > f 5 = "E"
| x > f 4 = "SE"
| x > f 3 = "S"
| x > f 2 = "SW"
| x > f 1 = "W"
| x > f 0 = "NW"
| otherwise = "N"
where
f i = i * pi / 4 + pi/8
ugateCalc :: Int -> Int -> Int ugateCalc :: Int -> Int -> Int
ugateCalc x y = (x `div` ((2::Int) ^ (f y ::Int))::Int) `mod` 2 ugateCalc x y = (x `div` ((2::Int) ^ (f y ::Int))::Int) `mod` 2
where where
+1
View File
@@ -38,6 +38,7 @@ itemFromBase = \case
UNIGATE -> unigate UNIGATE -> unigate
BINGATE -> bingate BINGATE -> bingate
LASER -> laser LASER -> laser
COMPASS -> compass
itemFromAmmoMag :: AmmoMagType -> Item itemFromAmmoMag :: AmmoMagType -> Item
itemFromAmmoMag at = case at of itemFromAmmoMag at = case at of
+1
View File
@@ -82,6 +82,7 @@ itemBaseName = \case
UNIGATE -> "UNIGATE" UNIGATE -> "UNIGATE"
NULGATE -> "NULGATE" NULGATE -> "NULGATE"
LASER -> "LASER" LASER -> "LASER"
COMPASS -> "COMPASS"
showInventoryPathing :: InventoryPathing -> String showInventoryPathing :: InventoryPathing -> String
showInventoryPathing = \case showInventoryPathing = \case
+1
View File
@@ -36,6 +36,7 @@ itemSPic it = case it ^. itType of
UNIGATE -> defSPic UNIGATE -> defSPic
NULGATE -> defSPic NULGATE -> defSPic
LASER -> lasGunPic it LASER -> lasGunPic it
COMPASS -> defSPic
craftItemSPic :: CraftType -> Shape craftItemSPic :: CraftType -> Shape
craftItemSPic = \case craftItemSPic = \case
+4 -2
View File
@@ -9,6 +9,7 @@ module Dodge.Item.Grammar (
invIndents, invIndents,
) where ) where
import Color
import NewInt import NewInt
import Dodge.Item.Orientation import Dodge.Item.Orientation
import Dodge.ItemUseCondition import Dodge.ItemUseCondition
@@ -122,7 +123,7 @@ itemToFunction itm = case itm ^. itType of
_ | Just amtype <- magAmmoType itm-- ^? itConsumables . magType _ | Just amtype <- magAmmoType itm-- ^? itConsumables . magType
, Just _ <- itm ^? itLocation . ilEquipSite . _Just -> , Just _ <- itm ^? itLocation . ilEquipSite . _Just ->
AmmoMagSF 0 amtype AmmoMagSF 0 amtype
AMMOMAG{} -> maybe NoSF (AmmoMagSF 0) $ magAmmoType itm -- ^? itConsumables . magType AMMOMAG{} -> maybe (NoSF (greyN 0.5)) (AmmoMagSF 0) $ magAmmoType itm -- ^? itConsumables . magType
ATTACH REMOTESCREEN -> RemoteScreenSF ATTACH REMOTESCREEN -> RemoteScreenSF
ATTACH JOYSTICK -> JoystickSF ATTACH JOYSTICK -> JoystickSF
ATTACH REMOTEDETONATOR -> RemoteDetonatorSF ATTACH REMOTEDETONATOR -> RemoteDetonatorSF
@@ -143,7 +144,8 @@ itemToFunction itm = case itm ^. itType of
ATTACH CAPACITOR -> CapacitorSF ATTACH CAPACITOR -> CapacitorSF
CRAFT TRANSFORMER -> TransformerSF CRAFT TRANSFORMER -> TransformerSF
CRAFT PUMP -> PumpSF CRAFT PUMP -> PumpSF
_ -> NoSF COMPASS -> NoSF white
_ -> NoSF $ greyN 0.5
treeToPotentialFunction :: DTree CItem -> S.Set ItemSF treeToPotentialFunction :: DTree CItem -> S.Set ItemSF
treeToPotentialFunction ldt = case ldt ^. dtValue . _1 . itType of treeToPotentialFunction ldt = case ldt ^. dtValue . _1 . itType of
+4
View File
@@ -2,6 +2,7 @@ module Dodge.Item.Held.BatteryGuns (
teslaCoil, teslaCoil,
laser, laser,
tractorGun, tractorGun,
compass,
) where ) where
import Control.Lens import Control.Lens
@@ -35,6 +36,9 @@ laser =
} }
& itType .~ LASER & itType .~ LASER
compass :: Item
compass = defHeldItem & itType .~ COMPASS
-- previous attractionPower values: 1, -1, -10, 0 -- previous attractionPower values: 1, -1, -10, 0
tractorGun :: Item tractorGun :: Item
tractorGun = defHeldItem & itType .~ HELD TRACTORGUN tractorGun = defHeldItem & itType .~ HELD TRACTORGUN
+1 -1
View File
@@ -29,7 +29,7 @@ sfInvColor = \case
JoystickSF -> azure JoystickSF -> azure
RemoteDetonatorSF -> azure RemoteDetonatorSF -> azure
SmokeReducerSF -> azure SmokeReducerSF -> azure
NoSF -> greyN 0.5 NoSF c -> c
AmmoModifierSF{} -> orange AmmoModifierSF{} -> orange
AmmoTargetingSF{} -> green AmmoTargetingSF{} -> green
AmmoPayloadSF{} -> violet AmmoPayloadSF{} -> violet