Cleanup
This commit is contained in:
@@ -112,7 +112,7 @@ moduleCombinations =
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
, ( ModBulletTarget
|
, ( ModBulletTarget
|
||||||
, bulletWeapons
|
, launcher : bulletWeapons
|
||||||
, [amod [TELEPORTMODULE,MICROCHIP] "+TELEPORT" (itUse . useMods .:~ withPositionWallCheck (const . const mouseWorldPos))
|
, [amod [TELEPORTMODULE,MICROCHIP] "+TELEPORT" (itUse . useMods .:~ withPositionWallCheck (const . const mouseWorldPos))
|
||||||
,amod [TELEPORTMODULE] "+DIRECTEDTELE" makeDirectedTele
|
,amod [TELEPORTMODULE] "+DIRECTEDTELE" makeDirectedTele
|
||||||
]
|
]
|
||||||
@@ -121,7 +121,11 @@ moduleCombinations =
|
|||||||
where
|
where
|
||||||
makeDirectedTele it = it & itEffect .~ rbSetTarget
|
makeDirectedTele it = it & itEffect .~ rbSetTarget
|
||||||
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
|
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
|
||||||
|
-- for the camera: the simplest option is to remove all zoom/offset
|
||||||
& itUse . useAim . aimZoom . itZoomFac .~ 1
|
& itUse . useAim . aimZoom . itZoomFac .~ 1
|
||||||
|
& itUse . useAim . aimRange .~ 0
|
||||||
|
-- a better option would be to involve a "scope" centered on the firing
|
||||||
|
-- position
|
||||||
directedTelPos it cr w = (p,a)
|
directedTelPos it cr w = (p,a)
|
||||||
where
|
where
|
||||||
p = fromMaybe (_crPos cr) $ do
|
p = fromMaybe (_crPos cr) $ do
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ wasdWithAiming w speed i cr
|
|||||||
isAiming = _posture (_crStance cr) == Aiming
|
isAiming = _posture (_crStance cr) == Aiming
|
||||||
isReloading = _posture (_crStance cr) == Reloading
|
isReloading = _posture (_crStance cr) == Reloading
|
||||||
mouseDir = case w ^? creatures . ix i . crInv . ix (_crInvSel (_creatures w IM.! i))
|
mouseDir = case w ^? creatures . ix i . crInv . ix (_crInvSel (_creatures w IM.! i))
|
||||||
. itAttachment of
|
. itScope . scopePos of
|
||||||
Just ItScope{_scopePos = p} -> normalizeAngle $ argV
|
Just p -> normalizeAngle $ argV
|
||||||
$ p +.+ 2 / _cameraZoom w
|
$ p +.+ 2 / _cameraZoom w
|
||||||
*.* rotateV (_cameraRot w) (_mousePos w)
|
*.* rotateV (_cameraRot w) (_mousePos w)
|
||||||
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
|
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
|
||||||
|
|||||||
+21
-22
@@ -356,28 +356,27 @@ data ItemConsumption
|
|||||||
{ _itAmount :: Int
|
{ _itAmount :: Int
|
||||||
}
|
}
|
||||||
| NoConsumption
|
| NoConsumption
|
||||||
data Item
|
data Item = Item
|
||||||
= Item
|
{ _itName :: String
|
||||||
{ _itName :: String
|
, _itConsumption :: ItemConsumption
|
||||||
, _itConsumption :: ItemConsumption
|
, _itUse :: ItemUse
|
||||||
, _itUse :: ItemUse
|
, _itEquipPict :: Creature -> Int -> SPic
|
||||||
, _itEquipPict :: Creature -> Int -> SPic
|
, _itScroll :: Float -> Creature -> Item -> Item
|
||||||
, _itScroll :: Float -> Creature -> Item -> Item
|
, _itType :: CombineType
|
||||||
, _itType :: CombineType
|
, _itAttachment :: ItAttachment
|
||||||
, _itAttachment :: ItAttachment
|
, _itID :: Maybe Int
|
||||||
, _itID :: Maybe Int
|
, _itEffect :: ItEffect
|
||||||
, _itEffect :: ItEffect
|
, _itInvSize :: Float
|
||||||
, _itInvSize :: Float
|
, _itInvDisplay :: Item -> [String]
|
||||||
, _itInvDisplay :: Item -> [String]
|
, _itInvColor :: Color
|
||||||
, _itInvColor :: Color
|
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
|
||||||
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
|
, _itDimension :: ItemDimension
|
||||||
, _itDimension :: ItemDimension
|
, _itCurseStatus :: CurseStatus
|
||||||
, _itCurseStatus :: CurseStatus
|
, _itParams :: ItemParams
|
||||||
, _itParams :: ItemParams
|
, _itTweaks :: ItemTweaks
|
||||||
, _itTweaks :: ItemTweaks
|
, _itModules :: M.Map ModuleSlot ItemModule
|
||||||
, _itModules :: M.Map ModuleSlot ItemModule
|
, _itScope :: Scope
|
||||||
}
|
}
|
||||||
|
|
||||||
data ModuleSlot
|
data ModuleSlot
|
||||||
= ModBullet
|
= ModBullet
|
||||||
| ModRifleMag
|
| ModRifleMag
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ defaultEquipment = Item
|
|||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
, _itTargeting = Nothing
|
, _itTargeting = Nothing
|
||||||
, _itModules = M.empty
|
, _itModules = M.empty
|
||||||
|
, _itScope = NoScope
|
||||||
}
|
}
|
||||||
defaultItZoom :: ItZoom
|
defaultItZoom :: ItZoom
|
||||||
defaultItZoom = ItZoom 20 0.2 1
|
defaultItZoom = ItZoom 20 0.2 1
|
||||||
@@ -180,6 +181,7 @@ defaultConsumable = Item
|
|||||||
, _itDimension = defItDimCol blue
|
, _itDimension = defItDimCol blue
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
, _itModules = M.empty
|
, _itModules = M.empty
|
||||||
|
, _itScope = NoScope
|
||||||
}
|
}
|
||||||
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
|
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
|
||||||
defaultApplyDamage ds cr = (id, doPoisonDam $ foldl' (flip $ \d c -> snd $ applyIndividualDamage d c) cr ds')
|
defaultApplyDamage ds cr = (id, doPoisonDam $ foldl' (flip $ \d c -> snd $ applyIndividualDamage d c) cr ds')
|
||||||
|
|||||||
@@ -103,16 +103,15 @@ defaultGun = Item
|
|||||||
, _itModules = M.fromList [(ModBullet , DefaultModule)
|
, _itModules = M.fromList [(ModBullet , DefaultModule)
|
||||||
,(ModBulletTarget,DefaultModule)
|
,(ModBulletTarget,DefaultModule)
|
||||||
]
|
]
|
||||||
|
, _itScope = NoScope
|
||||||
}
|
}
|
||||||
defaultCraftable :: Item
|
defaultCraftable :: Item
|
||||||
defaultCraftable = Item
|
defaultCraftable = Item
|
||||||
{ _itName = "default"
|
{ _itName = "default"
|
||||||
, _itType = NoCombineType
|
, _itType = NoCombineType
|
||||||
, _itCurseStatus = Uncursed
|
, _itCurseStatus = Uncursed
|
||||||
-- , _itIdentity = Generic
|
|
||||||
, _itConsumption = NoConsumption
|
, _itConsumption = NoConsumption
|
||||||
, _itUse = NoUse
|
, _itUse = NoUse
|
||||||
-- , _itZoom = ItZoom 20 0.2 1
|
|
||||||
, _itEquipPict = pictureWeaponOnAim
|
, _itEquipPict = pictureWeaponOnAim
|
||||||
, _itScroll = \_ _ -> id
|
, _itScroll = \_ _ -> id
|
||||||
, _itAttachment = NoItAttachment
|
, _itAttachment = NoItAttachment
|
||||||
@@ -126,6 +125,7 @@ defaultCraftable = Item
|
|||||||
, _itDimension = defItDimCol green
|
, _itDimension = defItDimCol green
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
, _itModules = M.empty
|
, _itModules = M.empty
|
||||||
|
, _itScope = NoScope
|
||||||
}
|
}
|
||||||
defItDim :: ItemDimension
|
defItDim :: ItemDimension
|
||||||
defItDim = ItemDimension
|
defItDim = ItemDimension
|
||||||
|
|||||||
@@ -8,13 +8,7 @@ import Control.Lens
|
|||||||
import qualified Data.Sequence as Seq
|
import qualified Data.Sequence as Seq
|
||||||
|
|
||||||
data ItAttachment
|
data ItAttachment
|
||||||
= ItScope
|
= ItFuse {_itFuseTime :: Int}
|
||||||
{_scopePos :: Point2 -- ^ a camera offset
|
|
||||||
,_scopeZoomChange :: Int
|
|
||||||
,_scopeZoom :: Float
|
|
||||||
,_scopeIsCamera :: Bool -- ^ if the camera offset is also the center of vision
|
|
||||||
}
|
|
||||||
| ItFuse {_itFuseTime :: Int}
|
|
||||||
| ItMode {_itMode :: Int}
|
| ItMode {_itMode :: Int}
|
||||||
| ItCharMode {_itCharMode :: Seq.Seq Char }
|
| ItCharMode {_itCharMode :: Seq.Seq Char }
|
||||||
| ItTargetPos { _itTargetPos :: Point2 }
|
| ItTargetPos { _itTargetPos :: Point2 }
|
||||||
@@ -24,4 +18,18 @@ data ItAttachment
|
|||||||
| ItBool { _itBool :: Bool }
|
| ItBool { _itBool :: Bool }
|
||||||
| NoItAttachment
|
| NoItAttachment
|
||||||
|
|
||||||
|
data Scope = NoScope
|
||||||
|
| RemoteScope
|
||||||
|
{_scopePos :: Point2 -- ^ a camera offset
|
||||||
|
,_scopeZoom :: Float
|
||||||
|
,_scopeIsCamera :: Bool -- ^ if the camera offset is also the center of vision
|
||||||
|
}
|
||||||
|
| ZoomScope
|
||||||
|
{_scopePos :: Point2 -- ^ a camera offset
|
||||||
|
,_scopeZoomChange :: Int
|
||||||
|
,_scopeZoom :: Float
|
||||||
|
,_scopeIsCamera :: Bool -- ^ if the camera offset is also the center of vision
|
||||||
|
}
|
||||||
|
|
||||||
makeLenses ''ItAttachment
|
makeLenses ''ItAttachment
|
||||||
|
makeLenses ''Scope
|
||||||
|
|||||||
@@ -453,23 +453,17 @@ longGun = defaultGun
|
|||||||
& useAim . aimRange .~ 1
|
& useAim . aimRange .~ 1
|
||||||
& useAim . aimStance .~ TwoHandTwist
|
& useAim . aimStance .~ TwoHandTwist
|
||||||
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
|
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
|
||||||
-- , _itFloorPict = longGunSPic
|
|
||||||
-- , _itZoom = defaultItZoom
|
|
||||||
, _itScroll = zoomLongGun
|
, _itScroll = zoomLongGun
|
||||||
, _itAttachment = ItScope (V2 0 0) 0 1 False
|
, _itAttachment = NoItAttachment
|
||||||
|
, _itScope = ZoomScope (V2 0 0) 0 1 False
|
||||||
, _itEffect = itemLaserScopeEffect
|
, _itEffect = itemLaserScopeEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
zoomLongGun :: Float -> Creature -> Item -> Item
|
zoomLongGun :: Float -> Creature -> Item -> Item
|
||||||
zoomLongGun x _
|
zoomLongGun x _
|
||||||
| x > 0 = startZoomInLongGun
|
| x > 0 = itScope . scopeZoomChange %~ (max 5 . (+5))
|
||||||
| x < 0 = startZoomOutLongGun
|
| x < 0 = itScope . scopeZoomChange %~ (min (-5) . subtract 5)
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
|
|
||||||
startZoomInLongGun :: Item -> Item
|
|
||||||
startZoomInLongGun = itAttachment . scopeZoomChange %~ \x -> max 5 (x + 5)
|
|
||||||
startZoomOutLongGun :: Item -> Item
|
|
||||||
startZoomOutLongGun = itAttachment . scopeZoomChange %~ \x -> min (-5) (x-5)
|
|
||||||
|
|
||||||
autogunSpread :: Float
|
autogunSpread :: Float
|
||||||
autogunSpread = 0.07
|
autogunSpread = 0.07
|
||||||
|
|||||||
@@ -27,32 +27,6 @@ import qualified Data.IntMap.Strict as IM
|
|||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
{- |
|
{- |
|
||||||
Controls resetting a weapon, allows for non-continuous fire needing a button release. -}
|
|
||||||
--wpRecock :: ItEffect
|
|
||||||
--wpRecock = ItInvEffect
|
|
||||||
-- {_itInvEffect = f
|
|
||||||
-- ,_itEffectCounter = 0
|
|
||||||
-- }
|
|
||||||
-- where
|
|
||||||
-- f _ cr invid = creatures . ix (_crID cr) . crInv . ix invid
|
|
||||||
-- . itUse . useHammer . hammerPosition %~ moveHammerUp
|
|
||||||
-- moveHammerUp HammerDown = HammerReleased
|
|
||||||
-- moveHammerUp HammerReleased = HammerUp
|
|
||||||
-- moveHammerUp HammerUp = HammerUp
|
|
||||||
--{- |
|
|
||||||
--Special recock for the bezier gun.
|
|
||||||
--Not sure of its purpose at this time... -}
|
|
||||||
--bezierRecock :: ItEffect
|
|
||||||
--bezierRecock = ItInvEffect
|
|
||||||
-- {_itInvEffect = f
|
|
||||||
-- ,_itEffectCounter = 0
|
|
||||||
-- }
|
|
||||||
-- where
|
|
||||||
-- f _ cr i = creatures . ix (_crID cr) . crInv %~ IM.adjust fOnIt i
|
|
||||||
-- fOnIt it = case _itHammer it of
|
|
||||||
-- HammerDown -> it & itHammer .~ HammerUp
|
|
||||||
-- _ -> it & itAttachment .~ NoItAttachment
|
|
||||||
{- |
|
|
||||||
Creates a laser scope and recocks the weapon.
|
Creates a laser scope and recocks the weapon.
|
||||||
TODO add the laser scope!
|
TODO add the laser scope!
|
||||||
-}
|
-}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ moveRemoteBomb itid time pID w
|
|||||||
setRemoteBombScope :: Int -> Prop -> World -> World
|
setRemoteBombScope :: Int -> Prop -> World -> World
|
||||||
setRemoteBombScope itid pj w' = case _itemPositions w' IM.! itid of
|
setRemoteBombScope itid pj w' = case _itemPositions w' IM.! itid of
|
||||||
InInv cid invid
|
InInv cid invid
|
||||||
-> w' & creatures . ix cid . crInv . ix invid . itAttachment
|
-> w' & creatures . ix cid . crInv . ix invid . itScope
|
||||||
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid))
|
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid))
|
||||||
& creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
|
& creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
|
||||||
.~ (defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5})
|
.~ (defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5})
|
||||||
@@ -293,7 +293,7 @@ remoteBombUnarmedPic = color (dark $ dark orange) $ circleSolid 5
|
|||||||
retireRemoteBomb :: Int -> Int -> Int -> World -> World
|
retireRemoteBomb :: Int -> Int -> Int -> World -> World
|
||||||
retireRemoteBomb itid 0 pjid w = w
|
retireRemoteBomb itid 0 pjid w = w
|
||||||
& pointToItem (_itemPositions w IM.! itid) %~
|
& pointToItem (_itemPositions w IM.! itid) %~
|
||||||
( (itAttachment . scopePos .~ V2 0 0)
|
( (itScope . scopePos .~ V2 0 0)
|
||||||
-- . (itZoom .~ defaultItZoom)
|
-- . (itZoom .~ defaultItZoom)
|
||||||
. (itUse . rUse .~ const throwRemoteBomb)
|
. (itUse . rUse .~ const throwRemoteBomb)
|
||||||
)
|
)
|
||||||
@@ -303,7 +303,7 @@ retireRemoteBomb itid t pjid w = setScope w
|
|||||||
where
|
where
|
||||||
setScope w' = case _itemPositions w' IM.! itid of
|
setScope w' = case _itemPositions w' IM.! itid of
|
||||||
InInv cid invid -> w'
|
InInv cid invid -> w'
|
||||||
& creatures . ix cid . crInv . ix invid . itAttachment
|
& creatures . ix cid . crInv . ix invid . itScope
|
||||||
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
|
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
|
||||||
_ -> w'
|
_ -> w'
|
||||||
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
|
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ remoteLauncher = launcher
|
|||||||
& useAim . aimSpeed .~ 0.2
|
& useAim . aimSpeed .~ 0.2
|
||||||
& useAim . aimRange .~ 0.5
|
& useAim . aimRange .~ 0.5
|
||||||
& useAim . aimStance .~ TwoHandTwist
|
& useAim . aimStance .~ TwoHandTwist
|
||||||
, _itAttachment = ItScope (V2 0 0) 0 1 True
|
, _itScope = RemoteScope (V2 0 0) 1 True
|
||||||
-- , _itParams = ShellLauncher
|
-- , _itParams = ShellLauncher
|
||||||
-- { _tweakSel = 0
|
-- { _tweakSel = 0
|
||||||
-- , _tweakParams = basicAmPjMoves -- TODO change to allow tweaking rocket speed
|
-- , _tweakParams = basicAmPjMoves -- TODO change to allow tweaking rocket speed
|
||||||
@@ -409,7 +409,7 @@ remoteShellPic t
|
|||||||
| otherwise = red
|
| otherwise = red
|
||||||
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
||||||
retireRemoteRocket itid 0 pjid w =
|
retireRemoteRocket itid 0 pjid w =
|
||||||
set (pointToItem (_itemPositions w IM.! itid) . itAttachment . scopePos) (V2 0 0)
|
set (pointToItem (_itemPositions w IM.! itid) . itScope . scopePos) (V2 0 0)
|
||||||
$ set (pointToItem (_itemPositions w IM.! itid) . itUse . rUse) (const fireRemoteLauncher)
|
$ set (pointToItem (_itemPositions w IM.! itid) . itUse . rUse) (const fireRemoteLauncher)
|
||||||
(w & props %~ IM.delete pjid)
|
(w & props %~ IM.delete pjid)
|
||||||
retireRemoteRocket itid t pjid w = setScope w
|
retireRemoteRocket itid t pjid w = setScope w
|
||||||
@@ -417,7 +417,7 @@ retireRemoteRocket itid t pjid w = setScope w
|
|||||||
where
|
where
|
||||||
setScope w' = case _itemPositions w' IM.! itid of
|
setScope w' = case _itemPositions w' IM.! itid of
|
||||||
InInv cid invid -> w'
|
InInv cid invid -> w'
|
||||||
& creatures . ix cid . crInv . ix invid . itAttachment
|
& creatures . ix cid . crInv . ix invid . itScope
|
||||||
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
|
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
|
||||||
_ -> w'
|
_ -> w'
|
||||||
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
|
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
|
||||||
@@ -425,6 +425,6 @@ retireRemoteRocket itid t pjid w = setScope w
|
|||||||
setRemoteScope :: Int -> Prop -> World -> World
|
setRemoteScope :: Int -> Prop -> World -> World
|
||||||
setRemoteScope itid pj w' = case w' ^? itemPositions . ix itid of
|
setRemoteScope itid pj w' = case w' ^? itemPositions . ix itid of
|
||||||
Just (InInv cid' invid )
|
Just (InInv cid' invid )
|
||||||
-> w' & creatures . ix cid' . crInv . ix invid . itAttachment
|
-> w' & creatures . ix cid' . crInv . ix invid . itScope
|
||||||
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid'))
|
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid'))
|
||||||
_ -> w'
|
_ -> w'
|
||||||
|
|||||||
+20
-21
@@ -32,7 +32,7 @@ updateCamera cfig = rotateCamera cfig . autoZoomCamera cfig . moveCamera . updat
|
|||||||
{- Updte the center of the screen camera center and where your avatar's view is from in world. -}
|
{- Updte the center of the screen camera center and where your avatar's view is from in world. -}
|
||||||
moveCamera :: World -> World
|
moveCamera :: World -> World
|
||||||
moveCamera w = w
|
moveCamera w = w
|
||||||
& cameraCenter .~ idealPos
|
& cameraCenter .~ idealPos
|
||||||
& cameraViewFrom .~ sightFrom
|
& cameraViewFrom .~ sightFrom
|
||||||
where
|
where
|
||||||
aimRangeFactor
|
aimRangeFactor
|
||||||
@@ -45,17 +45,16 @@ moveCamera w = w
|
|||||||
idealPos = camCenter
|
idealPos = camCenter
|
||||||
+.+ rotateV (_cameraRot w) (aimRangeFactor * aimingMult *.* _mousePos w)
|
+.+ rotateV (_cameraRot w) (aimRangeFactor * aimingMult *.* _mousePos w)
|
||||||
camCenter = ypos +.+ scopeOffset
|
camCenter = ypos +.+ scopeOffset
|
||||||
scopeOffset = fromMaybe (V2 0 0) $ yourItem w ^? _Just . itAttachment . scopePos
|
scopeOffset = fromMaybe (V2 0 0) $ yourItem w ^? _Just . itScope . scopePos
|
||||||
sightFrom
|
sightFrom = case yourItem w ^? _Just . itScope . scopeIsCamera of
|
||||||
| fromMaybe False $ yourItem w ^? _Just . itAttachment . scopeIsCamera
|
Just True -> camCenter
|
||||||
= camCenter
|
_ -> ypos
|
||||||
| otherwise = ypos
|
|
||||||
|
|
||||||
updateScopeZoom :: World -> World
|
updateScopeZoom :: World -> World
|
||||||
updateScopeZoom w
|
updateScopeZoom w
|
||||||
| SDL.ButtonRight `S.member` _mouseButtons w
|
| SDL.ButtonRight `S.member` _mouseButtons w
|
||||||
= case w ^? creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
= case w ^? creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||||
. itAttachment . scopeZoomChange of
|
. itScope . scopeZoomChange of
|
||||||
Just x
|
Just x
|
||||||
| x > 9 -> zoomInLongGun $ zoomInLongGun w
|
| x > 9 -> zoomInLongGun $ zoomInLongGun w
|
||||||
| x > 0 -> zoomInLongGun w
|
| x > 0 -> zoomInLongGun w
|
||||||
@@ -64,9 +63,9 @@ updateScopeZoom w
|
|||||||
| otherwise -> w
|
| otherwise -> w
|
||||||
_ -> w
|
_ -> w
|
||||||
| otherwise = w & creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
| otherwise = w & creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||||
. itAttachment %~ updateScope
|
. itScope %~ updateScope
|
||||||
where
|
where
|
||||||
updateScope (ItScope _ _ _ bl) = ItScope (V2 0 0) 0 1 bl
|
updateScope (ZoomScope _ _ _ bl) = ZoomScope (V2 0 0) 0 1 bl
|
||||||
updateScope otherAtt = otherAtt
|
updateScope otherAtt = otherAtt
|
||||||
|
|
||||||
zoomSpeed :: Float
|
zoomSpeed :: Float
|
||||||
@@ -74,38 +73,39 @@ zoomSpeed = 39/40
|
|||||||
-- TODO unify zoom in and out, use scroll speed
|
-- TODO unify zoom in and out, use scroll speed
|
||||||
zoomInLongGun :: World -> World
|
zoomInLongGun :: World -> World
|
||||||
zoomInLongGun w
|
zoomInLongGun w
|
||||||
| currentZoom < 8 = over (wpPointer . itAttachment . scopePos)
|
| currentZoom < 8 = over (wpPointer . itScope . scopePos)
|
||||||
(\p -> p +.+ (4-(4*zoomSpeed)) / currentZoom *.* mousep)
|
(\p -> p +.+ (4-(4*zoomSpeed)) / currentZoom *.* mousep)
|
||||||
$ over (wpPointer . itAttachment . scopeZoom) (/ zoomSpeed)
|
$ over (wpPointer . itScope . scopeZoom) (/ zoomSpeed)
|
||||||
$ decreaseScopeZoomChange
|
$ decreaseScopeZoomChange
|
||||||
w
|
w
|
||||||
| otherwise = decreaseScopeZoomChange w
|
| otherwise = decreaseScopeZoomChange w
|
||||||
where
|
where
|
||||||
decreaseScopeZoomChange = wpPointer . itAttachment . scopeZoomChange -~ 1
|
decreaseScopeZoomChange = wpPointer . itScope . scopeZoomChange -~ 1
|
||||||
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||||
wp = _crInv (_creatures w IM.! 0) IM.! _crInvSel (_creatures w IM.! 0)
|
wp = _crInv (_creatures w IM.! 0) IM.! _crInvSel (_creatures w IM.! 0)
|
||||||
Just currentZoom = wp ^? itAttachment . scopeZoom
|
Just currentZoom = wp ^? itScope . scopeZoom
|
||||||
mousep = rotateV (_cameraRot w) $ _mousePos w
|
mousep = rotateV (_cameraRot w) $ _mousePos w
|
||||||
|
|
||||||
zoomOutLongGun :: World -> World
|
zoomOutLongGun :: World -> World
|
||||||
zoomOutLongGun w
|
zoomOutLongGun w
|
||||||
| currentZoom > 0.5 = over (wpPointer . itAttachment . scopeZoom) (* zoomSpeed)
|
| currentZoom > 0.5 = over (wpPointer . itScope . scopeZoom) (* zoomSpeed)
|
||||||
$ increaseScopeZoomChange w
|
$ increaseScopeZoomChange w
|
||||||
| otherwise = increaseScopeZoomChange w
|
| otherwise = increaseScopeZoomChange w
|
||||||
where
|
where
|
||||||
increaseScopeZoomChange = wpPointer . itAttachment . scopeZoomChange +~ 1
|
increaseScopeZoomChange = wpPointer . itScope . scopeZoomChange +~ 1
|
||||||
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||||
wp = _crInv (_creatures w IM.! 0) IM.! _crInvSel (_creatures w IM.! 0)
|
wp = _crInv (_creatures w IM.! 0) IM.! _crInvSel (_creatures w IM.! 0)
|
||||||
Just currentZoom = wp ^? itAttachment . scopeZoom
|
Just currentZoom = wp ^? itScope . scopeZoom
|
||||||
|
|
||||||
ifConfigWallRotate :: Configuration -> World -> World
|
ifConfigWallRotate :: Configuration -> World -> World
|
||||||
ifConfigWallRotate cfig w
|
ifConfigWallRotate cfig w
|
||||||
| _rotate_to_wall cfig && not (SDL.ButtonRight `S.member` _mouseButtons w)
|
| _rotate_to_wall cfig && not (SDL.ButtonRight `S.member` _mouseButtons w)
|
||||||
= rotateToOverlappingWall w
|
= rotateToOverlappingWall w
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
|
|
||||||
rotateToOverlappingWall :: World -> World
|
rotateToOverlappingWall :: World -> World
|
||||||
rotateToOverlappingWall w = maybe w dowallrotate theWall
|
rotateToOverlappingWall w = maybe w dowallrotate
|
||||||
|
$ overlapCircWallsReturnWall p (_crRad cr + 5) (IM.filter _wlRotateTo $ wallsNearPoint p w)
|
||||||
where
|
where
|
||||||
dowallrotate wl' = rotateUsing $ (argV . uncurry (-.-) $ _wlLine wl') - _cameraRot w
|
dowallrotate wl' = rotateUsing $ (argV . uncurry (-.-) $ _wlLine wl') - _cameraRot w
|
||||||
rotateUsing a
|
rotateUsing a
|
||||||
@@ -118,14 +118,13 @@ rotateToOverlappingWall w = maybe w dowallrotate theWall
|
|||||||
b' = fromIntegral (round b :: Int)
|
b' = fromIntegral (round b :: Int)
|
||||||
cr = you w
|
cr = you w
|
||||||
p = _crPos cr
|
p = _crPos cr
|
||||||
theWall = overlapCircWallsReturnWall p (_crRad cr + 5) (IM.filter _wlRotateTo $ wallsNearPoint p w)
|
|
||||||
|
|
||||||
|
|
||||||
rotateCameraBy :: Float -> World -> World
|
rotateCameraBy :: Float -> World -> World
|
||||||
rotateCameraBy x w = w
|
rotateCameraBy x w = w
|
||||||
& cameraRot +~ x
|
& cameraRot +~ x
|
||||||
& creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
& creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||||
. itAttachment . scopePos %~ rotateV x
|
. itScope . scopePos %~ rotateV x
|
||||||
|
|
||||||
rotateCamera :: Configuration -> World -> World
|
rotateCamera :: Configuration -> World -> World
|
||||||
rotateCamera cfig w
|
rotateCamera cfig w
|
||||||
@@ -168,7 +167,7 @@ autoZoomCamera cfig w = w & cameraZoom %~ changeZoom
|
|||||||
-- these speeds are inverted, larger means slower
|
-- these speeds are inverted, larger means slower
|
||||||
zoomInSpeed = 25
|
zoomInSpeed = 25
|
||||||
zoomOutSpeed = 15
|
zoomOutSpeed = 15
|
||||||
theScopeZoom = fromMaybe 1 $ yourItem w ^? _Just . itAttachment . scopeZoom
|
theScopeZoom = fromMaybe 1 $ yourItem w ^? _Just . itScope . scopeZoom
|
||||||
|
|
||||||
farWallDist :: Point2 -> Configuration -> World -> Float
|
farWallDist :: Point2 -> Configuration -> World -> Float
|
||||||
farWallDist p cfig w = (winFac /) . min maxViewDistance $ ssfold (> maxViewDistance) findMax 1 vps
|
farWallDist p cfig w = (winFac /) . min maxViewDistance $ ssfold (> maxViewDistance) findMax 1 vps
|
||||||
|
|||||||
Reference in New Issue
Block a user