Add Read/Show instance for Creature

This commit is contained in:
2022-07-22 10:44:54 +01:00
parent 4c5218c633
commit 6b69fc1684
35 changed files with 345 additions and 225 deletions
+7
View File
@@ -0,0 +1,7 @@
module Dodge.Corpse.Draw where
import Dodge.Data.Corpse
import ShapePicture
-- not currently used, too simple
drawCorpse :: Corpse -> SPic
drawCorpse cp = _cpSPic cp
+36
View File
@@ -0,0 +1,36 @@
module Dodge.Corpse.Make where
import Dodge.Creature.Picture
import Dodge.Data.Creature
import Dodge.Data.Corpse
import Control.Lens
import ShapePicture
import Shape
import Geometry
makeCorpse :: CreatureCorpse -> Creature -> Corpse
makeCorpse cc = case cc of
MakeDefaultCorpse -> makeDefaultCorpse
makeDefaultCorpse :: Creature -> Corpse
makeDefaultCorpse cr = defaultCorpse
& cpPos .~ _crPos cr
& cpDir .~ _crDir cr
& cpSPic .~ noPic (scaleSH (V3 crsize crsize crsize) $ mconcat
[ colorSH (_skinHead cskin) $ deadScalp cr
, colorSH (_skinUpper cskin) $ deadUpperBody cr
, rotmdir $ colorSH (_skinLower cskin) $ deadFeet cr
]
)
where
cskin = _crType cr -- this should be fixed
crsize = 0.1 * _crRad cr
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
defaultCorpse :: Corpse
defaultCorpse = Corpse
{ _cpID = 0
, _cpPos = 0
, _cpDir = 0
, _cpSPic = mempty
, _cpRes = NoResurrection
}