From 2037891cc9338f1ded3b23dfd0a2d2ac1e197d7d Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 29 Dec 2024 10:40:21 +0000 Subject: [PATCH] Commit before perhaps rethinking item structure --- src/Dodge/Data/ComposedItem.hs | 2 +- src/Dodge/Data/Item/BulletMod.hs | 3 +-- src/Dodge/Data/Item/Combine.hs | 1 + src/Dodge/Item.hs | 1 + src/Dodge/Item/Display.hs | 1 + src/Dodge/Item/Draw/SPic.hs | 1 + src/Dodge/Item/Grammar.hs | 10 ++++++++-- src/Dodge/Item/InventoryColor.hs | 2 +- src/Dodge/Item/Scope.hs | 8 ++++++++ src/Dodge/Projectile/Update.hs | 3 +++ tags | 14 +++++++------- 11 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/Dodge/Data/ComposedItem.hs b/src/Dodge/Data/ComposedItem.hs index 9a6da1311..7dc84e04d 100644 --- a/src/Dodge/Data/ComposedItem.hs +++ b/src/Dodge/Data/ComposedItem.hs @@ -43,7 +43,7 @@ data ItemStructuralFunction | JoystickSF | RemoteDetonatorSF | SmokeReducerSF - | UncomposableIsolateSF + | NoSF | AmmoModifierSF AmmoType | AmmoTargetingSF AmmoType | AmmoPayloadSF AmmoType diff --git a/src/Dodge/Data/Item/BulletMod.hs b/src/Dodge/Data/Item/BulletMod.hs index 884af03c8..788c92762 100644 --- a/src/Dodge/Data/Item/BulletMod.hs +++ b/src/Dodge/Data/Item/BulletMod.hs @@ -8,8 +8,7 @@ import Data.Aeson.TH import Dodge.Data.Bullet data BulletMod - = -- BulletModTrajectory { _bmTrajectory :: BulletTrajectoryType} - BulletModPayload {_bmPayload :: BulletPayload} + = BulletModPayload {_bmPayload :: BulletPayload} | BulletModEffect {_bmEffect :: BulletEffect} deriving (Eq, Ord, Show, Read) diff --git a/src/Dodge/Data/Item/Combine.hs b/src/Dodge/Data/Item/Combine.hs index d1b88870e..d030cfa6a 100644 --- a/src/Dodge/Data/Item/Combine.hs +++ b/src/Dodge/Data/Item/Combine.hs @@ -22,6 +22,7 @@ data ItemType | AMMOMAG {_ibtAmmoMag :: AmmoMagType} | TARGETING {_ibtTargeting :: TargetingType} | BULLETMOD {_ibtBulletMod :: BulletMod} + | STICKYMOD deriving (Eq, Ord, Show, Read) data CraftType diff --git a/src/Dodge/Item.hs b/src/Dodge/Item.hs index d0fe8a4cf..8fe67daf3 100644 --- a/src/Dodge/Item.hs +++ b/src/Dodge/Item.hs @@ -24,6 +24,7 @@ itemFromBase = \case AMMOMAG t -> itemFromAmmoMag t TARGETING tt -> targetingScope tt BULLETMOD bm -> bulletModule bm + STICKYMOD -> stickyMod itemFromAmmoMag :: AmmoMagType -> Item itemFromAmmoMag at = case at of diff --git a/src/Dodge/Item/Display.hs b/src/Dodge/Item/Display.hs index a8e480b6a..90125499b 100644 --- a/src/Dodge/Item/Display.hs +++ b/src/Dodge/Item/Display.hs @@ -65,6 +65,7 @@ itemBaseName = \case TARGETING tt -> show tt BULLETMOD (BulletModPayload btt) -> show btt BULLETMOD (BulletModEffect btt) -> show btt + STICKYMOD -> "STICKYMOD" showAttachItem :: AttachType -> String showAttachItem t = case t of diff --git a/src/Dodge/Item/Draw/SPic.hs b/src/Dodge/Item/Draw/SPic.hs index 90392dea8..1c2c6c06d 100644 --- a/src/Dodge/Item/Draw/SPic.hs +++ b/src/Dodge/Item/Draw/SPic.hs @@ -40,6 +40,7 @@ itemSPic it = case it ^. itType of AMMOMAG amt -> ammoMagSPic it amt TARGETING{} -> defSPic BULLETMOD{} -> defSPic + STICKYMOD -> defSPic craftItemSPic :: CraftType -> Shape craftItemSPic = \case diff --git a/src/Dodge/Item/Grammar.hs b/src/Dodge/Item/Grammar.hs index 62a7e166b..42417fff9 100644 --- a/src/Dodge/Item/Grammar.hs +++ b/src/Dodge/Item/Grammar.hs @@ -17,6 +17,7 @@ import Dodge.DoubleTree import Dodge.Item.Orientation import LensHelp import ListHelp +import qualified Data.Set as S tryAttachItems :: LabelDoubleTree ItemLink ComposedItem -> @@ -108,7 +109,7 @@ itemToFunction itm = case itm ^. itType of | Just amtype <- itm ^? itConsumables . magType , Just _ <- itm ^? itLocation . ilEquipSite . _Just -> AmmoMagSF amtype - AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itConsumables . magType + AMMOMAG{} -> maybe NoSF AmmoMagSF $ itm ^? itConsumables . magType ATTACH REMOTESCREEN -> RemoteScreenSF ATTACH JOYSTICK -> JoystickSF ATTACH REMOTEDETONATOR -> RemoteDetonatorSF @@ -124,7 +125,12 @@ itemToFunction itm = case itm ^. itType of EQUIP WRIST_ECG -> TriggerSF EQUIP{} -> EquipmentPlatformSF ATTACH SHELLPAYLOAD{} -> AmmoPayloadSF LauncherAmmo - _ -> UncomposableIsolateSF + _ -> NoSF + +structureToPotentialFunction + :: LabelDoubleTree ComposedItem ItemLink + -> S.Set ItemStructuralFunction +structureToPotentialFunction _ = mempty baseCI :: Item -> ComposedItem baseCI itm = (itm, itemToFunction itm, itemBaseConnections itm) diff --git a/src/Dodge/Item/InventoryColor.hs b/src/Dodge/Item/InventoryColor.hs index 4863818fd..7a1ab59dc 100644 --- a/src/Dodge/Item/InventoryColor.hs +++ b/src/Dodge/Item/InventoryColor.hs @@ -21,7 +21,7 @@ itemInvColor ci = case ci ^. _2 of JoystickSF -> azure RemoteDetonatorSF -> azure SmokeReducerSF -> azure - UncomposableIsolateSF -> greyN 0.5 + NoSF -> greyN 0.5 AmmoModifierSF{} -> orange AmmoTargetingSF{} -> green AmmoPayloadSF{} -> violet diff --git a/src/Dodge/Item/Scope.hs b/src/Dodge/Item/Scope.hs index da2df8761..7141c5821 100644 --- a/src/Dodge/Item/Scope.hs +++ b/src/Dodge/Item/Scope.hs @@ -1,4 +1,5 @@ module Dodge.Item.Scope ( + stickyMod, shellModule, zoomScope, targetingScope, @@ -36,6 +37,13 @@ targetingScope tt = defaultHeldItem homingModule :: Item homingModule = makeAttach HOMINGMODULE +stickyMod :: Item +stickyMod = + defaultHeldItem + & itType .~ STICKYMOD + & itUse .~ UseNothing + + bulletModule :: BulletMod -> Item bulletModule bm = defaultHeldItem diff --git a/src/Dodge/Projectile/Update.hs b/src/Dodge/Projectile/Update.hs index afeb4ab8d..8e52fabe9 100644 --- a/src/Dodge/Projectile/Update.hs +++ b/src/Dodge/Projectile/Update.hs @@ -94,8 +94,11 @@ shellCollisionCheck pj w time = _pjTimer pj oldPos = _pjPos pj +-- note this doesn't take into account moving walls, which may break the +-- bouncing in some way tryShellBounce :: (Point2, Either Creature Wall) -> Projectile -> World -> World tryShellBounce (p, Right wl) pj w + | Just GStick <- pj ^? pjType . gnHitEffect = w | Just x <- pj ^? pjType . gnHitEffect . bounceTolerance = if abs (dotV (pj ^. pjVel) (vNormal hitline)) < x then w & cWorld . lWorld . projectiles . ix (_pjID pj) . pjVel %~ reflectIn diff --git a/tags b/tags index 18158dd33..a339da507 100644 --- a/tags +++ b/tags @@ -3824,7 +3824,7 @@ debugMenuOptions src/Dodge/Menu.hs 119;" f debugOn src/Dodge/Data/Config.hs 151;" f debugSelectCreatureList src/Dodge/Debug.hs 86;" f debugSelectCreatureMessage src/Dodge/Debug.hs 77;" f -decTimMvVel src/Dodge/Projectile/Update.hs 181;" f +decTimMvVel src/Dodge/Projectile/Update.hs 184;" f decodedtmap src/Dodge/Terminal.hs 205;" f decomposeSelfTree src/Dodge/Tree/Compose.hs 60;" f decomposeTree src/Dodge/Tree/Compose.hs 57;" f @@ -3927,7 +3927,7 @@ destroyMatS src/Dodge/Material/Sound.hs 7;" f destroyMcType src/Dodge/Machine/Destroy.hs 21;" f destroyMount src/Dodge/Block.hs 104;" f destroyMounts src/Dodge/Block.hs 101;" f -destroyProjectile src/Dodge/Projectile/Update.hs 109;" f +destroyProjectile src/Dodge/Projectile/Update.hs 112;" f detV src/Geometry/Vector.hs 93;" f detector src/Dodge/Item/Held/Utility.hs 41;" f detectorColor src/Dodge/Item/Draw/SPic.hs 434;" f @@ -4041,7 +4041,7 @@ doTerminalCommandEffect src/Dodge/Terminal.hs 135;" f doTestDrawing src/Dodge/Render.hs 42;" f doTextInputOver src/Dodge/Update/Input/Text.hs 15;" f doTextInputOverUniverse src/Dodge/Update/Input/Text.hs 12;" f -doThrust src/Dodge/Projectile/Update.hs 121;" f +doThrust src/Dodge/Projectile/Update.hs 124;" f doTimeScroll src/Dodge/Update.hs 205;" f doTmTm src/Dodge/TmTm.hs 6;" f doTmWdWd src/Dodge/WorldEffect.hs 101;" f @@ -4248,7 +4248,7 @@ expandPolyCorners src/Dodge/LevelGen/StaticWalls.hs 103;" f expandToSquare src/Dodge/LevelGen/StaticWalls/Deprecated.hs 83;" f expireAndDamage src/Dodge/Bullet.hs 195;" f expireAndDamageFL src/Dodge/Flame.hs 47;" f -explodeShell src/Dodge/Projectile/Update.hs 189;" f +explodeShell src/Dodge/Projectile/Update.hs 192;" f explosionS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 410;" f explosiveBarrel src/Dodge/Creature/Inanimate.hs 29;" f extTrigLitPos src/Dodge/Placement/Instance/Button.hs 84;" f @@ -5129,7 +5129,7 @@ pipe src/Dodge/Item/Craftable.hs 32;" f pistol src/Dodge/Item/Held/Stick.hs 42;" f pistolCrit src/Dodge/Creature/PistolCrit.hs 12;" f pistolerRoom src/Dodge/Room/Room.hs 321;" f -pjRemoteSetDirection src/Dodge/Projectile/Update.hs 166;" f +pjRemoteSetDirection src/Dodge/Projectile/Update.hs 169;" f plBlock src/Dodge/Placement/PlaceSpot/Block.hs 18;" f plDoor src/Dodge/Placement/PlaceSpot/TriggerDoor.hs 22;" f plLineBlock src/Dodge/Placement/PlaceSpot/Block.hs 50;" f @@ -6036,8 +6036,8 @@ tryPutFloorItemIDInInv src/Dodge/Inventory/Add.hs 26;" f tryPutItemInInv src/Dodge/Inventory/Add.hs 42;" f tryPutItemInInvAt src/Dodge/Inventory/Add.hs 32;" f trySeedFromClipboard src/Dodge/Menu.hs 88;" f -tryShellBounce src/Dodge/Projectile/Update.hs 97;" f -trySpinByCID src/Dodge/Projectile/Update.hs 148;" f +tryShellBounce src/Dodge/Projectile/Update.hs 99;" f +trySpinByCID src/Dodge/Projectile/Update.hs 151;" f trySynthBullet src/Dodge/Creature/State.hs 204;" f tryUseParent src/Dodge/Creature/State.hs 197;" f turnTo src/Dodge/Movement/Turn.hs 4;" f