Cleanup
This commit is contained in:
@@ -2,29 +2,29 @@ module Dodge.Creature.YourControl
|
|||||||
( yourControl
|
( yourControl
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.LightSource
|
||||||
import Dodge.Base.Coordinate
|
import Dodge.Base.Coordinate
|
||||||
import Dodge.Creature.Impulse.Movement
|
import Dodge.Creature.Impulse.Movement
|
||||||
import Dodge.Creature.Test
|
import Dodge.Creature.Test
|
||||||
import Dodge.Update.UsingInput
|
import Dodge.Update.UsingInput
|
||||||
import Dodge.InputFocus
|
import Dodge.InputFocus
|
||||||
--import Dodge.Config.KeyConfig
|
|
||||||
import Geometry
|
import Geometry
|
||||||
|
import LensHelp
|
||||||
|
|
||||||
import Control.Lens
|
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
--import qualified Data.Set as S
|
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
--import qualified Data.IntMap.Strict as IM
|
|
||||||
--import Data.Maybe
|
|
||||||
{- | The AI equivalent for your control. -}
|
{- | The AI equivalent for your control. -}
|
||||||
yourControl :: Creature -> World -> World
|
yourControl :: Creature -> World -> World
|
||||||
yourControl cr w
|
yourControl cr w
|
||||||
| inTermFocus w = w & updateUsingInput
|
| inTermFocus w = dimCreatureLight cr w & updateUsingInput
|
||||||
| otherwise = w
|
| otherwise = dimCreatureLight cr w
|
||||||
& creatures . ix (_crID cr) %~
|
& creatures . ix (_crID cr) %~
|
||||||
(wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons w))
|
(wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons w))
|
||||||
& updateUsingInput
|
& updateUsingInput
|
||||||
|
|
||||||
|
dimCreatureLight :: Creature -> World -> World
|
||||||
|
dimCreatureLight cr = tempLightSources .:~ tlsTimeRadColPos 1 300 0.1 (addZ 100 $ _crPos cr)
|
||||||
|
|
||||||
-- note the order of operation, setting the posture first--this prevents the twist fire bug
|
-- note the order of operation, setting the posture first--this prevents the twist fire bug
|
||||||
|
|
||||||
{- | Turn key presses into creature movement. -}
|
{- | Turn key presses into creature movement. -}
|
||||||
|
|||||||
@@ -292,11 +292,6 @@ data Gust = Gust
|
|||||||
, _guVel :: Point2
|
, _guVel :: Point2
|
||||||
, _guTime :: Int
|
, _guTime :: Int
|
||||||
}
|
}
|
||||||
data TempLightSource = TLS
|
|
||||||
{ _tlsParam :: LSParam
|
|
||||||
, _tlsUpdate :: World -> TempLightSource -> Maybe TempLightSource
|
|
||||||
, _tlsTime :: !Int
|
|
||||||
}
|
|
||||||
data CreatureType
|
data CreatureType
|
||||||
= Humanoid
|
= Humanoid
|
||||||
{ _skinHead :: Color
|
{ _skinHead :: Color
|
||||||
@@ -1383,7 +1378,6 @@ makeLenses ''Damage
|
|||||||
makeLenses ''DamageEffect
|
makeLenses ''DamageEffect
|
||||||
makeLenses ''World
|
makeLenses ''World
|
||||||
makeLenses ''Creature
|
makeLenses ''Creature
|
||||||
makeLenses ''TempLightSource
|
|
||||||
makeLenses ''Item
|
makeLenses ''Item
|
||||||
makeLenses ''ItemUse
|
makeLenses ''ItemUse
|
||||||
makeLenses ''ItEffect
|
makeLenses ''ItEffect
|
||||||
|
|||||||
@@ -16,5 +16,11 @@ data LightSource = LS
|
|||||||
, _lsDir :: !Float
|
, _lsDir :: !Float
|
||||||
, _lsPict :: LightSource -> Picture
|
, _lsPict :: LightSource -> Picture
|
||||||
}
|
}
|
||||||
|
data TempLightSource = TLS
|
||||||
|
{ _tlsParam :: LSParam
|
||||||
|
, _tlsUpdate :: TempLightSource -> Maybe TempLightSource
|
||||||
|
, _tlsTime :: !Int
|
||||||
|
}
|
||||||
makeLenses ''LSParam
|
makeLenses ''LSParam
|
||||||
makeLenses ''LightSource
|
makeLenses ''LightSource
|
||||||
|
makeLenses ''TempLightSource
|
||||||
|
|||||||
@@ -31,6 +31,6 @@ defaultTLS = TLS
|
|||||||
, _tlsTime = 1
|
, _tlsTime = 1
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
f _ t
|
f t
|
||||||
| _tlsTime t <= 0 = Nothing
|
| _tlsTime t <= 0 = Nothing
|
||||||
| otherwise = Just $ t & tlsTime -~ 1
|
| otherwise = Just $ t & tlsTime -~ 1
|
||||||
|
|||||||
+13
-16
@@ -10,10 +10,7 @@ import Geometry.Zone
|
|||||||
--import Picture
|
--import Picture
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Geometry.Polygon
|
import Geometry.Polygon
|
||||||
--import Picture.Texture
|
|
||||||
--import Data.Preload
|
|
||||||
|
|
||||||
import Control.Lens
|
|
||||||
import System.Random
|
import System.Random
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
@@ -85,7 +82,7 @@ defaultWorld = World
|
|||||||
, _carteRot = 0
|
, _carteRot = 0
|
||||||
}
|
}
|
||||||
, _lightSources = IM.empty
|
, _lightSources = IM.empty
|
||||||
, _tempLightSources = [youLight]
|
, _tempLightSources = []
|
||||||
, _closeObjects = []
|
, _closeObjects = []
|
||||||
, _rbOptions = NoRightButtonOptions
|
, _rbOptions = NoRightButtonOptions
|
||||||
, _seenLocations = IM.fromList
|
, _seenLocations = IM.fromList
|
||||||
@@ -121,15 +118,15 @@ defaultWorld = World
|
|||||||
}
|
}
|
||||||
defaultWorldHammers :: M.Map WorldHammer HammerPosition
|
defaultWorldHammers :: M.Map WorldHammer HammerPosition
|
||||||
defaultWorldHammers = M.fromSet (const HammerUp) $ S.fromList [minBound.. maxBound]
|
defaultWorldHammers = M.fromSet (const HammerUp) $ S.fromList [minBound.. maxBound]
|
||||||
youLight :: TempLightSource
|
--youLight :: TempLightSource
|
||||||
youLight = TLS
|
--youLight = TLS
|
||||||
{ _tlsParam = LSParam
|
-- { _tlsParam = LSParam
|
||||||
{_lsPos = V3 0 0 0
|
-- {_lsPos = V3 0 0 0
|
||||||
,_lsRad = 300
|
-- ,_lsRad = 300
|
||||||
,_lsCol = 0.1
|
-- ,_lsCol = 0.1
|
||||||
}
|
-- }
|
||||||
,_tlsUpdate = \w _ -> Just (youLight & tlsParam . lsPos .~ f (_crPos $ you w))
|
-- ,_tlsUpdate = \w _ -> Just (youLight & tlsParam . lsPos .~ f (_crPos $ you w))
|
||||||
,_tlsTime = 0
|
-- ,_tlsTime = 0
|
||||||
}
|
-- }
|
||||||
where
|
-- where
|
||||||
f (V2 x y) = V3 x y 100
|
-- f (V2 x y) = V3 x y 100
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ tlsTimeRadFunPos t rmax intensityF p = TLS
|
|||||||
, _tlsTime = t
|
, _tlsTime = t
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
upF _ tls
|
upF tls
|
||||||
| _tlsTime tls <= 0 = Nothing
|
| _tlsTime tls <= 0 = Nothing
|
||||||
| otherwise = Just $ tls
|
| otherwise = Just $ tls
|
||||||
& tlsTime -~ 1
|
& tlsTime -~ 1
|
||||||
@@ -83,7 +83,7 @@ tlsTimeRadColPos t rmax col (V3 x y z) = TLS
|
|||||||
, _tlsTime = t
|
, _tlsTime = t
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
upF _ tls
|
upF tls
|
||||||
| _tlsTime tls <= 0 = Nothing
|
| _tlsTime tls <= 0 = Nothing
|
||||||
| otherwise = Just $ tls
|
| otherwise = Just $ tls
|
||||||
& tlsTime -~ 1
|
& tlsTime -~ 1
|
||||||
|
|||||||
+2
-2
@@ -202,9 +202,9 @@ updateDistortions :: World -> World
|
|||||||
updateDistortions = distortions %~ mapMaybe updateDistortion
|
updateDistortions = distortions %~ mapMaybe updateDistortion
|
||||||
|
|
||||||
updateLightSources :: World -> World
|
updateLightSources :: World -> World
|
||||||
updateLightSources w = over tempLightSources f w
|
updateLightSources = tempLightSources %~ f
|
||||||
where
|
where
|
||||||
f = mapMaybe (\b -> _tlsUpdate b w b)
|
f = mapMaybe (\b -> _tlsUpdate b b)
|
||||||
|
|
||||||
updateRadarBlips :: World -> World
|
updateRadarBlips :: World -> World
|
||||||
updateRadarBlips = radarBlips %~ mapMaybe updateRadarBlip
|
updateRadarBlips = radarBlips %~ mapMaybe updateRadarBlip
|
||||||
|
|||||||
Reference in New Issue
Block a user