Start to clean up Prop datatype

This commit is contained in:
2025-10-22 12:07:06 +01:00
parent af245fb5bf
commit d5f985f3ab
6 changed files with 127 additions and 157 deletions
+27 -39
View File
@@ -10,60 +10,46 @@ import Data.Aeson.TH
import Dodge.Data.WorldEffect
import Geometry.Data
import qualified Quaternion as Q
import Shape.Data
import ShapePicture.Data
data Prop
= PropZ
{ _prPos :: Point2
, _prDraw :: PropDraw
, _prUpdate :: PropUpdate
, _prStartPos :: Point2
, _prVel :: Point2
, _prID :: Int
, _prPosZ :: Float
, _prVelZ :: Float
, _prQuat :: Q.Quaternion Float
, _prQuatSpin :: Q.Quaternion Float
, _prColor :: Color
}
| ShapeProp
{ _prPos :: Point2
, _prDraw :: PropDraw
, _prUpdate :: PropUpdate
, _prID :: Int
, _prRot :: Float
, _prToggle :: Bool
}
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Prop = ShapeProp
{ _prPos :: Point2
, _prDraw :: PropDraw
, _prUpdate :: PropUpdate
, _prID :: Int
, _prRot :: Float
, _prToggle :: Bool
}
data DebrisType =
Gib {_gibSize :: Float
,_gibColor :: Color
data DebrisType
= Gib
{ _gibSize :: Float
, _gibColor :: Color
}
| BlockDebris {_bdColor :: Color}
data Debris = DebrisChunk
{ _dbPos :: Point3
, _dbType :: DebrisType
, _dbVel :: Point3
, _dbRot :: Q.Quaternion Float
, _dbSpin :: Q.Quaternion Float
}
{ _dbPos :: Point3
, _dbType :: DebrisType
, _dbVel :: Point3
, _dbRot :: Q.Quaternion Float
, _dbSpin :: Q.Quaternion Float
}
--data PropType = FallingBlock Material
data PropDraw
= PropDrawSPic SPic
| PropDrawMovingShapeCol Shape
| PropDrawMovingShape PropDraw
| PropDrawFlatTranslate PropDraw
| -- | PropDrawMovingShapeCol Shape
-- | PropDrawMovingShape PropDraw
PropDrawFlatTranslate PropDraw
| PropDoubleLampCover Float
| PropVerticalLampCover Float
| PropLampCover Float
| PropDrawToggle PropDraw
-- | PropDrawGib Float
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
data PropUpdate
= PropUpdateId
@@ -75,13 +61,15 @@ data PropUpdate
| PropUpdatePosition WdP2f
| PropUpdateWhen WdBl PropUpdate
| PropUpdateIf WdBl PropUpdate PropUpdate
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
data PrWdLsLs
= PrWdLsId
| PrWdLsSetPosition WdP2f Point3
| PrWdLsSetColor Point3
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''Prop
makeLenses ''Debris
@@ -42,7 +42,6 @@ propLSThen propf lsf ls prop cont = pt0 (PutLS ls) $
moveLSThen ::
WdP2f -> --(World -> (Point2,Float))
-- | light source offset
Point3 ->
Shape ->
+14 -14
View File
@@ -26,8 +26,8 @@ debrisSPic db = translateSP (_dbPos db) . overPosSP (Q.rotate (_dbRot db)) $
drawProp :: PropDraw -> Prop -> SPic
drawProp = \case
PropDrawSPic spic -> const spic
PropDrawMovingShape pd' -> \pr -> drawMovingShape pr (drawProp pd' pr)
PropDrawMovingShapeCol sh -> (`drawMovingShapeCol` sh)
-- PropDrawMovingShape pd' -> \pr -> drawMovingShape pr (drawProp pd' pr)
-- PropDrawMovingShapeCol sh -> (`drawMovingShapeCol` sh)
PropDoubleLampCover h -> drawDoubleLampCover h
PropVerticalLampCover h -> drawVerticalLampCover h
PropLampCover h -> drawLampCover h
@@ -78,19 +78,19 @@ drawVerticalLampCover h pr =
$ rectNSWE 2 (-2) (-5) 5
)
drawMovingShape :: Prop -> SPic -> SPic
drawMovingShape pr =
translateSPz (_prPosZ pr)
. uncurryV translateSPxy (_prPos pr)
. overPosSP (Q.rotate (_prQuat pr))
--drawMovingShape :: Prop -> SPic -> SPic
--drawMovingShape pr =
-- translateSPz (_prPosZ pr)
-- . uncurryV translateSPxy (_prPos pr)
-- . overPosSP (Q.rotate (_prQuat pr))
drawMovingShapeCol :: Prop -> Shape -> SPic
drawMovingShapeCol pr =
noPic
. translateSHz (_prPosZ pr)
. uncurryV translateSHxy (_prPos pr)
. overPosSH (Q.rotate (_prQuat pr))
. colorSH (_prColor pr)
--drawMovingShapeCol :: Prop -> Shape -> SPic
--drawMovingShapeCol pr =
-- noPic
-- . translateSHz (_prPosZ pr)
-- . uncurryV translateSHxy (_prPos pr)
-- . overPosSH (Q.rotate (_prQuat pr))
-- . colorSH (_prColor pr)
drawDoubleLampCover :: Float -> Prop -> SPic
drawDoubleLampCover h pr =
-3
View File
@@ -153,9 +153,6 @@ airlockSimple =
y2 = (0, pi / 2)
x2 = (0, pi)
-- outDoorps = (V2 0 0,) <$> arcStepwise 3 (negate $ pi / 2) (V2 0 0) (V2 0 55)
-- inDoorps = (V2 0 0,) <$> arcStepwise 3 (negate $ pi / 2) (V2 0 0) (V2 (-55) 0)
airlockZ :: RandomGen g => State g Room
airlockZ = do
let cenlight = mntLS vShape (V2 90 60) (V3 90 40 50) `addPlmnt` mntLS vShape (V2 90 60) (V3 90 80 50)
-1
View File
@@ -137,7 +137,6 @@ addButtonSlowDoor x h rm = do
putDoubleDoorThen
DoorObstacle
thewall
-- (WdBlBtNotOff $ fromJust $ _plMID btplmnt)
(WdBlBtOn $ fromJust $ _plMID btplmnt)
30
(V2 0 h)