diff --git a/ghcidOutput b/ghcidOutput index 450e4e761..7ffd7adaa 100644 --- a/ghcidOutput +++ b/ghcidOutput @@ -1 +1 @@ -All good (617 modules, at 18:44:37) +All good (617 modules, at 19:05:46) diff --git a/src/Dodge/Data/Item/Combine.hs b/src/Dodge/Data/Item/Combine.hs index 0c2c64992..3205ef75d 100644 --- a/src/Dodge/Data/Item/Combine.hs +++ b/src/Dodge/Data/Item/Combine.hs @@ -95,7 +95,7 @@ data ItemBaseType --deriving (Eq, Ord, Show, Read) --Generic, Flat) data AttachType - = SCROLLATTACH ScrollAttachType + = ZOOMSCOPE | TARGETATTACH {_ibtAttachTarget :: TargetType} | BULLETSYNTHESIZER | ROCKETHOMER @@ -104,10 +104,6 @@ data AttachType -- | BULTRAJECTORYATTACH deriving (Eq, Ord, Show, Read) -data ScrollAttachType - = ZOOMSCOPE - deriving (Eq, Ord, Show, Read) - data AmmoMagType = REVOLVEMAG | TINMAG @@ -250,7 +246,6 @@ deriveJSON defaultOptions ''Stack deriveJSON defaultOptions ''CraftType deriveJSON defaultOptions ''ConsumableItemType deriveJSON defaultOptions ''AmmoMagType -deriveJSON defaultOptions ''ScrollAttachType deriveJSON defaultOptions ''AttachType deriveJSON defaultOptions ''Detector deriveJSON defaultOptions ''EquipItemType diff --git a/src/Dodge/HeldUse.hs b/src/Dodge/HeldUse.hs index 00180c2d5..09c1a14f2 100644 --- a/src/Dodge/HeldUse.hs +++ b/src/Dodge/HeldUse.hs @@ -115,22 +115,13 @@ applySidePush maxSide cr w = w (pushAmount, g) = randomR (- maxSide, maxSide) $ _randGen w applyTorqueCME :: Item -> Creature -> World -> World -applyTorqueCME itm cr w - | cid == 0 = w - & wCam . camRot +~ rot --- & rotateScope - & randGen .~ g - | otherwise = w +applyTorqueCME itm cr w = w & cWorld . lWorld . creatures . ix cid . crDir +~ rot & randGen .~ g where cid = _crID cr (rot, g) = randomR (- torque, torque) $ _randGen w torque = fromMaybe 0 $ itm ^? itUse . heldParams . torqueAfter --- rotateScope = fromMaybe id $ do --- i <- yourScopeInvID w --- return $ cWorld . lWorld . creatures . ix cid . crInv . ix i . itUse . attachParams . scrollAttachParams . opticPos %~ rotateV rot - -- (Muzzle,Int,Int) = (muzzle, amountloaded, id of mag taken from) loadMuzzle :: LabelDoubleTree ComposeLinkType Item diff --git a/src/Dodge/Item.hs b/src/Dodge/Item.hs index abf00d2be..5321055f2 100644 --- a/src/Dodge/Item.hs +++ b/src/Dodge/Item.hs @@ -38,7 +38,7 @@ itemFromAmmoMag at = case at of itemFromAttachType :: AttachType -> Item itemFromAttachType at = case at of - SCROLLATTACH ZOOMSCOPE -> zoomScope + ZOOMSCOPE -> zoomScope TARGETATTACH tt -> targetingScope tt BULLETSYNTHESIZER -> bulletSynthesizer ROCKETREMOTESCREEN -> rocketRemoteScreen diff --git a/src/Dodge/Item/Display.hs b/src/Dodge/Item/Display.hs index 4c8b9f5f5..d4823bbf8 100644 --- a/src/Dodge/Item/Display.hs +++ b/src/Dodge/Item/Display.hs @@ -73,7 +73,7 @@ itemBaseName it = case _iyBase $ _itType it of showAttachItem :: AttachType -> String showAttachItem t = case t of - SCROLLATTACH x -> show x + ZOOMSCOPE -> "ZOOMSCOPE" TARGETATTACH x -> show x BULLETSYNTHESIZER -> "BSYNTH" ROCKETREMOTESCREEN -> "REMOTE SCREEN" diff --git a/src/Dodge/Item/Grammar.hs b/src/Dodge/Item/Grammar.hs index 4e32e0b14..05b5c5fbc 100644 --- a/src/Dodge/Item/Grammar.hs +++ b/src/Dodge/Item/Grammar.hs @@ -34,7 +34,7 @@ baseComposedItem ibt itm = case ibt of AMMOMAG _ -> ammoComposedItem itm ATTACH BULLETSYNTHESIZER -> (AmmoModifierCI BulletAmmo, [], []) ATTACH (TARGETATTACH{}) -> (WeaponTargetingCI, [], []) - ATTACH (SCROLLATTACH ZOOMSCOPE) -> (WeaponScopeCI, [], []) + ATTACH ZOOMSCOPE -> (WeaponScopeCI, [], []) ATTACH ROCKETHOMER -> (AmmoModifierCI ProjectileAmmo, [], []) ATTACH ROCKETREMOTESCREEN -> (AmmoModifierCI ProjectileAmmo, [], []) _ -> (UncomposableCI, [], []) diff --git a/src/Dodge/Item/Scope.hs b/src/Dodge/Item/Scope.hs index a12900244..e4f82a998 100644 --- a/src/Dodge/Item/Scope.hs +++ b/src/Dodge/Item/Scope.hs @@ -11,7 +11,7 @@ import Dodge.Default.Item zoomScope :: Item zoomScope = defaultHeldItem - & itType . iyBase .~ ATTACH (SCROLLATTACH ZOOMSCOPE) + & itType . iyBase .~ ATTACH ZOOMSCOPE -- & itUse .~ AttachUse (ScrollAttachParams (ZoomScrollParams{_opticPos = 0, _opticZoom = 1, _opticDefaultZoom = 0.5})) & itScope .~ OpticScope{_opticPos = 0, _opticZoom = 1, _opticDefaultZoom = 0.5} diff --git a/src/Dodge/Update/Camera.hs b/src/Dodge/Update/Camera.hs index 0ece2bda6..7fb0acde6 100644 --- a/src/Dodge/Update/Camera.hs +++ b/src/Dodge/Update/Camera.hs @@ -72,34 +72,31 @@ updateInGameCamera :: Configuration -> World -> World updateInGameCamera cfig w = w & updateBounds cfig - & over wCam (setViewDistance cfig) & wCam %~ moveZoomCamera cfig (w ^. input) (you w) & updateScopeZoom & rotateCamera cfig + & over wCam (setViewDistance cfig) -- I think this should be updated after the zoom? moveZoomCamera :: Configuration -> Input -> Creature -> Camera -> Camera moveZoomCamera cfig theinput cr campos = campos - & camCenter .~ newcen - & camViewFrom .~ newvf + & camCenter .~ _crPos cr +.+ offset + & camViewFrom .~ _crPos cr +.+ vfoffset & camZoom .~ newzoom & camDefaultZoom .~ newDefaultZoom & camItemZoom .~ newItemZoom where - newvf = _crPos cr +.+ fromMaybe (V2 0 0) vfoffset - vfoffset = do + vfoffset = fromMaybe 0 $ do guard (SDL.ButtonRight `M.member` _mouseButtons theinput) i <- cr ^? crManipulation . manObject . inInventory . ispItem (cr ^? crInv . ix i . itScope . remotePos) - camrot = campos ^. camRot - newcen = _crPos cr +.+ offset + docamrot = rotateV (campos ^. camRot) offset = fromMaybe noscopeoffset $ do guard (SDL.ButtonRight `M.member` _mouseButtons theinput) i <- cr ^? crManipulation . manObject . inInventory . ispItem - (fmap (rotateV camrot) (cr ^? crInv . ix i . itScope . opticPos)) + (fmap docamrot (cr ^? crInv . ix i . itScope . opticPos)) <|> (cr ^? crInv . ix i . itScope . remotePos) - noscopeoffset = - rotateV (campos ^. camRot) $ + noscopeoffset = docamrot $ ((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do i <- cr ^? crManipulation . manObject . inInventory . ispItem @@ -137,13 +134,12 @@ updateScopeZoom w = fromMaybe w $ do updateScopeZoom' :: Int -> World -> World updateScopeZoom' i w | SDL.ButtonRight `M.member` _mouseButtons (_input w) = - w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) mp + w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) (w ^. input . mousePos) | otherwise = w & wppointer %~ resetscope where wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itScope resetscope (OpticScope _ _ defz) = OpticScope (V2 0 0) defz defz resetscope otherAtt = otherAtt - mp = _mousePos (_input w) doScopeZoom :: Int -> Point2 -> Scope -> Scope doScopeZoom scrollamount mp sc = case scrollamount of @@ -249,6 +245,8 @@ findBoundDists cfig w hw = halfWidth cfig hh = halfHeight cfig +-- this probably doesn't need to be updated every frame, +-- though I'm not sure how often it should be updated updateBounds :: Configuration -> World -> World updateBounds cfig w = case (w ^. cWorld . cClock) `mod` 5 of 0 -> w