Add newtype to floor item ids

This commit is contained in:
2024-09-23 22:42:09 +01:00
parent 43b365185d
commit 265da89791
20 changed files with 193 additions and 158 deletions
+3 -1
View File
@@ -5,13 +5,15 @@
module Dodge.Data.FloorItem where
import NewInt
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
import Dodge.Data.Item
import Geometry.Data
data FloorItem = FlIt {_flIt :: Item, _flItPos :: Point2, _flItRot :: Float, _flItID :: Int}
data FloorItem = FlIt {_flIt :: Item, _flItPos :: Point2, _flItRot :: Float, _flItID :: NewInt FloorInt}
--deriving (Eq, Show, Read) --Generic, Flat)
makeLenses ''FloorItem
+4
View File
@@ -30,6 +30,9 @@ import Dodge.Data.Item.Use
import Dodge.Data.Item.Location
import Data.Set (Set)
data ItID = ItID
deriving (Eq,Ord,Show,Read)
data Item = Item
{ _itUse :: ItemUse
, _itType :: ItemType
@@ -57,5 +60,6 @@ _itUseAimStance :: Item -> AimStance
_itUseAimStance = _aimStance . _heldAim . _itUse
makeLenses ''Item
deriveJSON defaultOptions ''ItID
deriveJSON defaultOptions ''ItemAttachment
deriveJSON defaultOptions ''Item
+17 -1
View File
@@ -2,18 +2,34 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE EmptyDataDeriving #-}
module Dodge.Data.Item.Location where
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
import NewInt
-- it would be nice to have these as empty types, but I'm not sure how to get
-- aeson to handle that
data FloorInt = FloorInt
deriving (Eq,Ord,Show,Read)
-- should use these..
data InvInt = InvInt
deriving (Eq,Ord,Show,Read)
data TurretInt
deriving (Eq,Ord,Show,Read)
data CrInt = CrInt
deriving (Eq,Ord,Show,Read)
data ItemLocation
= InInv {_ilCrID :: Int, _ilInvID :: Int, _ilIsRoot :: Bool, _ilIsSelected :: Bool}
| OnTurret {_ilTuID :: Int}
| OnFloor {_ilFlID :: Int}
| OnFloor {_ilFlID :: NewInt FloorInt}
| InVoid
deriving (Eq, Show, Ord, Read) --Generic, Flat)
makeLenses ''ItemLocation
deriveJSON defaultOptions ''InvInt
deriveJSON defaultOptions ''FloorInt
deriveJSON defaultOptions ''ItemLocation
+2 -1
View File
@@ -47,6 +47,7 @@ module Dodge.Data.LWorld (
module Dodge.Data.WorldEffect,
) where
import NewInt
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
@@ -128,7 +129,7 @@ data LWorld = LWorld
, _blocks :: IM.IntMap Block
, _coordinates :: IM.IntMap Point2
, _triggers :: IM.IntMap Bool
, _floorItems :: IM.IntMap FloorItem
, _floorItems :: NewIntMap FloorInt FloorItem
, _modifications :: IM.IntMap Modification
, _worldEvents :: [WdWd]
, _delayedEvents :: [(Int, WdWd)]