Cleanup
This commit is contained in:
@@ -8,13 +8,7 @@ import Control.Lens
|
||||
import qualified Data.Sequence as Seq
|
||||
|
||||
data ItAttachment
|
||||
= ItScope
|
||||
{_scopePos :: Point2 -- ^ a camera offset
|
||||
,_scopeZoomChange :: Int
|
||||
,_scopeZoom :: Float
|
||||
,_scopeIsCamera :: Bool -- ^ if the camera offset is also the center of vision
|
||||
}
|
||||
| ItFuse {_itFuseTime :: Int}
|
||||
= ItFuse {_itFuseTime :: Int}
|
||||
| ItMode {_itMode :: Int}
|
||||
| ItCharMode {_itCharMode :: Seq.Seq Char }
|
||||
| ItTargetPos { _itTargetPos :: Point2 }
|
||||
@@ -24,4 +18,18 @@ data ItAttachment
|
||||
| ItBool { _itBool :: Bool }
|
||||
| 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 ''Scope
|
||||
|
||||
@@ -429,7 +429,7 @@ multGun = defaultGun
|
||||
, _itTweaks = defaultBulletSelTweak
|
||||
}
|
||||
longGun :: Item
|
||||
longGun = defaultGun
|
||||
longGun = defaultGun
|
||||
{ _itName = "LONGGUN"
|
||||
, _itType = LONGGUN
|
||||
, _itConsumption = defaultAmmo
|
||||
@@ -453,23 +453,17 @@ longGun = defaultGun
|
||||
& useAim . aimRange .~ 1
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
|
||||
-- , _itFloorPict = longGunSPic
|
||||
-- , _itZoom = defaultItZoom
|
||||
, _itScroll = zoomLongGun
|
||||
, _itAttachment = ItScope (V2 0 0) 0 1 False
|
||||
, _itAttachment = NoItAttachment
|
||||
, _itScope = ZoomScope (V2 0 0) 0 1 False
|
||||
, _itEffect = itemLaserScopeEffect
|
||||
}
|
||||
|
||||
zoomLongGun :: Float -> Creature -> Item -> Item
|
||||
zoomLongGun x _
|
||||
| x > 0 = startZoomInLongGun
|
||||
| x < 0 = startZoomOutLongGun
|
||||
| x > 0 = itScope . scopeZoomChange %~ (max 5 . (+5))
|
||||
| x < 0 = itScope . scopeZoomChange %~ (min (-5) . subtract 5)
|
||||
| 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 = 0.07
|
||||
|
||||
@@ -27,32 +27,6 @@ import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.Set as S
|
||||
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.
|
||||
TODO add the laser scope!
|
||||
-}
|
||||
|
||||
@@ -202,7 +202,7 @@ moveRemoteBomb itid time pID w
|
||||
setRemoteBombScope :: Int -> Prop -> World -> World
|
||||
setRemoteBombScope itid pj w' = case _itemPositions w' IM.! itid of
|
||||
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))
|
||||
& creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
|
||||
.~ (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 itid 0 pjid w = w
|
||||
& pointToItem (_itemPositions w IM.! itid) %~
|
||||
( (itAttachment . scopePos .~ V2 0 0)
|
||||
( (itScope . scopePos .~ V2 0 0)
|
||||
-- . (itZoom .~ defaultItZoom)
|
||||
. (itUse . rUse .~ const throwRemoteBomb)
|
||||
)
|
||||
@@ -303,7 +303,7 @@ retireRemoteBomb itid t pjid w = setScope w
|
||||
where
|
||||
setScope w' = case _itemPositions w' IM.! itid of
|
||||
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))
|
||||
_ -> w'
|
||||
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
|
||||
|
||||
@@ -282,7 +282,7 @@ remoteLauncher = launcher
|
||||
& useAim . aimSpeed .~ 0.2
|
||||
& useAim . aimRange .~ 0.5
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
, _itAttachment = ItScope (V2 0 0) 0 1 True
|
||||
, _itScope = RemoteScope (V2 0 0) 1 True
|
||||
-- , _itParams = ShellLauncher
|
||||
-- { _tweakSel = 0
|
||||
-- , _tweakParams = basicAmPjMoves -- TODO change to allow tweaking rocket speed
|
||||
@@ -409,7 +409,7 @@ remoteShellPic t
|
||||
| otherwise = red
|
||||
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
||||
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)
|
||||
(w & props %~ IM.delete pjid)
|
||||
retireRemoteRocket itid t pjid w = setScope w
|
||||
@@ -417,7 +417,7 @@ retireRemoteRocket itid t pjid w = setScope w
|
||||
where
|
||||
setScope w' = case _itemPositions w' IM.! itid of
|
||||
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))
|
||||
_ -> w'
|
||||
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 itid pj w' = case w' ^? itemPositions . ix itid of
|
||||
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'))
|
||||
_ -> w'
|
||||
|
||||
Reference in New Issue
Block a user