Refactor items, suspect a leak
This commit is contained in:
+2
-104
@@ -10,6 +10,7 @@ circular imports are probably not a good idea.
|
||||
{-# LANGUAGE DerivingStrategies #-}
|
||||
module Dodge.Data
|
||||
( module Dodge.Data
|
||||
, module Dodge.Data.Item.Params
|
||||
, module Dodge.Data.Beam
|
||||
, module Dodge.Data.Targeting
|
||||
, module Dodge.Data.ItEffect
|
||||
@@ -67,6 +68,7 @@ module Dodge.Data
|
||||
, module Dodge.Data.RadarBlip
|
||||
, module Dodge.Data.PathGraph
|
||||
) where
|
||||
import Dodge.Data.Item.Params
|
||||
import Dodge.Data.Beam
|
||||
import Dodge.Data.Targeting
|
||||
import Dodge.Data.ItEffect
|
||||
@@ -417,25 +419,6 @@ data PressPlate = PressPlate
|
||||
}
|
||||
data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int}
|
||||
|
||||
data Item = Item
|
||||
{ _itConsumption :: ItemConsumption
|
||||
, _itUse :: ItemUse
|
||||
, _itType :: ItemType
|
||||
, _itAttachment :: ItAttachment
|
||||
, _itID :: Maybe Int
|
||||
, _itPos :: ItemPos
|
||||
, _itIsHeld :: Bool
|
||||
, _itEffect :: ItEffect
|
||||
, _itInvSize :: Float
|
||||
, _itInvColor :: Color
|
||||
, _itTargeting :: Targeting
|
||||
, _itDimension :: ItemDimension
|
||||
, _itCurseStatus :: CurseStatus
|
||||
, _itTweaks :: ItemTweaks
|
||||
, _itScope :: Scope
|
||||
, _itValue :: ItemValue
|
||||
, _itParams :: ItemParams
|
||||
}
|
||||
|
||||
data IntID a = IntID Int a
|
||||
|
||||
@@ -504,87 +487,6 @@ type HitEffect' = Flame
|
||||
-> World
|
||||
-> (World,Maybe Flame)
|
||||
|
||||
data ItemTweaks
|
||||
= NoTweaks
|
||||
| Tweakable
|
||||
{ _tweakParams :: IM.IntMap TweakParam
|
||||
, _tweakSel :: Int
|
||||
}
|
||||
data TweakParam = TweakParam
|
||||
{ _doTweak :: Int -> Item -> Item
|
||||
, _curTweak :: Int
|
||||
, _maxTweak :: Int
|
||||
, _showTweak :: Int -> String
|
||||
, _nameTweak :: String
|
||||
}
|
||||
data Nozzle = Nozzle
|
||||
{ _nzPressure :: Float
|
||||
, _nzDir :: Float
|
||||
, _nzMaxWalkAngle :: Float
|
||||
, _nzCurrentWalkAngle :: Float
|
||||
, _nzWalkSpeed :: Float
|
||||
, _nzLength :: Float
|
||||
}
|
||||
data GunBarrels
|
||||
= MultiBarrel
|
||||
{ _brlSpread :: BarrelSpread
|
||||
, _brlNum :: Int
|
||||
, _brlInaccuracy :: Float
|
||||
}
|
||||
| RotBarrel
|
||||
{ _brlNum :: Int
|
||||
, _brlInaccuracy :: Float
|
||||
}
|
||||
| SingleBarrel {_brlInaccuracy :: Float}
|
||||
data ItemParams
|
||||
= NoParams
|
||||
| ShellLauncher
|
||||
{ _shellSpinDrag :: Int
|
||||
, _shellSpinAmount :: Int
|
||||
, _shellThrustDelay :: Int
|
||||
}
|
||||
| Refracting
|
||||
{ _phaseV :: Float
|
||||
, _lasColor :: Color
|
||||
, _lasColor2 :: Color
|
||||
, _lasCycle :: Int
|
||||
, _lasDamage :: Int
|
||||
}
|
||||
| DualBeam
|
||||
{ _phaseV :: Float
|
||||
, _lasColor :: Color
|
||||
, _lasColor2 :: Color
|
||||
, _lasCycle :: Int
|
||||
, _lasDamage :: Int
|
||||
, _lasBeam :: BeamType
|
||||
, _subParams :: Maybe ItemParams
|
||||
, _dbGap :: Float
|
||||
}
|
||||
| Attracting {_attractionPower :: Point2}
|
||||
| BulletShooter
|
||||
{ _muzVel :: Float
|
||||
, _rifling :: Float
|
||||
, _bore :: Float
|
||||
, _gunBarrels :: GunBarrels
|
||||
, _recoil :: Float
|
||||
, _torqueAfter :: Float
|
||||
, _randomOffset :: Float
|
||||
}
|
||||
| Sprayer { _sprayNozzles :: [Nozzle] }
|
||||
| AngleWalk
|
||||
{ _maxWalkAngle :: Float
|
||||
, _currentWalkAngle :: Float
|
||||
, _walkSpeed :: Float
|
||||
}
|
||||
| Arcing
|
||||
{ _currentArc :: Maybe [ArcStep]
|
||||
, _arcSize :: Float
|
||||
, _arcNumber :: Int
|
||||
, _newArcStep :: NextArcStep --ItemParams -> World -> ArcStep -> State StdGen (Maybe ArcStep)
|
||||
, _previousArcEffect :: PreviousArcEffect
|
||||
}
|
||||
| ParamMID {_paramMID :: Maybe Int}
|
||||
data PreviousArcEffect = NoPreviousArcEffect | PerturbTillBreakPreviousArc
|
||||
data Modification
|
||||
= ModIDTimerPoint3Bool
|
||||
{ _mdID :: Int
|
||||
@@ -1175,9 +1077,7 @@ data InPlacement = InPlacement
|
||||
makeLenses ''CreatureState
|
||||
makeLenses ''World
|
||||
makeLenses ''Creature
|
||||
makeLenses ''Item
|
||||
makeLenses ''FloorItem
|
||||
makeLenses ''TweakParam
|
||||
makeLenses ''Prop
|
||||
makeLenses ''Proj
|
||||
makeLenses ''Modification
|
||||
@@ -1194,8 +1094,6 @@ makeLenses ''Terminal
|
||||
makeLenses ''Machine
|
||||
makeLenses ''MachineType
|
||||
makeLenses ''Universe
|
||||
makeLenses ''ItemParams
|
||||
makeLenses ''ItemTweaks
|
||||
makeLenses ''Gust
|
||||
makeLenses ''GunBarrels
|
||||
makeLenses ''Nozzle
|
||||
|
||||
+48
-25
@@ -1,32 +1,55 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Item where
|
||||
module Dodge.Data.Item
|
||||
( module Dodge.Data.Item
|
||||
, module Dodge.Data.Item.Misc
|
||||
) where
|
||||
import Geometry.Data
|
||||
import Control.Lens
|
||||
import Dodge.Data.Item.Misc
|
||||
import Dodge.Data.Item.Consumption
|
||||
import Dodge.Data.Item.Use
|
||||
import Dodge.Data.Item.Params
|
||||
import Dodge.Data.ItEffect
|
||||
import Dodge.Data.Targeting
|
||||
import Dodge.Item.Data
|
||||
import Dodge.Combine.Data
|
||||
import Dodge.Item.Attachment.Data
|
||||
import Color
|
||||
|
||||
data ItemDimension = ItemDimension
|
||||
{ _dimRad :: Float
|
||||
, _dimCenter :: Point3
|
||||
, _dimAttachPos :: Point3
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
data Item = Item
|
||||
{ _itConsumption :: ItemConsumption
|
||||
, _itUse :: ItemUse
|
||||
, _itType :: ItemType
|
||||
, _itAttachment :: ItAttachment
|
||||
, _itID :: Maybe Int
|
||||
, _itPos :: ItemPos
|
||||
, _itIsHeld :: Bool
|
||||
, _itEffect :: ItEffect
|
||||
, _itInvSize :: Float
|
||||
, _itInvColor :: Color
|
||||
, _itTargeting :: Targeting
|
||||
, _itDimension :: ItemDimension
|
||||
, _itCurseStatus :: CurseStatus
|
||||
, _itTweaks :: ItemTweaks
|
||||
, _itScope :: Scope
|
||||
, _itValue :: ItemValue
|
||||
, _itParams :: ItemParams
|
||||
}
|
||||
data ItemPortage
|
||||
= HeldItem
|
||||
{ _handlePos :: Float
|
||||
, _muzPos :: Float
|
||||
data ItemTweaks
|
||||
= NoTweaks
|
||||
| Tweakable
|
||||
{ _tweakParams :: IM.IntMap TweakParam
|
||||
, _tweakSel :: Int
|
||||
}
|
||||
| WornItem
|
||||
| NoPortage
|
||||
|
||||
data ItemValue = ItemValue
|
||||
{ _ivInt :: Int
|
||||
, _ivType :: ItemValueType
|
||||
}
|
||||
data ItemValueType = MundaneItem | ArtefactItem
|
||||
data ItemPos
|
||||
= InInv { _ipCrID :: Int , _ipInvID :: Int }
|
||||
| OnFloor { _ipFlID :: Int }
|
||||
| VoidItm
|
||||
makeLenses ''ItemDimension
|
||||
makeLenses ''ItemPortage
|
||||
makeLenses ''ItemValue
|
||||
makeLenses ''ItemPos
|
||||
data TweakParam = TweakParam
|
||||
{ _doTweak :: Int -> Item -> Item
|
||||
, _curTweak :: Int
|
||||
, _maxTweak :: Int
|
||||
, _showTweak :: Int -> String
|
||||
, _nameTweak :: String
|
||||
}
|
||||
makeLenses ''Item
|
||||
makeLenses ''ItemTweaks
|
||||
makeLenses ''TweakParam
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Item.Misc where
|
||||
import Geometry.Data
|
||||
import Control.Lens
|
||||
|
||||
data ItemDimension = ItemDimension
|
||||
{ _dimRad :: Float
|
||||
, _dimCenter :: Point3
|
||||
, _dimAttachPos :: Point3
|
||||
}
|
||||
data ItemPortage
|
||||
= HeldItem
|
||||
{ _handlePos :: Float
|
||||
, _muzPos :: Float
|
||||
}
|
||||
| WornItem
|
||||
| NoPortage
|
||||
|
||||
data ItemValue = ItemValue
|
||||
{ _ivInt :: Int
|
||||
, _ivType :: ItemValueType
|
||||
}
|
||||
data ItemValueType = MundaneItem | ArtefactItem
|
||||
data ItemPos
|
||||
= InInv { _ipCrID :: Int , _ipInvID :: Int }
|
||||
| OnFloor { _ipFlID :: Int }
|
||||
| VoidItm
|
||||
makeLenses ''ItemDimension
|
||||
makeLenses ''ItemPortage
|
||||
makeLenses ''ItemValue
|
||||
makeLenses ''ItemPos
|
||||
@@ -1,3 +1,84 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Item.Params where
|
||||
import Dodge.Data.Beam
|
||||
import Dodge.Data.ArcStep
|
||||
import Geometry.Data
|
||||
import Color
|
||||
import Control.Lens
|
||||
|
||||
data ItemParams
|
||||
= NoParams
|
||||
| ShellLauncher
|
||||
{ _shellSpinDrag :: Int
|
||||
, _shellSpinAmount :: Int
|
||||
, _shellThrustDelay :: Int
|
||||
}
|
||||
| Refracting
|
||||
{ _phaseV :: Float
|
||||
, _lasColor :: Color
|
||||
, _lasColor2 :: Color
|
||||
, _lasCycle :: Int
|
||||
, _lasDamage :: Int
|
||||
}
|
||||
| DualBeam
|
||||
{ _phaseV :: Float
|
||||
, _lasColor :: Color
|
||||
, _lasColor2 :: Color
|
||||
, _lasCycle :: Int
|
||||
, _lasDamage :: Int
|
||||
, _lasBeam :: BeamType
|
||||
, _subParams :: Maybe ItemParams
|
||||
, _dbGap :: Float
|
||||
}
|
||||
| Attracting {_attractionPower :: Point2}
|
||||
| BulletShooter
|
||||
{ _muzVel :: Float
|
||||
, _rifling :: Float
|
||||
, _bore :: Float
|
||||
, _gunBarrels :: GunBarrels
|
||||
, _recoil :: Float
|
||||
, _torqueAfter :: Float
|
||||
, _randomOffset :: Float
|
||||
}
|
||||
| Sprayer { _sprayNozzles :: [Nozzle] }
|
||||
| AngleWalk
|
||||
{ _maxWalkAngle :: Float
|
||||
, _currentWalkAngle :: Float
|
||||
, _walkSpeed :: Float
|
||||
}
|
||||
| Arcing
|
||||
{ _currentArc :: Maybe [ArcStep]
|
||||
, _arcSize :: Float
|
||||
, _arcNumber :: Int
|
||||
, _newArcStep :: NextArcStep --ItemParams -> World -> ArcStep -> State StdGen (Maybe ArcStep)
|
||||
, _previousArcEffect :: PreviousArcEffect
|
||||
}
|
||||
| ParamMID {_paramMID :: Maybe Int}
|
||||
data PreviousArcEffect = NoPreviousArcEffect | PerturbTillBreakPreviousArc
|
||||
data GunBarrels
|
||||
= MultiBarrel
|
||||
{ _brlSpread :: BarrelSpread
|
||||
, _brlNum :: Int
|
||||
, _brlInaccuracy :: Float
|
||||
}
|
||||
| RotBarrel
|
||||
{ _brlNum :: Int
|
||||
, _brlInaccuracy :: Float
|
||||
}
|
||||
| SingleBarrel {_brlInaccuracy :: Float}
|
||||
data Nozzle = Nozzle
|
||||
{ _nzPressure :: Float
|
||||
, _nzDir :: Float
|
||||
, _nzMaxWalkAngle :: Float
|
||||
, _nzCurrentWalkAngle :: Float
|
||||
, _nzWalkSpeed :: Float
|
||||
, _nzLength :: Float
|
||||
}
|
||||
data BarrelSpread
|
||||
= AlignedBarrels
|
||||
| SpreadBarrels {_spreadAngle :: Float}
|
||||
| RotatingBarrels {_rotatingBarrelInaccuracy :: Float}
|
||||
|
||||
makeLenses ''BarrelSpread
|
||||
makeLenses ''ItemParams
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
{-# LANGUAGE StrictData #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
--{-# LANGUAGE TemplateHaskell #-}
|
||||
module Dodge.Item.Data where
|
||||
import Control.Lens
|
||||
--import Control.Lens
|
||||
data CurseStatus
|
||||
= Uncursed
|
||||
| UndroppableIdentified
|
||||
| UndroppableUnidentified
|
||||
data BarrelSpread
|
||||
= AlignedBarrels
|
||||
| SpreadBarrels {_spreadAngle :: Float}
|
||||
| RotatingBarrels {_rotatingBarrelInaccuracy :: Float}
|
||||
makeLenses ''BarrelSpread
|
||||
|
||||
Reference in New Issue
Block a user