Simplify props (should they be removed?)
This commit is contained in:
@@ -7,7 +7,6 @@ import Color
|
|||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import Data.Aeson.TH
|
import Data.Aeson.TH
|
||||||
import Dodge.Data.WorldEffect
|
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import qualified Quaternion as Q
|
import qualified Quaternion as Q
|
||||||
import ShapePicture.Data
|
import ShapePicture.Data
|
||||||
@@ -15,10 +14,8 @@ import ShapePicture.Data
|
|||||||
data Prop = ShapeProp
|
data Prop = ShapeProp
|
||||||
{ _prPos :: Point2
|
{ _prPos :: Point2
|
||||||
, _prDraw :: SPic
|
, _prDraw :: SPic
|
||||||
, _prUpdate :: PropUpdate
|
|
||||||
, _prID :: Int
|
, _prID :: Int
|
||||||
, _prRot :: Float
|
, _prRot :: Float
|
||||||
-- , _prToggle :: Bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data DebrisType
|
data DebrisType
|
||||||
@@ -33,23 +30,9 @@ data Debris = DebrisChunk
|
|||||||
, _dbSpin :: Q.Quaternion Float
|
, _dbSpin :: Q.Quaternion Float
|
||||||
}
|
}
|
||||||
|
|
||||||
data PropUpdate
|
|
||||||
= PropUpdateId
|
|
||||||
| PropUpdates [PropUpdate]
|
|
||||||
| PropUpdatePosition WdP2f
|
|
||||||
| PropUpdateWhen WdBl PropUpdate
|
|
||||||
| PropUpdateIf WdBl PropUpdate PropUpdate
|
|
||||||
|
|
||||||
data PrWdLsLs
|
|
||||||
= PrWdLsId
|
|
||||||
| PrWdLsSetPosition WdP2f Point3
|
|
||||||
| PrWdLsSetColor Point3
|
|
||||||
|
|
||||||
makeLenses ''Prop
|
makeLenses ''Prop
|
||||||
makeLenses ''Debris
|
makeLenses ''Debris
|
||||||
makeLenses ''DebrisType
|
makeLenses ''DebrisType
|
||||||
deriveJSON defaultOptions ''DebrisType
|
deriveJSON defaultOptions ''DebrisType
|
||||||
deriveJSON defaultOptions ''Debris
|
deriveJSON defaultOptions ''Debris
|
||||||
deriveJSON defaultOptions ''PrWdLsLs
|
|
||||||
deriveJSON defaultOptions ''PropUpdate
|
|
||||||
deriveJSON defaultOptions ''Prop
|
deriveJSON defaultOptions ''Prop
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
module Dodge.Default.Prop where
|
|
||||||
|
|
||||||
import Dodge.Data.Prop
|
|
||||||
import Geometry
|
|
||||||
|
|
||||||
defaultProp :: Prop
|
|
||||||
defaultProp =
|
|
||||||
ShapeProp
|
|
||||||
{ _prPos = V2 0 0
|
|
||||||
, _prDraw = mempty
|
|
||||||
, _prID = 0
|
|
||||||
, _prUpdate = PropUpdateId
|
|
||||||
, _prRot = 0
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
module Dodge.Prop.Update (updateProp) where
|
|
||||||
|
|
||||||
import Control.Lens
|
|
||||||
import Data.Foldable
|
|
||||||
import Dodge.Data.World
|
|
||||||
import Dodge.WdP2f
|
|
||||||
import Dodge.WorldBool
|
|
||||||
|
|
||||||
updateProp :: Prop -> World -> World
|
|
||||||
updateProp pr = case _prUpdate pr of
|
|
||||||
PropUpdateId -> id
|
|
||||||
PropUpdates pus -> doPropUpdates pr pus
|
|
||||||
PropUpdatePosition x -> propUpdatePosition x pr
|
|
||||||
PropUpdateWhen t x -> propUpdateIf t x PropUpdateId pr
|
|
||||||
PropUpdateIf t x y -> propUpdateIf t x y pr
|
|
||||||
|
|
||||||
propUpdateIf :: WdBl -> PropUpdate -> PropUpdate -> Prop -> World -> World
|
|
||||||
propUpdateIf wb x y pr w
|
|
||||||
| doWdBl wb w = updateProp (pr & prUpdate .~ x) w
|
|
||||||
| otherwise = updateProp (pr & prUpdate .~ y) w
|
|
||||||
|
|
||||||
propUpdatePosition :: WdP2f -> Prop -> World -> World
|
|
||||||
propUpdatePosition x pr w =
|
|
||||||
w
|
|
||||||
& cWorld . lWorld . props . ix (_prID pr) . prPos .~ fst (doWdP2f x w)
|
|
||||||
& cWorld . lWorld . props . ix (_prID pr) . prRot .~ snd (doWdP2f x w)
|
|
||||||
|
|
||||||
doPropUpdates :: Prop -> [PropUpdate] -> World -> World
|
|
||||||
doPropUpdates pr pus w = foldl' f w pus
|
|
||||||
where
|
|
||||||
f w' pu = updateProp (pr & prUpdate .~ pu) w'
|
|
||||||
@@ -38,7 +38,6 @@ import Dodge.Machine.Update
|
|||||||
import Dodge.ModificationEffect
|
import Dodge.ModificationEffect
|
||||||
import Dodge.Projectile.Update
|
import Dodge.Projectile.Update
|
||||||
import Dodge.Prop.Moving
|
import Dodge.Prop.Moving
|
||||||
import Dodge.Prop.Update
|
|
||||||
import Dodge.RadarBlip
|
import Dodge.RadarBlip
|
||||||
import Dodge.RadarSweep
|
import Dodge.RadarSweep
|
||||||
import Dodge.ScreenPos
|
import Dodge.ScreenPos
|
||||||
@@ -275,13 +274,11 @@ functionalUpdate =
|
|||||||
. over
|
. over
|
||||||
uvWorld
|
uvWorld
|
||||||
(updateIMl' (_linearShockwaves . _lWorld . _cWorld) updateLinearShockwave)
|
(updateIMl' (_linearShockwaves . _lWorld . _cWorld) updateLinearShockwave)
|
||||||
. over uvWorld (updateIMl' (_props . _lWorld . _cWorld) updateProp)
|
|
||||||
. over uvWorld (updateIMl' (_projectiles . _lWorld . _cWorld) updateProjectile)
|
. over uvWorld (updateIMl' (_projectiles . _lWorld . _cWorld) updateProjectile)
|
||||||
. over uvWorld updateClouds
|
. over uvWorld updateClouds
|
||||||
. over uvWorld updateDusts
|
. over uvWorld updateDusts
|
||||||
. over uvWorld updateGusts
|
. over uvWorld updateGusts
|
||||||
. over uvWorld (updateIMl' (_terminals . _lWorld . _cWorld) tmUpdate)
|
. over uvWorld (updateIMl' (_terminals . _lWorld . _cWorld) tmUpdate)
|
||||||
-- . updateIMl _machines mcChooseUpdate
|
|
||||||
. over uvWorld (updateIMl' (_machines . _lWorld . _cWorld) updateMachine)
|
. over uvWorld (updateIMl' (_machines . _lWorld . _cWorld) updateMachine)
|
||||||
. over uvWorld (updateIMl' (_creatures . _lWorld . _cWorld) updateCreature)
|
. over uvWorld (updateIMl' (_creatures . _lWorld . _cWorld) updateCreature)
|
||||||
-- creatures should be updated early so that crOldPos is set before any position change
|
-- creatures should be updated early so that crOldPos is set before any position change
|
||||||
|
|||||||
Reference in New Issue
Block a user