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
+131 -127
View File
@@ -19,13 +19,17 @@ data ActionPlan
,_apStrategy :: Strategy
,_apGoal :: [Goal]
}
newtype RandImpulse = RandImpulseList [Impulse]
deriving (Eq,Ord,Show,Read)
data RandImpulse
= RandImpulseList [Impulse]
| RandImpulseCircMove Float
deriving (Eq,Ord,Show,Read)
data Impulse
= Move Point2
| MoveForward Float
| Turn Float
| RandomTurn Float
| RandomImpulse (State StdGen Impulse)
| RandomImpulse RandImpulse -- (State StdGen Impulse)
| TurnToward Point2 Float
| MvTurnToward Point2
| MvForward
@@ -52,34 +56,34 @@ data Impulse
{_impulseUseAheadPos :: P2Imp
}
| ImpulseNothing
instance Show Impulse where
show imp = case imp of
Move p -> "Move "++shortPoint2 p
MoveForward f -> "MoveForward "++ show f
Turn f -> "Turn "++show f
RandomTurn f -> "RandomTurn "++show f
TurnToward p f -> "TurnToward "++shortPoint2 p++show f
MvTurnToward p -> "MvTurnToward "++shortPoint2 p
MvForward -> "MvForward"
TurnTo p -> "TurnTo "++shortPoint2 p
UseItem -> "UseItem"
SwitchToItem i -> "SwitchToItem "++show i
DropItem -> "DropItem"
Bark sid -> "Bark "++show sid
Melee i -> "Melee "++show i
ChangePosture post -> "ChangePosture " ++ show post
MakeSound sid -> "MakeSound " ++ show sid
ChangeStrategy s -> "ChangeStrategy " ++ show s
AddGoal g -> "AddGoal " ++ show g
ArbitraryImpulseFunction {} -> "ArbitraryImpulseFunction"
ArbitraryImpulse {} -> "ArbitraryImpulse"
ArbitraryImpulseEffect {} -> "ArbitraryImpulseEffect"
ImpulseUseTargetCID {} -> "ImpulseUseTargetCID"
ImpulseUseTarget {} -> "ImpulseUseTarget"
ImpulseUseAheadPos {} -> "ImpulseUseAheadPos"
RandomImpulse {} -> "RandomImpulse"
ImpulseNothing -> "ImpulseNothing"
-- deriving (Eq,Ord,Show)
deriving (Eq,Ord,Show,Read)
--instance Show Impulse where
-- show imp = case imp of
-- Move p -> "Move "++shortPoint2 p
-- MoveForward f -> "MoveForward "++ show f
-- Turn f -> "Turn "++show f
-- RandomTurn f -> "RandomTurn "++show f
-- TurnToward p f -> "TurnToward "++shortPoint2 p++show f
-- MvTurnToward p -> "MvTurnToward "++shortPoint2 p
-- MvForward -> "MvForward"
-- TurnTo p -> "TurnTo "++shortPoint2 p
-- UseItem -> "UseItem"
-- SwitchToItem i -> "SwitchToItem "++show i
-- DropItem -> "DropItem"
-- Bark sid -> "Bark "++show sid
-- Melee i -> "Melee "++show i
-- ChangePosture post -> "ChangePosture " ++ show post
-- MakeSound sid -> "MakeSound " ++ show sid
-- ChangeStrategy s -> "ChangeStrategy " ++ show s
-- AddGoal g -> "AddGoal " ++ show g
-- ArbitraryImpulseFunction {} -> "ArbitraryImpulseFunction"
-- ArbitraryImpulse {} -> "ArbitraryImpulse"
-- ArbitraryImpulseEffect {} -> "ArbitraryImpulseEffect"
-- ImpulseUseTargetCID {} -> "ImpulseUseTargetCID"
-- ImpulseUseTarget {} -> "ImpulseUseTarget"
-- ImpulseUseAheadPos {} -> "ImpulseUseAheadPos"
-- RandomImpulse {} -> "RandomImpulse"
-- ImpulseNothing -> "ImpulseNothing"
infixr 9 `WaitThen`
infixr 9 `DoActionThen`
infixr 9 `DoActionWhile`
@@ -180,101 +184,101 @@ data Action
{_sideImpulses :: [Impulse]
,_mainAction :: Action
}
deriving (Generic)
instance Show Action where
show act = case act of
ActionNothing -> "ActionNothing"
LabelAction
{_actLabel = str
,_actAction = subAct
} -> str++":"++show subAct
AimAt
{_targetID = tid
,_targetSeenAt = p
} -> "AimAt tid:"++show tid++" seenAt:"++shortPoint2 p
PathTo
{_pathToPoint = p
} -> "PathTo:"++shortPoint2 p
TurnToPoint
{_turnToPoint = p
} -> "TurnToPoint:"++shortPoint2 p
---- | PickupItem
---- {_pickupItemID :: Int
---- }
ImpulsesList
{_impulsesListList = iss
} -> "ImpulsesList:"++show iss
DoImpulses
{_doImpulsesList = is
} -> "DoImpulses:"++show is
WaitThen
{_waitThenTimer = i
,_waitThenAction = a
} -> "WaitThen timer:"++show i++" act:"++show a
DoActionWhile
{_doActionWhileCondition = _
,_doActionWhileAction = a
} -> "DoActionWhile (function) act:"++show a
DoActionWhilePartial
{_doActionWhilePartial = partact
,_doActionWhileCondition = _
,_doActionWhileAction = a
} -> "DoActionWhilePartial partAct:"++show partact++" resetAct:"++show a
DoActionIf
{_doActionIfCondition = _
,_doActionIfAction = a
} -> "DoActionIf act:"++show a
DoActionIfElse
{_doActionIfElseIfAction = ifa
,_doActionIfElseCondition = _
,_doActionIfElseElseAction = elsea
} -> "DoActionIfElse ifa:"++show ifa++" elsea:"++show elsea
DoActionWhileInterrupt
{_doActionWhileThenDo = whilea
,_doActionWhileThenCondition = _
,_doActionWhileThenThen = thena
} -> "DoActionWhileInterrupt whilea:" ++show whilea++" interrupta:"++show thena
DoActions
{_doActionsList = as
} -> "DoActions " ++ foldMap show as
DoActionThen
{_doActionThenFirst = a1
,_doActionThenSecond = a2
} -> "DoActionThen " ++ show a1 ++ " then:" ++ show a2
---- | DoGuardActions
---- {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
---- }
DoReplicate
{_doReplicateTimes = i
,_doReplicateAction = a
} -> "DoReplicate times:" ++ show i ++ " act:"++ show a
DoReplicatePartial
{_partialAction = pa
,_doReplicateTimes = i
,_doReplicateAction = ra
} -> "DoReplicatePartial pa:" ++ show pa ++ " times:" ++ show i ++ " reset:"++ show ra
LeadTarget
{_leadTargetBy = p
} -> "LeadTarget by:"++ show p
NoAction -> "NoAction"
StartSentinelPost -> "StartSentinelPost"
UseTarget
{_useTarget = _
} -> "UseTarget func"
UseSelf
{_useSelf = _
} -> "UseSelf func"
UseAheadPos
{_useAheadPos = _
} -> "UseAheadPos func"
UseMvTargetPos
{_useMvTargetPos = _
} -> "UseMvTargetPos func"
ArbitraryAction {} -> "ArbitraryAction func"
DoImpulsesAlongside
{_sideImpulses = is
,_mainAction = a
} -> "DoImpulsesAlongside sideImpulses:"++show is ++ " mainA:"++show a
deriving (Eq,Ord,Show,Read)
--instance Show Action where
-- show act = case act of
-- ActionNothing -> "ActionNothing"
-- LabelAction
-- {_actLabel = str
-- ,_actAction = subAct
-- } -> str++":"++show subAct
-- AimAt
-- {_targetID = tid
-- ,_targetSeenAt = p
-- } -> "AimAt tid:"++show tid++" seenAt:"++shortPoint2 p
-- PathTo
-- {_pathToPoint = p
-- } -> "PathTo:"++shortPoint2 p
-- TurnToPoint
-- {_turnToPoint = p
-- } -> "TurnToPoint:"++shortPoint2 p
------ | PickupItem
------ {_pickupItemID :: Int
------ }
-- ImpulsesList
-- {_impulsesListList = iss
-- } -> "ImpulsesList:"++show iss
-- DoImpulses
-- {_doImpulsesList = is
-- } -> "DoImpulses:"++show is
-- WaitThen
-- {_waitThenTimer = i
-- ,_waitThenAction = a
-- } -> "WaitThen timer:"++show i++" act:"++show a
-- DoActionWhile
-- {_doActionWhileCondition = _
-- ,_doActionWhileAction = a
-- } -> "DoActionWhile (function) act:"++show a
-- DoActionWhilePartial
-- {_doActionWhilePartial = partact
-- ,_doActionWhileCondition = _
-- ,_doActionWhileAction = a
-- } -> "DoActionWhilePartial partAct:"++show partact++" resetAct:"++show a
-- DoActionIf
-- {_doActionIfCondition = _
-- ,_doActionIfAction = a
-- } -> "DoActionIf act:"++show a
-- DoActionIfElse
-- {_doActionIfElseIfAction = ifa
-- ,_doActionIfElseCondition = _
-- ,_doActionIfElseElseAction = elsea
-- } -> "DoActionIfElse ifa:"++show ifa++" elsea:"++show elsea
-- DoActionWhileInterrupt
-- {_doActionWhileThenDo = whilea
-- ,_doActionWhileThenCondition = _
-- ,_doActionWhileThenThen = thena
-- } -> "DoActionWhileInterrupt whilea:" ++show whilea++" interrupta:"++show thena
-- DoActions
-- {_doActionsList = as
-- } -> "DoActions " ++ foldMap show as
-- DoActionThen
-- {_doActionThenFirst = a1
-- ,_doActionThenSecond = a2
-- } -> "DoActionThen " ++ show a1 ++ " then:" ++ show a2
------ | DoGuardActions
------ {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
------ }
-- DoReplicate
-- {_doReplicateTimes = i
-- ,_doReplicateAction = a
-- } -> "DoReplicate times:" ++ show i ++ " act:"++ show a
-- DoReplicatePartial
-- {_partialAction = pa
-- ,_doReplicateTimes = i
-- ,_doReplicateAction = ra
-- } -> "DoReplicatePartial pa:" ++ show pa ++ " times:" ++ show i ++ " reset:"++ show ra
-- LeadTarget
-- {_leadTargetBy = p
-- } -> "LeadTarget by:"++ show p
-- NoAction -> "NoAction"
-- StartSentinelPost -> "StartSentinelPost"
-- UseTarget
-- {_useTarget = _
-- } -> "UseTarget func"
-- UseSelf
-- {_useSelf = _
-- } -> "UseSelf func"
-- UseAheadPos
-- {_useAheadPos = _
-- } -> "UseAheadPos func"
-- UseMvTargetPos
-- {_useMvTargetPos = _
-- } -> "UseMvTargetPos func"
-- ArbitraryAction {} -> "ArbitraryAction func"
-- DoImpulsesAlongside
-- {_sideImpulses = is
-- ,_mainAction = a
-- } -> "DoImpulsesAlongside sideImpulses:"++show is ++ " mainA:"++show a
-- deriving (Eq,Ord,Show)
data Strategy
@@ -293,13 +297,13 @@ data Strategy
| Reload
| Flee
| MeleeStrike
deriving (Generic,Show)
deriving (Eq,Ord,Show,Read)
-- deriving (Eq,Ord,Show)
data Goal
= LiveLongAndProsper
| Kill Int
| SentinelAt Point2 Float
deriving (Show)
deriving (Eq,Ord,Show,Read)
makeLenses ''ActionPlan
makeLenses ''Impulse
makeLenses ''Action
+1 -1
View File
@@ -41,6 +41,6 @@ data AmmoType
{ _amForceFieldType :: Wall
}
| GenericAmmo
deriving (Show,Read)
deriving (Eq,Ord,Show,Read)
makeLenses ''ProjectileUpdate
makeLenses ''AmmoType
+18
View File
@@ -0,0 +1,18 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.Corpse where
import ShapePicture.Data
import Geometry.Data
import Control.Lens
data CorpseResurrection = NoResurrection
data Corpse = Corpse
{ _cpID :: Int
, _cpPos :: Point2
, _cpDir :: Float
, _cpSPic :: SPic
, _cpRes :: CorpseResurrection
}
makeLenses ''Corpse
+5 -9
View File
@@ -45,7 +45,7 @@ data Creature = Creature
, _crEquipment :: M.Map EquipPosition Int
, _crLeftInvSel :: Maybe Int
, _crState :: CreatureState
, _crCorpse :: Creature -> Corpse -> SPic
, _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic
, _crMaterial :: Material
, _crPastDamage :: Int
, _crStance :: Stance
@@ -63,18 +63,14 @@ data Creature = Creature
, _crStatistics :: CreatureStatistics
, _crCamouflage :: CamouflageStatus
}
data Corpse = Corpse
{ _cpID :: Int
, _cpPos :: Point2
, _cpDir :: Float
, _cpPict :: Corpse -> SPic
, _cpRes :: Maybe Creature
}
deriving (Eq,Ord,Show,Read)
data CreatureCorpse = MakeDefaultCorpse
deriving (Eq,Ord,Show,Read)
data Intention = Intention
{ _targetCr :: Maybe Creature
, _mvToPoint :: Maybe Point2
, _viewPoint :: Maybe Point2
}
deriving (Eq,Ord,Show,Read)
makeLenses ''Creature
makeLenses ''Intention
makeLenses ''Corpse
+16 -4
View File
@@ -4,17 +4,20 @@ module Dodge.Data.Creature.Misc
( module Dodge.Data.Creature.Misc
, module Dodge.Data.CamouflageStatus
) where
import Dodge.Data.FloatFunction
import Dodge.Data.CamouflageStatus
import Sound.Data
import Geometry.Data
import Color
import Control.Lens
data CreatureStatistics = CreatureStatistics
{ _strength :: Int
, _dexterity :: Int
, _intelligence :: Int
}
deriving (Eq,Ord,Show)
deriving (Eq,Ord,Show,Read)
data Vocalization
= Mute
| Vocalization
@@ -23,19 +26,24 @@ data Vocalization
,_vcMaxCoolDown :: Int
,_vcCoolDown :: Int
}
deriving (Eq,Ord,Show)
deriving (Eq,Ord,Show,Read)
data CrMvType
= NoMvType
| MvWalking { _mvSpeed :: Float }
| CrMvType
{ _mvSpeed :: Float
, _mvTurnRad :: Float -> Float
, _mvTurnRad :: FloatFloat
, _mvTurnJit :: Float
, _mvAimSpeed :: Float -> Float
, _mvAimSpeed :: FloatFloat
}
deriving (Eq,Ord,Show,Read)
data HumanoidAI = YourAI | ChaseAI | InanimateAI | SpreadGunAI | PistolAI
| LtAutoAI | LauncherAI | SwarmAI | AutoAI | FlockArmourChaseAI | MiniGunAI
| LongAI | MultGunAI
deriving (Eq,Ord,Show,Read)
data CreatureType
= Humanoid
{ _skinHead :: Color
@@ -47,7 +55,11 @@ data CreatureType
| Lampoid {_lampHeight :: Float, _lampColor :: Point3, _lampLSID :: Maybe Int}
| Turretoid
| NonDrawnCreature
deriving (Eq,Ord,Show,Read)
data BarrelType = PlainBarrel | ExplosiveBarrel
deriving (Eq,Ord,Show,Read)
makeLenses ''CreatureStatistics
makeLenses ''Vocalization
makeLenses ''CrMvType
+1
View File
@@ -10,4 +10,5 @@ data CreatureState = CrSt
, _csSpState :: CrSpState
, _csDropsOnDeath :: CreatureDropType
}
deriving (Eq,Ord,Show,Read)
makeLenses ''CreatureState
+13
View File
@@ -1,37 +1,50 @@
module Dodge.Data.CreatureEffect where
data WdCrCr = NoCreatureEffect
deriving (Eq,Ord,Show,Read)
data CrWdImp = NoCrWdImp
deriving (Eq,Ord,Show,Read)
data CrWdWd = CrWdWdId
deriving (Eq,Ord,Show,Read)
data IntImp = NoIntImp
deriving (Eq,Ord,Show,Read)
data CrImp = NoCrImp
| TurnTowardCr Float -- turn amount
deriving (Eq,Ord,Show,Read)
data P2Imp = P2ImpNo
deriving (Eq,Ord,Show,Read)
data WdCrBl = WdCrTrue
| WdCrBlfromCrBl CrBl
| WdCrNegate WdCrBl
| WdCrLOSTarget
| WdCrSafeDistFromTarget Float
deriving (Eq,Ord,Show,Read)
data CrBl = CrCanShoot
| CrIsReloading
| CrIsAiming
deriving (Eq,Ord,Show,Read)
data MCrAc = MCrNoAction
deriving (Eq,Ord,Show,Read)
data CrAc = CrTurnAround
| CrFleeFromTarget
deriving (Eq,Ord,Show,Read)
data P2Ac = P2NoAction
deriving (Eq,Ord,Show,Read)
data MP2Ac = MP2NoAction
deriving (Eq,Ord,Show,Read)
data CrWdAc = CrWdBFSThenReturn Int
| ChooseMovementSpreadGun
| ChooseMovementLtAuto
deriving (Eq,Ord,Show,Read)
+8
View File
@@ -0,0 +1,8 @@
module Dodge.Data.FloatFunction where
data FloatFloat = FloatID
| FloatFOV Float
| FloatLessCheck Float
| FloatAbsCheckGreaterLess Float Float Float
| FloatConst Float
deriving (Eq,Ord,Show,Read)
+1 -1
View File
@@ -40,7 +40,7 @@ data Item = Item
, _itValue :: ItemValue
, _itParams :: ItemParams
}
deriving (Show,Read)
deriving (Eq,Ord,Show,Read)
data ItemTweaks
= NoTweaks
| Tweakable
+1 -1
View File
@@ -28,5 +28,5 @@ data ItemConsumption
{ _icAmount :: IcAmount
}
| NoConsumption
deriving (Show,Read)
deriving (Eq,Ord,Show,Read)
makeLenses ''ItemConsumption
+1
View File
@@ -11,6 +11,7 @@ data LoadAction
| LoadPrime {_actionTime :: Int, _actionSound :: SoundID}
deriving (Eq,Ord,Show,Read)
data InvSel = InvSel {_iselPos :: Int, _iselAction :: InvSelAction }
deriving (Eq,Ord,Show,Read)
data InvSelAction
= NoInvSelAction
| ReloadAction { _actionProgress :: Int, _reloadAction :: LoadAction, _actionHammer :: HammerType}