Add Store instances

This commit is contained in:
2022-08-21 12:21:05 +01:00
parent 1ce7d4a72d
commit dd62e30026
92 changed files with 465 additions and 255 deletions
+13 -11
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.Combine where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -20,11 +22,9 @@ data ItemType = ItemType
, _iyStack :: Stack
}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ItemType
data Stack = NoStack | Stack ItAmount
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary Stack
data CraftType
= PIPE
@@ -74,7 +74,6 @@ data CraftType
| SIZEMODULE
| GRAVITYMODULE
deriving (Eq, Ord, Show, Enum, Read, Generic, Flat)
instance Binary CraftType
data ItemBaseType
= NoItemType
@@ -84,13 +83,11 @@ data ItemBaseType
| Consumable {_ibtConsumable :: ConsumableItemType}
| CRAFT CraftType
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ItemBaseType
data ConsumableItemType
= MEDKIT Int
| EXPLOSIVES
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ConsumableItemType
data EquipItemType
= MAGSHIELD
@@ -107,7 +104,6 @@ data EquipItemType
| JETPACK
| AUTODETECTOR Detector
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary EquipItemType
data LeftItemType
= BOOSTER
@@ -117,7 +113,6 @@ data LeftItemType
| SHRINKER
| SPAWNER
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary LeftItemType
data HeldItemType
= BANGSTICK {_xNum :: Int}
@@ -166,7 +161,6 @@ data HeldItemType
| FLATSHIELD
| KEYCARD Int
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary HeldItemType
data ItemModuleType
= EMPTYMODULE
@@ -192,14 +186,12 @@ data ItemModuleType
| EXTRABATTERY
| ATTACHTORCH
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ItemModuleType
data Detector
= ITEMDETECTOR
| CREATUREDETECTOR
| WALLDETECTOR
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary Detector
data ModuleSlot
= ModBullet
@@ -214,7 +206,6 @@ data ModuleSlot
| ModDualBeam
| ModHeldAttach
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ModuleSlot
instance ToJSONKey ModuleSlot
@@ -234,3 +225,14 @@ deriveJSON defaultOptions ''ModuleSlot
makeLenses ''ItemType
makeLenses ''ItemBaseType
makeLenses ''HeldItemType
$($(derive [d| instance Deriving (Store ItemType ) |]))
$($(derive [d| instance Deriving (Store Stack ) |]))
$($(derive [d| instance Deriving (Store CraftType) |]))
$($(derive [d| instance Deriving (Store ItemBaseType) |]))
$($(derive [d| instance Deriving (Store ConsumableItemType) |]))
$($(derive [d| instance Deriving (Store EquipItemType) |]))
$($(derive [d| instance Deriving (Store LeftItemType) |]))
$($(derive [d| instance Deriving (Store HeldItemType) |]))
$($(derive [d| instance Deriving (Store ItemModuleType) |]))
$($(derive [d| instance Deriving (Store Detector) |]))
$($(derive [d| instance Deriving (Store ModuleSlot) |]))
+3 -1
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.CurseStatus where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Data.Aeson
@@ -15,6 +17,6 @@ data CurseStatus
| UndroppableIdentified
| UndroppableUnidentified
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary CurseStatus
$($(derive [d| instance Deriving (Store CurseStatus) |]))
deriveJSON defaultOptions ''CurseStatus
+8 -4
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.Effect where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -19,7 +21,6 @@ data ItEffect = ItEffect
, _ieOnStash :: ItInvEffect
}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ItEffect
data ItInvEffect
= NoInvEffect
@@ -30,18 +31,21 @@ data ItInvEffect
| RemoveShieldWall
| EffectWhileHeld ItInvEffect
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ItInvEffect
$($(derive [d| instance Deriving (Store ItInvEffect) |]))
data ItFloorEffect = NoFloorEffect
| HackItFloorEffect
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ItFloorEffect
data ItDropEffect = NoDropEffect
| HackItDropEffect
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ItDropEffect
makeLenses ''ItEffect
deriveJSON defaultOptions ''ItEffect
deriveJSON defaultOptions ''ItInvEffect
deriveJSON defaultOptions ''ItFloorEffect
deriveJSON defaultOptions ''ItDropEffect
$($(derive [d| instance Deriving (Store ItEffect ) |]))
$($(derive [d| instance Deriving (Store ItDropEffect ) |]))
$($(derive [d| instance Deriving (Store ItFloorEffect ) |]))
+3 -1
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.HeldDelay where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -28,7 +30,7 @@ data UseDelay -- should just be Delay
, _warmMax :: Int
}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary UseDelay
$($(derive [d| instance Deriving (Store UseDelay ) |]))
makeLenses ''UseDelay
deriveJSON defaultOptions ''UseDelay
+3 -1
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.HeldScroll where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -22,7 +24,7 @@ data HeldScroll
, _hsMaxInt :: Int
}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary HeldScroll
$($(derive [d| instance Deriving (Store HeldScroll) |]))
makeLenses ''HeldScroll
deriveJSON defaultOptions ''HeldScroll
+7 -5
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.HeldUse where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Data.Aeson
@@ -29,13 +31,13 @@ data HeldUse
| HeldForceField
| HeldShatter
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary HeldUse
$($(derive [d| instance Deriving (Store HeldUse) |]))
data Cuse
= CDoNothing
| CHeal Int
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary Cuse
$($(derive [d| instance Deriving (Store Cuse) |]))
data Euse
= EDoNothing
@@ -47,7 +49,7 @@ data Euse
| EonWristShield
| EoffWristShield
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary Euse
$($(derive [d| instance Deriving (Store Euse) |]))
data Luse
= LDoNothing
@@ -57,7 +59,7 @@ data Luse
| LUnsafeBlink
| LBoost
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary Luse
$($(derive [d| instance Deriving (Store Luse) |]))
data HeldMod
= HeldModNothing
@@ -96,7 +98,7 @@ data HeldMod
| RevolverXRepeatMod
| BangConeMod
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary HeldMod
$($(derive [d| instance Deriving (Store HeldMod) |]))
deriveJSON defaultOptions ''Cuse
deriveJSON defaultOptions ''HeldMod
+3 -1
View File
@@ -4,6 +4,8 @@
{-# LANGUAGE TemplateHaskell #-}
module Dodge.Data.Item.Location where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -16,7 +18,7 @@ data ItemLocation
| OnFloor {_ipFlID :: Int}
| InVoid
deriving (Eq, Show, Read, Ord, Generic, Flat)
instance Binary ItemLocation
$($(derive [d| instance Deriving (Store ItemLocation) |]))
makeLenses ''ItemLocation
deriveJSON defaultOptions ''ItemLocation
+6 -4
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.Misc where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -19,7 +21,7 @@ data ItemDimension = ItemDimension
, _dimAttachPos :: Point3
}
deriving (Eq, Show, Read, Generic, Flat)
instance Binary ItemDimension
$($(derive [d| instance Deriving (Store ItemDimension ) |]))
data ItemPortage
= HeldItem
@@ -29,18 +31,18 @@ data ItemPortage
| WornItem
| NoPortage
deriving (Eq, Show, Read, Generic, Flat)
instance Binary ItemPortage
$($(derive [d| instance Deriving (Store ItemPortage) |]))
--data ItemValue = ItemValue
-- { _ivInt :: Int
-- , _ivType :: ItemValueType
-- }
-- deriving (Eq, Show, Read, Generic, Flat)
-- instance Binary ItemValue
-- $($(derive [d| instance Deriving (Store ItemValue ) |]))
--
--data ItemValueType = MundaneItem | ArtefactItem
-- deriving (Eq, Show, Read, Generic, Flat)
-- instance Binary ItemValueType
-- $($(derive [d| instance Deriving (Store ItemValueType ) |]))
makeLenses ''ItemDimension
makeLenses ''ItemPortage
+8 -6
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.Params where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Color
@@ -71,15 +73,12 @@ data ItemParams
| ParamMID {_paramMID :: Maybe Int}
| BoostPropIX {_boostPropIX :: Maybe Int}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ItemParams
data ShrinkGunStatus = FullSize | Shrunk
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ShrinkGunStatus
data PreviousArcEffect = NoPreviousArcEffect | PerturbTillBreakPreviousArc
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary PreviousArcEffect
data GunBarrels
= MultiBarrel
@@ -93,7 +92,6 @@ data GunBarrels
}
| SingleBarrel {_brlInaccuracy :: Float}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary GunBarrels
data Nozzle = Nozzle
{ _nzPressure :: Float
@@ -104,14 +102,12 @@ data Nozzle = Nozzle
, _nzLength :: Float
}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary Nozzle
data BarrelSpread
= AlignedBarrels
| SpreadBarrels {_spreadAngle :: Float}
| RotatingBarrels {_rotatingBarrelInaccuracy :: Float}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary BarrelSpread
makeLenses ''BarrelSpread
makeLenses ''ItemParams
@@ -123,3 +119,9 @@ deriveJSON defaultOptions ''PreviousArcEffect
deriveJSON defaultOptions ''GunBarrels
deriveJSON defaultOptions ''Nozzle
deriveJSON defaultOptions ''BarrelSpread
$($(derive [d| instance Deriving (Store PreviousArcEffect ) |]))
$($(derive [d| instance Deriving (Store GunBarrels) |]))
$($(derive [d| instance Deriving (Store Nozzle ) |]))
$($(derive [d| instance Deriving (Store BarrelSpread) |]))
$($(derive [d| instance Deriving (Store ItemParams) |]))
$($(derive [d| instance Deriving (Store ShrinkGunStatus ) |]))
+3 -1
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.Scope where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -32,7 +34,7 @@ data Scope
_scopeIsCamera :: Bool
}
deriving (Eq, Show, Read, Generic, Flat)
instance Binary Scope
$($(derive [d| instance Deriving (Store Scope) |]))
makeLenses ''Scope
deriveJSON defaultOptions ''Scope
+5 -3
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.Targeting where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -23,7 +25,6 @@ data Targeting
, _tgActive :: Bool
}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary Targeting
data TargetUpdate
= NoTargetUpdate
@@ -32,7 +33,6 @@ data TargetUpdate
| TargetRBCreatureUpdate
| TargetCursorUpdate
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary TargetUpdate
data TargetDraw
= NoTargetDraw
@@ -40,9 +40,11 @@ data TargetDraw
| SimpleDrawTarget
| TargetRBCreatureDraw
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary TargetDraw
makeLenses ''Targeting
deriveJSON defaultOptions ''Targeting
deriveJSON defaultOptions ''TargetUpdate
deriveJSON defaultOptions ''TargetDraw
$($(derive [d| instance Deriving (Store Targeting) |]))
$($(derive [d| instance Deriving (Store TargetDraw) |]))
$($(derive [d| instance Deriving (Store TargetUpdate) |]))
+5 -3
View File
@@ -5,6 +5,8 @@
module Dodge.Data.Item.Tweak where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -18,7 +20,6 @@ data ItemTweaks
{ _tweakParams :: IM.IntMap TweakParam
}
deriving (Eq, Show, Read, Generic, Flat)
instance Binary ItemTweaks
data TweakType
= TweakPhaseV
@@ -27,7 +28,6 @@ data TweakType
| TweakSpinAmount
| TweakThrustDelay
deriving (Eq, Show, Read, Generic, Flat)
instance Binary TweakType
data TweakParam = TweakParam
{ _tweakType :: TweakType -- Int -> Item -> Item
@@ -35,10 +35,12 @@ data TweakParam = TweakParam
, _tweakMax :: Int
}
deriving (Eq, Show, Read, Generic, Flat)
instance Binary TweakParam
$($(derive [d| instance Deriving (Store TweakParam ) |]))
makeLenses ''TweakParam
makeLenses ''ItemTweaks
deriveJSON defaultOptions ''ItemTweaks
deriveJSON defaultOptions ''TweakType
deriveJSON defaultOptions ''TweakParam
$($(derive [d| instance Deriving (Store ItemTweaks) |]))
$($(derive [d| instance Deriving (Store TweakType) |]))
+6 -4
View File
@@ -13,6 +13,8 @@ module Dodge.Data.Item.Use (
module Dodge.Data.Hammer,
) where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -52,7 +54,6 @@ data ItemUse
| CraftUse
{_useAmount :: ItAmount}
deriving (Eq, Show, Read, Generic, Flat)
instance Binary ItemUse
data AimParams = AimParams
{ _aimWeight :: Int
@@ -63,7 +64,6 @@ data AimParams = AimParams
, _aimMuzPos :: Float
}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary AimParams
data AimStance
= TwoHandTwist
@@ -71,7 +71,6 @@ data AimStance
| OneHand
| LeaveHolstered
deriving (Eq, Show, Ord, Enum, Read, Generic, Flat)
instance Binary AimStance
data ItZoom = ItZoom
{ _itZoomMax :: Float
@@ -79,7 +78,6 @@ data ItZoom = ItZoom
, _itZoomFac :: Float
}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ItZoom
makeLenses ''ItemUse
makeLenses ''AimParams
@@ -88,3 +86,7 @@ deriveJSON defaultOptions ''ItemUse
deriveJSON defaultOptions ''AimParams
deriveJSON defaultOptions ''AimStance
deriveJSON defaultOptions ''ItZoom
$($(derive [d| instance Deriving (Store AimParams ) |]))
$($(derive [d| instance Deriving (Store AimStance) |]))
$($(derive [d| instance Deriving (Store ItZoom ) |]))
$($(derive [d| instance Deriving (Store ItemUse) |]))
+5 -3
View File
@@ -11,6 +11,8 @@ module Dodge.Data.Item.Use.Consumption (
module Dodge.Data.Item.Use.Consumption.LoadAction,
) where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -30,7 +32,7 @@ data HeldConsumption
}
| NoConsumption
deriving (Eq, Show, Read, Generic, Flat)
instance Binary HeldConsumption
$($(derive [d| instance Deriving (Store HeldConsumption) |]))
data LeftConsumption
= AutoRecharging
@@ -44,14 +46,14 @@ data LeftConsumption
, _wpCharge :: Int
}
deriving (Eq, Show, Read, Generic, Flat)
instance Binary LeftConsumption
$($(derive [d| instance Deriving (Store LeftConsumption) |]))
newtype ItAmount = ItAmount {_getItAmount :: Int}
-- deriving (Eq, Ord, Read, Show, Num, Real, Generic, Flat)
deriving newtype (Eq, Ord, Read, Show, Num, Real, Enum, Integral)
deriving stock (Generic)
deriving anyclass (Flat)
instance Binary ItAmount
$($(derive [d| instance Deriving (Store ItAmount) |]))
makeLenses ''HeldConsumption
makeLenses ''LeftConsumption
+9 -6
View File
@@ -9,6 +9,8 @@ module Dodge.Data.Item.Use.Consumption.Ammo (
module Dodge.Data.Payload,
) where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -19,11 +21,9 @@ import Dodge.Data.Payload
data ProjectileDraw = DrawShell | DrawRemoteShell | DrawDrone | DrawBlankProjectile
deriving (Show, Read, Eq, Ord, Enum, Bounded, Generic, Flat)
instance Binary ProjectileDraw
data ProjectileCreate = CreateShell | CreateTrackingShell
deriving (Show, Read, Eq, Ord, Enum, Bounded, Generic, Flat)
instance Binary ProjectileCreate
data ProjectileUpdate
= PJThrust {_pjuStart :: Int, _pjuEnd :: Int}
@@ -37,7 +37,6 @@ data ProjectileUpdate
| PJShellCollisionCheck
| PJRemoteShellCollisionCheck
deriving (Show, Read, Eq, Ord, Generic, Flat)
instance Binary ProjectileUpdate
data AmmoType
= ProjectileAmmo
@@ -61,15 +60,13 @@ data AmmoType
}
| GenericAmmo
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary AmmoType
data ForceFieldType = DefaultForceField
| HackForceFieldType
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary ForceFieldType
data GasCreate = CreatePoisonGas | CreateFlame
deriving (Eq, Ord, Show, Enum, Bounded, Read, Generic, Flat)
instance Binary GasCreate
makeLenses ''ProjectileUpdate
makeLenses ''AmmoType
@@ -79,3 +76,9 @@ deriveJSON defaultOptions ''ProjectileUpdate
deriveJSON defaultOptions ''AmmoType
deriveJSON defaultOptions ''GasCreate
deriveJSON defaultOptions ''ForceFieldType
$($(derive [d| instance Deriving (Store AmmoType) |]))
$($(derive [d| instance Deriving (Store ProjectileDraw ) |]))
$($(derive [d| instance Deriving (Store ProjectileCreate ) |]))
$($(derive [d| instance Deriving (Store ProjectileUpdate) |]))
$($(derive [d| instance Deriving (Store ForceFieldType ) |]))
$($(derive [d| instance Deriving (Store GasCreate ) |]))
@@ -5,6 +5,8 @@
module Dodge.Data.Item.Use.Consumption.LoadAction where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -19,17 +21,14 @@ data LoadAction
| LoadAdd {_actionTime :: Int, _actionSound :: SoundID, _insertMax :: Int}
| LoadPrime {_actionTime :: Int, _actionSound :: SoundID}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary LoadAction
data InvSel = InvSel {_iselPos :: Int, _iselAction :: InvSelAction}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary InvSel
data InvSelAction
= NoInvSelAction
| ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction, _actionHammer :: HammerType}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary InvSelAction
makeLenses ''LoadAction
makeLenses ''InvSel
@@ -37,3 +36,6 @@ makeLenses ''InvSelAction
deriveJSON defaultOptions ''LoadAction
deriveJSON defaultOptions ''InvSel
deriveJSON defaultOptions ''InvSelAction
$($(derive [d| instance Deriving (Store LoadAction) |]))
$($(derive [d| instance Deriving (Store InvSelAction) |]))
$($(derive [d| instance Deriving (Store InvSel ) |]))
+4 -2
View File
@@ -8,6 +8,8 @@ module Dodge.Data.Item.Use.Equipment (
module Dodge.Data.Item.Use.Equipment,
) where
import TH.Derive
import Data.Store
import Data.Binary
import Flat
import Control.Lens
@@ -25,16 +27,16 @@ data EquipEffect = EquipEffect
, _eeViewDist :: Maybe Float
}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary EquipEffect
data EquipParams
= NoEquipParams
| EquipID {_eparamID :: Int}
| EquipCounter {_eparamInt :: Int}
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance Binary EquipParams
makeLenses ''EquipEffect
makeLenses ''EquipParams
deriveJSON defaultOptions ''EquipEffect
deriveJSON defaultOptions ''EquipParams
$($(derive [d| instance Deriving (Store EquipEffect ) |]))
$($(derive [d| instance Deriving (Store EquipParams) |]))