Compare commits
10 Commits
c041a4d174
...
707ccae971
| Author | SHA1 | Date | |
|---|---|---|---|
| 707ccae971 | |||
| 333f2875cb | |||
| f0e568e694 | |||
| 35d169b585 | |||
| 608de9f2ed | |||
| 9d7c9f1db2 | |||
| 262463c52d | |||
| 21573d0b05 | |||
| 9e29550a20 | |||
| 4723b45ef6 |
@@ -179,6 +179,7 @@ crHeight cr = case cr ^. crHP of
|
|||||||
HoverCrit {} -> 10
|
HoverCrit {} -> 10
|
||||||
ChaseCrit {} -> 25
|
ChaseCrit {} -> 25
|
||||||
Avatar {} -> 25
|
Avatar {} -> 25
|
||||||
|
CrabCrit {} -> 25
|
||||||
_ -> error "Need to define crHeight for this crType"
|
_ -> error "Need to define crHeight for this crType"
|
||||||
CrIsCorpse{} -> Just 5
|
CrIsCorpse{} -> Just 5
|
||||||
CrDestroyed{} -> Nothing
|
CrDestroyed{} -> Nothing
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ module Dodge.Creature.Action (
|
|||||||
youDropItem,
|
youDropItem,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import RandomHelp
|
||||||
import Dodge.WorldEvent.ThingsHit
|
import Dodge.WorldEvent.ThingsHit
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
@@ -45,9 +46,9 @@ performActions cid w =
|
|||||||
iss
|
iss
|
||||||
where
|
where
|
||||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||||
(iss, mayas) = foldMap (performAction cr w) $ cr ^. crActionPlan . apAction
|
(iss, mayas) = fromMaybe ([],NoAction) $ performAction cr w <$> cr ^? crActionPlan . apAction
|
||||||
|
|
||||||
type ActionUpdate = ([Impulse], [Action])
|
type ActionUpdate = ([Impulse], Action)
|
||||||
|
|
||||||
{- | Performing an action on a frame creates an ActionUpdate:
|
{- | Performing an action on a frame creates an ActionUpdate:
|
||||||
gives impulses and updates/deletes the action itself.
|
gives impulses and updates/deletes the action itself.
|
||||||
@@ -55,54 +56,61 @@ type ActionUpdate = ([Impulse], [Action])
|
|||||||
performAction :: Creature -> World -> Action -> ActionUpdate
|
performAction :: Creature -> World -> Action -> ActionUpdate
|
||||||
performAction cr w ac = case ac of
|
performAction cr w ac = case ac of
|
||||||
AimAt tcid p -> performAimAt cr w tcid p
|
AimAt tcid p -> performAimAt cr w tcid p
|
||||||
WaitThen 0 newAc -> ([], [newAc])
|
WaitThen 0 newAc -> ([], newAc)
|
||||||
WaitThen t newAc -> ([], [WaitThen (t -1) newAc])
|
WaitThen t newAc -> ([], WaitThen (t -1) newAc)
|
||||||
ImpulsesList (xs : xss) -> (xs, [ImpulsesList xss])
|
ImpulsesList (xs : xss) a -> performAction cr w a & _1 <>~ xs
|
||||||
ImpulsesList _ -> ([], mempty)
|
& _2 %~ ImpulsesList xss
|
||||||
DoImpulses imps -> (imps, mempty)
|
ImpulsesList _ a -> performAction cr w a
|
||||||
DoActionThen fsta afta -> case performAction cr w fsta of -- NOTE this only does ONE continuation action
|
DoImpulses imps -> (imps, NoAction)
|
||||||
(imps, nxta : _) -> (imps, [DoActionThen nxta afta])
|
DoActionThen fsta afta -> case performAction cr w fsta of
|
||||||
(imps, []) -> (imps, [afta])
|
(imps, NoAction) -> (imps, afta)
|
||||||
|
(imps, nxta) -> (imps, DoActionThen nxta afta)
|
||||||
DoActionWhile f act -> performAction cr w $ DoActionWhilePartial act f act
|
DoActionWhile f act -> performAction cr w $ DoActionWhilePartial act f act
|
||||||
DoActionWhilePartial partAc f resetAc
|
DoActionWhilePartial partAc f resetAc
|
||||||
| doWdCrBl f w cr -> case performAction cr w partAc of
|
| doWdCrBl f w cr -> case performAction cr w partAc of
|
||||||
(imps, nxta : _) -> (imps, [DoActionWhilePartial nxta f resetAc])
|
(imps, NoAction) -> (imps, DoActionWhilePartial resetAc f resetAc)
|
||||||
(imps, []) -> (imps, [DoActionWhilePartial resetAc f resetAc])
|
(imps, nxta ) -> (imps, DoActionWhilePartial nxta f resetAc)
|
||||||
| otherwise -> performAction cr w partAc
|
| otherwise -> performAction cr w partAc
|
||||||
DoActionIf f ifa
|
DoActionIf f ifa
|
||||||
| doWdCrBl f w cr -> performAction cr w ifa
|
| doWdCrBl f w cr -> performAction cr w ifa
|
||||||
| otherwise -> ([], mempty)
|
| otherwise -> ([], NoAction)
|
||||||
DoActionIfElse ifa f elsea
|
DoActionIfElse ifa f elsea
|
||||||
| doWdCrBl f w cr -> performAction cr w ifa
|
| doWdCrBl f w cr -> performAction cr w ifa
|
||||||
| otherwise -> performAction cr w elsea
|
| otherwise -> performAction cr w elsea
|
||||||
DoActionWhileInterrupt repa f afta
|
DoActionWhileInterrupt repa f afta
|
||||||
| doWdCrBl f w cr -> (fst $ performAction cr w repa, [DoActionWhileInterrupt repa f afta])
|
| doWdCrBl f w cr -> (fst $ performAction cr w repa, DoActionWhileInterrupt repa f afta)
|
||||||
| otherwise -> performAction cr w afta
|
| otherwise -> performAction cr w afta
|
||||||
DoActions [] -> ([], mempty)
|
-- DoActions [] -> ([], NoAction)
|
||||||
DoActions acs ->
|
-- DoActions acs ->
|
||||||
let (imps, newAcs) = foldMap (performAction cr w) acs
|
-- let (imps, newAcs) = foldMap (performAction cr w) acs
|
||||||
in (imps, newAcs)
|
-- in (imps, newAcs)
|
||||||
StartSentinelPost -> ([AddGoal $ SentinelAt (cr ^. crPos . _xy) (_crDir cr)], mempty)
|
StartSentinelPost -> ([AddGoal $ SentinelAt (cr ^. crPos . _xy) (_crDir cr)], NoAction)
|
||||||
PathTo p a -> performPathTo a cr w p
|
PathTo p a -> performPathTo a cr w p
|
||||||
|
EvadeAim -> tryEvadeSideways cr w
|
||||||
TurnToPoint p -> performTurnToA cr p
|
TurnToPoint p -> performTurnToA cr p
|
||||||
LeadTarget p -> fromMaybe ([], mempty) $ do
|
LeadTarget p -> fromMaybe ([], NoAction) $ do
|
||||||
i <- cr ^? crIntention . targetCr . _Just
|
i <- cr ^? crIntention . targetCr . _Just
|
||||||
tcr <- w ^? cWorld . lWorld . creatures . ix i
|
tcr <- w ^? cWorld . lWorld . creatures . ix i
|
||||||
return ([TurnTo (tcr ^. crPos . _xy +.+ rotateV (_crDir tcr) p)], mempty)
|
return ([TurnTo (tcr ^. crPos . _xy +.+ rotateV (_crDir tcr) p)], NoAction)
|
||||||
UseSelf f -> performAction cr w $ doCrAc f cr
|
UseSelf f -> performAction cr w $ doCrAc f cr
|
||||||
ArbitraryAction f -> performAction cr w (doCrWdAc f cr w)
|
ArbitraryAction f -> performAction cr w (doCrWdAc f cr w)
|
||||||
DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of
|
DoImpulsesAlongside sideImp mainAc -> performAction cr w mainAc & _1 <>~ sideImp
|
||||||
(imp, [nxtac]) -> (sideImp ++ imp, [DoImpulsesAlongside sideImp nxtac])
|
|
||||||
(imp, _) -> (sideImp ++ imp, mempty)
|
|
||||||
DoReplicate t nxtac -> performAction cr w $ DoReplicatePartial nxtac t nxtac
|
DoReplicate t nxtac -> performAction cr w $ DoReplicatePartial nxtac t nxtac
|
||||||
DoReplicatePartial _ 0 pac -> performAction cr w pac
|
DoReplicatePartial _ 0 pac -> performAction cr w pac
|
||||||
DoReplicatePartial startac t partac -> case performAction cr w partac of
|
DoReplicatePartial startac t partac -> case performAction cr w partac of
|
||||||
(imps, [nextac]) -> (imps, [DoReplicatePartial startac t nextac])
|
(imps, NoAction) -> (imps, DoReplicatePartial startac (t -1) startac)
|
||||||
(imps, _) -> (imps, [DoReplicatePartial startac (t -1) startac])
|
(imps, nextac) -> (imps, DoReplicatePartial startac t nextac)
|
||||||
NoAction -> ([], mempty)
|
NoAction -> ([], NoAction)
|
||||||
|
|
||||||
|
tryEvadeSideways :: Creature -> World -> ActionUpdate
|
||||||
|
tryEvadeSideways _ w = jumpleft -- (mv,mempty)
|
||||||
|
where
|
||||||
|
jumpleft = (mv,DoReplicate 5 (DoImpulses mv))
|
||||||
|
mv = [Walk (V2 0 d)]
|
||||||
|
d = evalState (takeOne [3,-3]) (w ^. randGen)
|
||||||
|
|
||||||
performAimAt :: Creature -> World -> Int -> Point2 -> ActionUpdate
|
performAimAt :: Creature -> World -> Int -> Point2 -> ActionUpdate
|
||||||
performAimAt cr w tcid p = ([TurnToward tpos aimSp], [AimAt tcid tpos])
|
performAimAt cr w tcid p = ([TurnToward tpos aimSp], AimAt tcid tpos)
|
||||||
where
|
where
|
||||||
cdir = _crDir cr
|
cdir = _crDir cr
|
||||||
cpos = cr ^. crPos . _xy
|
cpos = cr ^. crPos . _xy
|
||||||
@@ -121,20 +129,20 @@ crPathing cr = case cr ^. crStance . carriage of
|
|||||||
|
|
||||||
performPathTo :: Action -> Creature -> World -> Point2 -> ActionUpdate
|
performPathTo :: Action -> Creature -> World -> Point2 -> ActionUpdate
|
||||||
performPathTo a cr w p
|
performPathTo a cr w p
|
||||||
| dist cpos p <= crRad (cr ^. crType) = mempty
|
| dist cpos p <= crRad (cr ^. crType) = (mempty,NoAction)
|
||||||
| fst (crPathing cr) cpos p w = gotowards p
|
| fst (crPathing cr) cpos p w = gotowards p
|
||||||
| otherwise = case uncurry pointTowardsImpulse' (crPathing cr) cpos p w of
|
| otherwise = case uncurry pointTowardsImpulse' (crPathing cr) cpos p w of
|
||||||
Just q -> gotowards q
|
Just q -> gotowards q
|
||||||
_ -> ([], [a])
|
_ -> ([], a)
|
||||||
where
|
where
|
||||||
gotowards q = ( [MvTurnToward q, MvForward, RandomTurn jit] , [PathTo p a])
|
gotowards q = ( [MvTurnToward q, MvForward, RandomTurn jit] , PathTo p a)
|
||||||
cpos = cr ^. crPos . _xy
|
cpos = cr ^. crPos . _xy
|
||||||
jit = _mvTurnJit $ crMvType cr
|
jit = _mvTurnJit $ crMvType cr
|
||||||
|
|
||||||
performTurnToA :: Creature -> Point2 -> ActionUpdate
|
performTurnToA :: Creature -> Point2 -> ActionUpdate
|
||||||
performTurnToA cr p
|
performTurnToA cr p
|
||||||
| angleVV cdirv dirv < 0.1 = mempty
|
| angleVV cdirv dirv < 0.1 = (mempty,NoAction)
|
||||||
| otherwise = ([MvTurnToward p, RandomTurn jit], [TurnToPoint p])
|
| otherwise = ([MvTurnToward p, RandomTurn jit], TurnToPoint p)
|
||||||
where
|
where
|
||||||
cpos = cr ^. crPos . _xy
|
cpos = cr ^. crPos . _xy
|
||||||
cdirv = unitVectorAtAngle (_crDir cr)
|
cdirv = unitVectorAtAngle (_crDir cr)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ flockArmourChaseCrit =
|
|||||||
-- ]
|
-- ]
|
||||||
, _crActionPlan =
|
, _crActionPlan =
|
||||||
ActionPlan
|
ActionPlan
|
||||||
{ _apAction = []
|
{ _apAction = NoAction
|
||||||
, _apStrategy = FollowImpulses
|
, _apStrategy = FollowImpulses
|
||||||
, _apGoal = [Kill 0]
|
, _apGoal = [Kill 0]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
module Dodge.Creature.ChaseCrit (
|
module Dodge.Creature.ChaseCrit (
|
||||||
smallChaseCrit,
|
smallChaseCrit,
|
||||||
invisibleChaseCrit,
|
invisibleChaseCrit,
|
||||||
|
crabCrit,
|
||||||
chaseCrit,
|
chaseCrit,
|
||||||
hoverCrit,
|
hoverCrit,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
--import Dodge.Data.Equipment.Misc
|
--import Dodge.Data.Equipment.Misc
|
||||||
|
import Dodge.Data.FloatFunction
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Data.Creature
|
import Dodge.Data.Creature
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
@@ -32,6 +34,20 @@ chaseCrit =
|
|||||||
& crHP .~ HP 150
|
& crHP .~ HP 150
|
||||||
& crFaction .~ ColorFaction green
|
& crFaction .~ ColorFaction green
|
||||||
|
|
||||||
|
crabCrit :: Creature
|
||||||
|
crabCrit = defaultCreature
|
||||||
|
& crName .~ "chaseCrit"
|
||||||
|
& crHP .~ HP 350
|
||||||
|
& crType .~ CrabCrit
|
||||||
|
{ _meleeCooldownL = 0
|
||||||
|
, _meleeCooldownR = 0
|
||||||
|
, _footForward = LeftForward
|
||||||
|
, _strideAmount = 0
|
||||||
|
, _dodgeCooldown = 0
|
||||||
|
}
|
||||||
|
& crFaction .~ ColorFaction red
|
||||||
|
& crPerception . cpVision . viFOV .~ FloatFOV pi
|
||||||
|
|
||||||
hoverCrit :: Creature
|
hoverCrit :: Creature
|
||||||
hoverCrit =
|
hoverCrit =
|
||||||
defaultCreature
|
defaultCreature
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ followImpulse cid w = \case
|
|||||||
soundStart (CrMouth cid) cpos sid Nothing $
|
soundStart (CrMouth cid) cpos sid Nothing $
|
||||||
w & clens %~ resetCrVocCoolDown w
|
w & clens %~ resetCrVocCoolDown w
|
||||||
Move p -> crup $ crMvBy p (w ^. cWorld . lWorld)
|
Move p -> crup $ crMvBy p (w ^. cWorld . lWorld)
|
||||||
|
Walk p -> crup $ crWalk p (w ^. cWorld . lWorld)
|
||||||
MoveForward x -> crup $ crMvForward x (w ^. cWorld . lWorld)
|
MoveForward x -> crup $ crMvForward x (w ^. cWorld . lWorld)
|
||||||
MoveNoStride p -> crup $ crMvByNoStride p (w ^. cWorld . lWorld)
|
MoveNoStride p -> crup $ crMvByNoStride p (w ^. cWorld . lWorld)
|
||||||
Turn a -> crup $ crDir +~ a
|
Turn a -> crup $ crDir +~ a
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ module Dodge.Creature.Impulse.Movement (
|
|||||||
creatureTurnTowardDir,
|
creatureTurnTowardDir,
|
||||||
crMvAbsolute,
|
crMvAbsolute,
|
||||||
crMvBy,
|
crMvBy,
|
||||||
|
crWalk,
|
||||||
crMvByNoStride,
|
crMvByNoStride,
|
||||||
crMvForward,
|
crMvForward,
|
||||||
creatureTurnTo,
|
creatureTurnTo,
|
||||||
@@ -27,6 +28,14 @@ crMvBy ::
|
|||||||
Creature
|
Creature
|
||||||
crMvBy p lw cr = crMvAbsolute lw (rotateV (_crDir cr) p) cr
|
crMvBy p lw cr = crMvAbsolute lw (rotateV (_crDir cr) p) cr
|
||||||
|
|
||||||
|
crWalk ::
|
||||||
|
-- | Movement translation vector, will be made relative to creature direction
|
||||||
|
Point2 ->
|
||||||
|
LWorld ->
|
||||||
|
Creature ->
|
||||||
|
Creature
|
||||||
|
crWalk p lw cr = crWalkAbsolute lw (rotateV (_crDir cr) p) cr
|
||||||
|
|
||||||
crMvByNoStride ::
|
crMvByNoStride ::
|
||||||
-- | Movement translation vector, will be made relative to creature direction
|
-- | Movement translation vector, will be made relative to creature direction
|
||||||
Point2 ->
|
Point2 ->
|
||||||
@@ -43,6 +52,15 @@ crMvAbsolute lw p' cr =
|
|||||||
where
|
where
|
||||||
p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
|
p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
|
||||||
|
|
||||||
|
crWalkAbsolute :: LWorld -> Point2 -> Creature -> Creature
|
||||||
|
crWalkAbsolute lw p' cr
|
||||||
|
| Walking <- cr ^. crStance . carriage = cr
|
||||||
|
& crPos . _xy +~ p
|
||||||
|
& crMvDir .~ argV (p + cr ^. crOldPos . _xy - cr ^. crOldOldPos . _xy)
|
||||||
|
| otherwise = cr
|
||||||
|
where
|
||||||
|
p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
|
||||||
|
|
||||||
crMvAbsoluteNoStride :: LWorld -> Point2 -> Creature -> Creature
|
crMvAbsoluteNoStride :: LWorld -> Point2 -> Creature -> Creature
|
||||||
crMvAbsoluteNoStride lw p' cr = cr & crPos . _xy +~ p
|
crMvAbsoluteNoStride lw p' cr = cr & crPos . _xy +~ p
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import Dodge.Data.Creature.Misc
|
|||||||
crMass :: CreatureType -> Float
|
crMass :: CreatureType -> Float
|
||||||
crMass = \case
|
crMass = \case
|
||||||
Avatar {} -> 10
|
Avatar {} -> 10
|
||||||
ChaseCrit {} -> 12
|
ChaseCrit {} -> 10
|
||||||
|
CrabCrit {} -> 10
|
||||||
HoverCrit {} -> 5
|
HoverCrit {} -> 5
|
||||||
SwarmCrit -> 2
|
SwarmCrit -> 2
|
||||||
AutoCrit -> 10
|
AutoCrit -> 10
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ crMaterial :: CreatureType -> Material
|
|||||||
crMaterial = \case
|
crMaterial = \case
|
||||||
Avatar{_avatarMaterial = mt} -> mt
|
Avatar{_avatarMaterial = mt} -> mt
|
||||||
ChaseCrit {} -> Flesh
|
ChaseCrit {} -> Flesh
|
||||||
|
CrabCrit {} -> Flesh
|
||||||
HoverCrit {} -> Metal
|
HoverCrit {} -> Metal
|
||||||
SwarmCrit -> Flesh
|
SwarmCrit -> Flesh
|
||||||
AutoCrit -> Flesh
|
AutoCrit -> Flesh
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ crMaxHP :: CreatureType -> Int
|
|||||||
crMaxHP = \case
|
crMaxHP = \case
|
||||||
Avatar {} -> 15000
|
Avatar {} -> 15000
|
||||||
ChaseCrit {} -> 150
|
ChaseCrit {} -> 150
|
||||||
|
CrabCrit {} -> 350
|
||||||
HoverCrit {} -> 100
|
HoverCrit {} -> 100
|
||||||
SwarmCrit -> 50
|
SwarmCrit -> 50
|
||||||
AutoCrit -> 100
|
AutoCrit -> 100
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import Control.Lens
|
|||||||
crMvType :: Creature -> CrMvType
|
crMvType :: Creature -> CrMvType
|
||||||
crMvType cr = case _crType cr of
|
crMvType cr = case _crType cr of
|
||||||
Avatar {} -> MvWalking 1.5
|
Avatar {} -> MvWalking 1.5
|
||||||
ChaseCrit {} -> defaultChaseMvType
|
ChaseCrit {} -> defaultChaseMvType & mvSpeed .~ 1.8
|
||||||
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.15
|
CrabCrit {} -> defaultChaseMvType & mvSpeed .~ 0.5
|
||||||
|
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.16
|
||||||
SwarmCrit -> defaultChaseMvType
|
SwarmCrit -> defaultChaseMvType
|
||||||
AutoCrit -> defaultAimMvType
|
AutoCrit -> defaultAimMvType
|
||||||
BarrelCrit {} -> defaultAimMvType
|
BarrelCrit {} -> defaultAimMvType
|
||||||
|
|||||||
@@ -21,12 +21,8 @@ import Linear
|
|||||||
import RandomHelp
|
import RandomHelp
|
||||||
import Sound.Data
|
import Sound.Data
|
||||||
|
|
||||||
perceptionUpdate ::
|
-- | The [Int] is a list of creature ids that may direct attention and awareness
|
||||||
-- | List of creature ids that may direct attention and awareness
|
perceptionUpdate :: [Int] -> World -> Creature -> Creature
|
||||||
[Int] ->
|
|
||||||
World ->
|
|
||||||
Creature ->
|
|
||||||
Creature
|
|
||||||
perceptionUpdate is w = rememberSounds w . basicAwarenessUpdate w . basicAttentionUpdate is w
|
perceptionUpdate is w = rememberSounds w . basicAwarenessUpdate w . basicAttentionUpdate is w
|
||||||
|
|
||||||
{- | Update a creatures awareness based upon the creatures' current direction
|
{- | Update a creatures awareness based upon the creatures' current direction
|
||||||
@@ -55,9 +51,9 @@ basicAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
|
|||||||
return $
|
return $
|
||||||
(crActionPlan . apStrategy .~ WarningCry) .
|
(crActionPlan . apStrategy .~ WarningCry) .
|
||||||
(crActionPlan . apAction
|
(crActionPlan . apAction
|
||||||
.~ [ImpulsesList (crImpulsesOnCognizant w cr)
|
.~ ImpulsesList (crImpulsesOnCognizant w cr)
|
||||||
, AimAt 0 (w ^?! cWorld . lWorld . creatures . ix 0 . crPos . _xy)
|
(AimAt 0 (w ^?! cWorld . lWorld . creatures . ix 0 . crPos . _xy))
|
||||||
])
|
)
|
||||||
|
|
||||||
crImpulsesOnCognizant :: World -> Creature -> [[Impulse]]
|
crImpulsesOnCognizant :: World -> Creature -> [[Impulse]]
|
||||||
crImpulsesOnCognizant w cr = case cr ^. crType of
|
crImpulsesOnCognizant w cr = case cr ^. crType of
|
||||||
@@ -65,6 +61,7 @@ crImpulsesOnCognizant w cr = case cr ^. crType of
|
|||||||
<> [[ChangeStrategy $ CloseToMelee 0]]
|
<> [[ChangeStrategy $ CloseToMelee 0]]
|
||||||
HoverCrit {} | Just sid <- cognizantVoc w cr -> [Bark sid]:
|
HoverCrit {} | Just sid <- cognizantVoc w cr -> [Bark sid]:
|
||||||
[[ChangeStrategy $ CloseToMelee 0]]
|
[[ChangeStrategy $ CloseToMelee 0]]
|
||||||
|
CrabCrit {} -> [[ChangeStrategy $ CloseToMelee 0]]
|
||||||
_ | Just sid <- cognizantVoc w cr -> [Bark sid]: replicate 5 [RandomImpulse $ RandImpulseCircMove 1]
|
_ | Just sid <- cognizantVoc w cr -> [Bark sid]: replicate 5 [RandomImpulse $ RandImpulseCircMove 1]
|
||||||
_ -> replicate 5 [RandomImpulse $ RandImpulseCircMove 3]
|
_ -> replicate 5 [RandomImpulse $ RandImpulseCircMove 3]
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ module Dodge.Creature.Picture (
|
|||||||
deadFeet,
|
deadFeet,
|
||||||
drawChaseCrit,
|
drawChaseCrit,
|
||||||
drawHoverCrit,
|
drawHoverCrit,
|
||||||
|
drawCrabCrit,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Base.Collide
|
import Dodge.Base.Collide
|
||||||
@@ -65,6 +66,14 @@ drawHoverCrit cr = colorSH (_skinHead cskin)
|
|||||||
f a = tpq `Q.comp` (1 & _xy .~ rotateV a 5, Q.qid)
|
f a = tpq `Q.comp` (1 & _xy .~ rotateV a 5, Q.qid)
|
||||||
tpq = (V3 0 0 0, Q.qid)
|
tpq = (V3 0 0 0, Q.qid)
|
||||||
|
|
||||||
|
drawCrabCrit :: World -> Creature -> Shape
|
||||||
|
drawCrabCrit w cr = mconcat
|
||||||
|
[ crabUpperBody w cr
|
||||||
|
, colorSH (_skinLower cskin) $ crabFeet cr
|
||||||
|
]
|
||||||
|
where
|
||||||
|
cskin = crShape $ _crType cr
|
||||||
|
|
||||||
drawChaseCrit :: World -> Creature -> Shape
|
drawChaseCrit :: World -> Creature -> Shape
|
||||||
drawChaseCrit w cr = mconcat
|
drawChaseCrit w cr = mconcat
|
||||||
[ chaseUpperBody w cr
|
[ chaseUpperBody w cr
|
||||||
@@ -74,6 +83,16 @@ drawChaseCrit w cr = mconcat
|
|||||||
cskin = crShape $ _crType cr
|
cskin = crShape $ _crType cr
|
||||||
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
||||||
|
|
||||||
|
crabUpperBody :: World -> Creature -> Shape
|
||||||
|
crabUpperBody _ cr = colorSH (_skinUpper cskin)
|
||||||
|
(overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI 5 $ polyCirc 4 12
|
||||||
|
& each . _x *~ 0.6)
|
||||||
|
)
|
||||||
|
where
|
||||||
|
torsoq = (V3 0 0 10,Q.qid)
|
||||||
|
cskin = crShape $ _crType cr
|
||||||
|
|
||||||
|
|
||||||
chaseUpperBody :: World -> Creature -> Shape
|
chaseUpperBody :: World -> Creature -> Shape
|
||||||
chaseUpperBody w cr = colorSH (_skinUpper cskin)
|
chaseUpperBody w cr = colorSH (_skinUpper cskin)
|
||||||
(overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI tz $ polyCirc 3 12
|
(overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI tz $ polyCirc 3 12
|
||||||
@@ -126,6 +145,20 @@ feet cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
|||||||
-- f i = 8 * (sLen - 2*i) / sLen
|
-- f i = 8 * (sLen - 2*i) / sLen
|
||||||
f i = 8 * oneSmooth ((sLen - 2*i) / sLen)
|
f i = 8 * oneSmooth ((sLen - 2*i) / sLen)
|
||||||
|
|
||||||
|
crabFeet :: Creature -> Shape
|
||||||
|
{-# INLINE crabFeet #-}
|
||||||
|
crabFeet cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||||
|
(Just sa,Just LeftForward) -> sh (f sa)
|
||||||
|
(Just sa,Just RightForward) -> sh (-f sa)
|
||||||
|
_ -> sh 0
|
||||||
|
where
|
||||||
|
sh x = translateSHxy x off aFoot <> translateSHxy (- x) (- off) aFoot
|
||||||
|
aFoot = upperPrismPolyST 10 $ polyCirc 3 2
|
||||||
|
off = 10
|
||||||
|
sLen = strideLength cr
|
||||||
|
-- f i = 8 * (sLen - 2*i) / sLen
|
||||||
|
f i = 8 * oneSmooth ((sLen - 2*i) / sLen)
|
||||||
|
|
||||||
deadFeet :: Creature -> Shape
|
deadFeet :: Creature -> Shape
|
||||||
{-# INLINE deadFeet #-}
|
{-# INLINE deadFeet #-}
|
||||||
deadFeet = feet
|
deadFeet = feet
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ crRad :: CreatureType -> Float
|
|||||||
crRad = \case
|
crRad = \case
|
||||||
Avatar {} -> 10
|
Avatar {} -> 10
|
||||||
ChaseCrit {} -> 10
|
ChaseCrit {} -> 10
|
||||||
|
CrabCrit {} -> 10
|
||||||
HoverCrit {} -> 8
|
HoverCrit {} -> 8
|
||||||
SwarmCrit -> 2
|
SwarmCrit -> 2
|
||||||
AutoCrit -> 10
|
AutoCrit -> 10
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
module Dodge.Creature.ReaderUpdate (
|
module Dodge.Creature.ReaderUpdate (
|
||||||
doStrategyActions,
|
doStrategyActions,
|
||||||
setTargetMv,
|
|
||||||
targetYouWhenCognizant,
|
targetYouWhenCognizant,
|
||||||
overrideMeleeCloseTarget,
|
overrideMeleeCloseTarget,
|
||||||
watchUpdateStrat,
|
watchUpdateStrat,
|
||||||
@@ -9,11 +9,13 @@ module Dodge.Creature.ReaderUpdate (
|
|||||||
-- goToTarget,
|
-- goToTarget,
|
||||||
flockACC,
|
flockACC,
|
||||||
chaseCritMv,
|
chaseCritMv,
|
||||||
setMvPos,
|
crabCritMv,
|
||||||
|
setMvPosToTargetCr,
|
||||||
setViewPos,
|
setViewPos,
|
||||||
hoverCritMv,
|
hoverCritMv,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Dodge.WorldEvent.ThingsHit
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Bifunctor
|
import Data.Bifunctor
|
||||||
@@ -45,19 +47,18 @@ tryMeleeAttack cr tcr
|
|||||||
&& dist tpos cpos < crRad (cr ^. crType) + crRad (tcr ^. crType) + 5
|
&& dist tpos cpos < crRad (cr ^. crType) + crRad (tcr ^. crType) + 5
|
||||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 =
|
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 =
|
||||||
cr & crActionPlan . apAction
|
cr & crActionPlan . apAction
|
||||||
.~ [ DoImpulses [Melee $ _crID tcr] `DoActionThen`
|
.~ DoImpulses [Melee $ _crID tcr] `DoActionThen`
|
||||||
DoReplicate 10 NoAction
|
DoReplicate 10 NoAction
|
||||||
`DoActionThen` DoImpulses
|
-- `DoActionThen` DoImpulses
|
||||||
[ChangeStrategy (CloseToMelee $ _crID tcr)]
|
-- [ChangeStrategy (CloseToMelee $ _crID tcr)]
|
||||||
]
|
-- & crActionPlan . apStrategy .~ MeleeStrike
|
||||||
& crActionPlan . apStrategy .~ MeleeStrike
|
|
||||||
| otherwise = cr
|
| otherwise = cr
|
||||||
where
|
where
|
||||||
cpos = cr ^. crPos . _xy
|
cpos = cr ^. crPos . _xy
|
||||||
tpos = tcr ^. crPos . _xy
|
tpos = tcr ^. crPos . _xy
|
||||||
|
|
||||||
setMvPos :: World -> Creature -> Creature
|
setMvPosToTargetCr :: World -> Creature -> Creature
|
||||||
setMvPos w cr = cr & crIntention . mvToPoint .~ mpos
|
setMvPosToTargetCr w cr = cr & crIntention . mvToPoint .~ mpos
|
||||||
where
|
where
|
||||||
int = _crIntention cr
|
int = _crIntention cr
|
||||||
mtpos = do
|
mtpos = do
|
||||||
@@ -81,17 +82,17 @@ attentionViewPoint w cr = do
|
|||||||
guard $ visionCheck cr (tcr ^. crPos . _xy) > 0
|
guard $ visionCheck cr (tcr ^. crPos . _xy) > 0
|
||||||
tcr ^? crPos . _xy
|
tcr ^? crPos . _xy
|
||||||
|
|
||||||
setTargetMv ::
|
--setTargetMv ::
|
||||||
-- | Function for determining target
|
-- -- | Function for determining target
|
||||||
(World -> Creature -> Maybe Creature) ->
|
-- (World -> Creature -> Maybe Creature) ->
|
||||||
World ->
|
-- World ->
|
||||||
Creature ->
|
-- Creature ->
|
||||||
Creature
|
-- Creature
|
||||||
setTargetMv targFunc w cr =
|
--setTargetMv targFunc w cr =
|
||||||
maybe
|
-- maybe
|
||||||
cr
|
-- cr
|
||||||
(\ctarg -> cr & crIntention . mvToPoint ?~ (ctarg ^. crPos . _xy))
|
-- (\ctarg -> cr & crIntention . mvToPoint ?~ (ctarg ^. crPos . _xy))
|
||||||
(targFunc w cr)
|
-- (targFunc w cr)
|
||||||
|
|
||||||
-- ugly
|
-- ugly
|
||||||
flockACC :: World -> Creature -> Creature
|
flockACC :: World -> Creature -> Creature
|
||||||
@@ -120,48 +121,109 @@ flockACC w cr = fromMaybe cr $ do
|
|||||||
else negate r *.* horDir
|
else negate r *.* horDir
|
||||||
in cr & crIntention . mvToPoint ?~ tpos +.+ horShift
|
in cr & crIntention . mvToPoint ?~ tpos +.+ horShift
|
||||||
|
|
||||||
|
crabCritMv :: World -> Creature -> Creature
|
||||||
|
crabCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||||
|
_ | Just tid <- melee -> cr & crActionPlan . apAction
|
||||||
|
.~ DoImpulses [Melee tid] `DoActionThen`
|
||||||
|
DoReplicate 10 NoAction
|
||||||
|
& crType . meleeCooldownL .~ 20
|
||||||
|
WarningCry -> cr
|
||||||
|
CloseToMelee tid | aimi tid -> cr & crActionPlan . apAction .~ EvadeAim
|
||||||
|
& crType . dodgeCooldown .~ dc
|
||||||
|
CloseToMelee _ | ma <- cr ^? crActionPlan . apAction , notpath ma -> cr
|
||||||
|
Wander | Just tid <- cr ^? crIntention . targetCr . _Just
|
||||||
|
, canSee tid (cr ^. crID) w -> cr & crActionPlan . apStrategy .~ CloseToMelee tid
|
||||||
|
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||||
|
Just p
|
||||||
|
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
||||||
|
cr & crActionPlan . apAction .~ PathTo p (DoImpulses [ChangeStrategy Wander])
|
||||||
|
| otherwise ->
|
||||||
|
cr & crActionPlan . apAction .~ bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
|
||||||
|
& crActionPlan . apStrategy .~ Search
|
||||||
|
& crIntention . mvToPoint .~ Nothing
|
||||||
|
_ -> viewTarget w cr
|
||||||
|
where
|
||||||
|
melee = do
|
||||||
|
tid <- cr ^? crIntention . targetCr . _Just
|
||||||
|
tcr <- w ^? cWorld . lWorld . creatures . ix tid
|
||||||
|
let cpos = cr ^. crPos . _xy
|
||||||
|
tpos = tcr ^. crPos . _xy
|
||||||
|
guard $ _meleeCooldownL (_crType cr) == 0
|
||||||
|
&& Just (_crID tcr) == cr ^? crActionPlan . apStrategy . meleeTarget
|
||||||
|
&& dist tpos cpos < crRad (cr ^. crType) + crRad (tcr ^. crType) + 5
|
||||||
|
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4
|
||||||
|
return tid
|
||||||
|
dc = fst $ randomR (15,25) (w ^. randGen)
|
||||||
|
notpath = \case
|
||||||
|
Just NoAction -> False
|
||||||
|
Just PathTo {} -> False
|
||||||
|
Just AimAt {} -> False
|
||||||
|
_ -> True
|
||||||
|
aimi tid = fromMaybe False $ do
|
||||||
|
tcr <- w ^? cWorld . lWorld . creatures . ix tid
|
||||||
|
Aiming <- tcr ^? crStance . posture
|
||||||
|
let txy = tcr ^. crPos . _xy
|
||||||
|
cxy = cr ^. crPos . _xy
|
||||||
|
0 <- cr ^? crType . dodgeCooldown
|
||||||
|
return $ hasLOS cxy txy w
|
||||||
|
&& abs (nearZeroAngle (tcr^.crDir - argV (cxy - txy))) < 0.3
|
||||||
|
&& isWalkable txy cxy w
|
||||||
|
&& diffAngles (cr ^. crDir) (argV (txy - cxy)) < 0.1
|
||||||
|
|
||||||
chaseCritMv :: World -> Creature -> Creature
|
chaseCritMv :: World -> Creature -> Creature
|
||||||
chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||||
WarningCry -> cr
|
WarningCry -> cr
|
||||||
MeleeStrike -> cr
|
|
||||||
CloseToMelee cid
|
CloseToMelee cid
|
||||||
| VocReady == (cr ^. crVocalization) ->
|
| VocReady == (cr ^. crVocalization) ->
|
||||||
cr
|
cr
|
||||||
& crActionPlan . apAction
|
& crActionPlan . apAction
|
||||||
.:~ ImpulsesList
|
.~ ImpulsesList
|
||||||
( [Bark soundid] :
|
( [Bark soundid] :
|
||||||
replicate numjits [RandomImpulse thejitter]
|
replicate numjits [RandomImpulse thejitter]
|
||||||
++ [[ChangeStrategy (CloseToMelee cid)]]
|
++ [[ChangeStrategy (CloseToMelee cid)]]
|
||||||
)
|
) NoAction
|
||||||
& resetCrVocCoolDown w
|
& resetCrVocCoolDown w
|
||||||
& crActionPlan . apStrategy .~ WarningCry
|
& crActionPlan . apStrategy .~ WarningCry
|
||||||
where
|
where
|
||||||
thejitter = RandImpulseCircMove 3
|
thejitter = RandImpulseCircMove 3
|
||||||
soundid = evalState (takeOne (crWarningSounds cr)) (_randGen w)
|
soundid = evalState (takeOne (crWarningSounds cr)) (_randGen w)
|
||||||
numjits = fst $ randomR (15, 25) (_randGen w)
|
numjits = fst $ randomR (15, 25) (_randGen w)
|
||||||
|
CloseToMelee _ | ma <- cr ^? crActionPlan . apAction , notpath ma -> cr
|
||||||
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||||
Just p
|
Just p
|
||||||
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
||||||
cr & crActionPlan . apAction .~ [PathTo p (DoImpulses [ChangeStrategy Wander])]
|
cr & crActionPlan . apAction .~ PathTo p (DoImpulses [ChangeStrategy Wander])
|
||||||
| otherwise ->
|
| otherwise ->
|
||||||
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
|
cr & crActionPlan . apAction .~ bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
|
||||||
& crActionPlan . apStrategy .~ WatchAndWait
|
& crActionPlan . apStrategy .~ WatchAndWait
|
||||||
& crIntention . mvToPoint .~ Nothing
|
& crIntention . mvToPoint .~ Nothing
|
||||||
_ -> viewTarget w cr
|
_ -> viewTarget w cr
|
||||||
|
where
|
||||||
|
notpath = \case
|
||||||
|
Just NoAction -> False
|
||||||
|
Just PathTo {} -> False
|
||||||
|
Just AimAt {} -> False
|
||||||
|
_ -> True
|
||||||
|
|
||||||
hoverCritMv :: World -> Creature -> Creature
|
hoverCritMv :: World -> Creature -> Creature
|
||||||
hoverCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
hoverCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||||
WarningCry -> cr
|
WarningCry -> cr
|
||||||
MeleeStrike -> cr
|
CloseToMelee _ | ma <- cr ^? crActionPlan . apAction , notpath ma -> cr
|
||||||
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||||
Just p
|
Just p
|
||||||
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
||||||
cr & crActionPlan . apAction .~ [PathTo p (DoImpulses [ChangeStrategy Wander])]
|
cr & crActionPlan . apAction .~ PathTo p (DoImpulses [ChangeStrategy Wander])
|
||||||
| otherwise ->
|
| otherwise ->
|
||||||
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
|
cr & crActionPlan . apAction .~ bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
|
||||||
& crActionPlan . apStrategy .~ WatchAndWait
|
& crActionPlan . apStrategy .~ WatchAndWait
|
||||||
& crIntention . mvToPoint .~ Nothing
|
& crIntention . mvToPoint .~ Nothing
|
||||||
_ -> viewTarget w cr
|
_ -> viewTarget w cr
|
||||||
|
where
|
||||||
|
notpath = \case
|
||||||
|
Just NoAction -> False
|
||||||
|
Just PathTo {} -> False
|
||||||
|
Just AimAt {} -> False
|
||||||
|
_ -> True
|
||||||
|
|
||||||
--goToTarget :: World -> Creature -> Creature
|
--goToTarget :: World -> Creature -> Creature
|
||||||
--goToTarget w cr = case cr ^? crIntention . mvToPoint . _Just of
|
--goToTarget w cr = case cr ^? crIntention . mvToPoint . _Just of
|
||||||
@@ -173,23 +235,25 @@ viewTarget w cr = case cr ^? crIntention . viewPoint . _Just of
|
|||||||
Just p
|
Just p
|
||||||
| hasLOSIndirect p (cr ^. crPos . _xy) w ->
|
| hasLOSIndirect p (cr ^. crPos . _xy) w ->
|
||||||
cr
|
cr
|
||||||
& crActionPlan . apAction .~ [TurnToPoint p]
|
& crActionPlan . apAction .~ TurnToPoint p
|
||||||
& crIntention . viewPoint .~ Nothing
|
& crIntention . viewPoint .~ Nothing
|
||||||
& crActionPlan . apStrategy .~ Investigate
|
& crActionPlan . apStrategy .~ Investigate
|
||||||
| otherwise ->
|
| otherwise ->
|
||||||
cr & crActionPlan . apAction %~ replaceNullWith (PathTo p (DoImpulses [ChangeStrategy Wander]))
|
-- cr & crActionPlan . apAction %~ replaceNullWith (PathTo p (DoImpulses [ChangeStrategy Wander]))
|
||||||
|
cr & crActionPlan . apAction .~ PathTo p (DoImpulses [ChangeStrategy Wander])
|
||||||
& crActionPlan . apStrategy .~ Investigate
|
& crActionPlan . apStrategy .~ Investigate
|
||||||
Nothing -> cr
|
Nothing -> cr
|
||||||
|
|
||||||
replaceNullWith :: a -> [a] -> [a]
|
--replaceNullWith :: a -> [a] -> [a]
|
||||||
replaceNullWith x [] = [x]
|
--replaceNullWith x [] = [x]
|
||||||
replaceNullWith _ xs = xs
|
--replaceNullWith _ xs = xs
|
||||||
|
|
||||||
doStrategyActions :: Creature -> Creature
|
doStrategyActions :: Creature -> Creature
|
||||||
doStrategyActions cr = case cr ^? crActionPlan . apStrategy of
|
doStrategyActions cr = case cr ^? crActionPlan . apStrategy of
|
||||||
Just (StrategyActions strat acs) ->
|
Just (StrategyActions strat acs) ->
|
||||||
cr
|
cr
|
||||||
& crActionPlan . apAction .~ acs
|
-- & crActionPlan . apAction .~ acs
|
||||||
|
& crActionPlan . apAction .~ head acs
|
||||||
& crActionPlan . apStrategy .~ strat
|
& crActionPlan . apStrategy .~ strat
|
||||||
_ -> cr
|
_ -> cr
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ crShape :: CreatureType -> CreatureShape
|
|||||||
crShape = \case
|
crShape = \case
|
||||||
Avatar{} -> Humanoid (greyN 0.9) (lightx4 black) (greyN 0.3)
|
Avatar{} -> Humanoid (greyN 0.9) (lightx4 black) (greyN 0.3)
|
||||||
ChaseCrit {} -> Humanoid (greyN 0.9) (lightx4 green) (greyN 0.3)
|
ChaseCrit {} -> Humanoid (greyN 0.9) (lightx4 green) (greyN 0.3)
|
||||||
|
CrabCrit {} -> Humanoid (greyN 0.9) (lightx4 red) (greyN 0.3)
|
||||||
HoverCrit {} -> Humanoid (greyN 0.9) (light blue) (greyN 0.3)
|
HoverCrit {} -> Humanoid (greyN 0.9) (light blue) (greyN 0.3)
|
||||||
SwarmCrit -> Humanoid (greyN 0.9) (lightx4 yellow) (greyN 0.3)
|
SwarmCrit -> Humanoid (greyN 0.9) (lightx4 yellow) (greyN 0.3)
|
||||||
AutoCrit -> Humanoid (greyN 0.9) (lightx4 red) (greyN 0.3)
|
AutoCrit -> Humanoid (greyN 0.9) (lightx4 red) (greyN 0.3)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ crDexterity cr = case cr ^. crType of
|
|||||||
AutoCrit -> 46
|
AutoCrit -> 46
|
||||||
BarrelCrit {} -> 0
|
BarrelCrit {} -> 0
|
||||||
LampCrit {} -> 0
|
LampCrit {} -> 0
|
||||||
|
_ -> 46
|
||||||
|
|
||||||
crStrength :: Creature -> Int
|
crStrength :: Creature -> Int
|
||||||
crStrength cr = case cr ^. crType of
|
crStrength cr = case cr ^. crType of
|
||||||
@@ -35,11 +36,13 @@ crStrength cr = case cr ^. crType of
|
|||||||
AutoCrit -> 46
|
AutoCrit -> 46
|
||||||
BarrelCrit {} -> 0
|
BarrelCrit {} -> 0
|
||||||
LampCrit {} -> 0
|
LampCrit {} -> 0
|
||||||
|
_ -> 46
|
||||||
|
|
||||||
crIntelligence :: Creature -> Int
|
crIntelligence :: Creature -> Int
|
||||||
crIntelligence cr = case cr ^. crType of
|
crIntelligence cr = case cr ^. crType of
|
||||||
Avatar { _avIntelligence = x } -> x
|
Avatar { _avIntelligence = x } -> x
|
||||||
ChaseCrit {} -> 20
|
ChaseCrit {} -> 20
|
||||||
|
CrabCrit {} -> 20
|
||||||
HoverCrit {} -> 20
|
HoverCrit {} -> 20
|
||||||
SwarmCrit -> 20
|
SwarmCrit -> 20
|
||||||
AutoCrit -> 20
|
AutoCrit -> 20
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ updateLivingCreature cr =
|
|||||||
ChaseCrit{} -> \w ->
|
ChaseCrit{} -> \w ->
|
||||||
crUpdate cid . performActions cid $
|
crUpdate cid . performActions cid $
|
||||||
over (cWorld . lWorld . creatures . ix cid) (chaseCritInternal w) w
|
over (cWorld . lWorld . creatures . ix cid) (chaseCritInternal w) w
|
||||||
|
CrabCrit{} -> \w ->
|
||||||
|
crUpdate cid . performActions cid $
|
||||||
|
over (cWorld . lWorld . creatures . ix cid) (crabCritInternal w) w
|
||||||
AutoCrit {} -> crUpdate cid
|
AutoCrit {} -> crUpdate cid
|
||||||
SwarmCrit {} -> crUpdate cid
|
SwarmCrit {} -> crUpdate cid
|
||||||
HoverCrit {} -> \w ->
|
HoverCrit {} -> \w ->
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ crWarningSounds cr = case cr ^. crType of
|
|||||||
, seagullCry1S
|
, seagullCry1S
|
||||||
, seagullCry2S
|
, seagullCry2S
|
||||||
]
|
]
|
||||||
|
CrabCrit {} -> mempty
|
||||||
HoverCrit {} -> mempty
|
HoverCrit {} -> mempty
|
||||||
SwarmCrit -> mempty
|
SwarmCrit -> mempty
|
||||||
AutoCrit -> mempty
|
AutoCrit -> mempty
|
||||||
@@ -36,6 +37,7 @@ crDeathSounds :: Creature -> DeathType -> [SoundID]
|
|||||||
crDeathSounds cr dt = case cr ^. crType of
|
crDeathSounds cr dt = case cr ^. crType of
|
||||||
Avatar{} -> mempty
|
Avatar{} -> mempty
|
||||||
ChaseCrit{} -> defaultDeathSounds dt
|
ChaseCrit{} -> defaultDeathSounds dt
|
||||||
|
CrabCrit{} -> defaultDeathSounds dt
|
||||||
HoverCrit{} -> hoverDeathSounds dt
|
HoverCrit{} -> hoverDeathSounds dt
|
||||||
SwarmCrit -> mempty
|
SwarmCrit -> mempty
|
||||||
AutoCrit -> mempty
|
AutoCrit -> mempty
|
||||||
|
|||||||
@@ -34,5 +34,5 @@ shootFirstMiss :: Action
|
|||||||
shootFirstMiss =
|
shootFirstMiss =
|
||||||
LeadTarget (V2 30 50)
|
LeadTarget (V2 30 50)
|
||||||
`DoActionThen` DoImpulses [UseItem]
|
`DoActionThen` DoImpulses [UseItem]
|
||||||
`DoActionThen` (WdCrBlfromCrBl CrCanShoot `DoActionWhile` DoActions [LeadTarget (V2 0 0), DoImpulses [UseItem]])
|
-- `DoActionThen` (WdCrBlfromCrBl CrCanShoot `DoActionWhile` DoActions [LeadTarget (V2 0 0), DoImpulses [UseItem]])
|
||||||
`DoActionThen` 20 `WaitThen` holsterWeapon
|
`DoActionThen` 20 `WaitThen` holsterWeapon
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ data ActionPlan
|
|||||||
= Inanimate
|
= Inanimate
|
||||||
| ActionPlan
|
| ActionPlan
|
||||||
{ -- _apImpulse :: [Impulse] -- done per frame
|
{ -- _apImpulse :: [Impulse] -- done per frame
|
||||||
_apAction :: [Action] -- updated per frame, likely persist across frames
|
_apAction :: Action -- updated per frame, likely persist across frames
|
||||||
, _apStrategy :: Strategy -- current strategy
|
, _apStrategy :: Strategy -- current strategy
|
||||||
, _apGoal :: [Goal] -- particular ordered goals
|
, _apGoal :: [Goal] -- particular ordered goals
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ data ActionPlan
|
|||||||
|
|
||||||
data Impulse
|
data Impulse
|
||||||
= Move Point2
|
= Move Point2
|
||||||
|
| Walk Point2
|
||||||
| MoveForward Float
|
| MoveForward Float
|
||||||
| MoveNoStride Point2
|
| MoveNoStride Point2
|
||||||
| Turn Float
|
| Turn Float
|
||||||
@@ -68,8 +69,9 @@ data Action
|
|||||||
, _targetSeenAt :: Point2
|
, _targetSeenAt :: Point2
|
||||||
}
|
}
|
||||||
| PathTo { _pathToPoint :: Point2, _pathFailAction :: Action }
|
| PathTo { _pathToPoint :: Point2, _pathFailAction :: Action }
|
||||||
|
| EvadeAim
|
||||||
| TurnToPoint { _turnToPoint :: Point2 }
|
| TurnToPoint { _turnToPoint :: Point2 }
|
||||||
| ImpulsesList { _impulsesListList :: [[Impulse]] }
|
| ImpulsesList { _impulsesListList :: [[Impulse]], _acAction :: Action }
|
||||||
| DoImpulses { _doImpulsesList :: [Impulse] }
|
| DoImpulses { _doImpulsesList :: [Impulse] }
|
||||||
| WaitThen
|
| WaitThen
|
||||||
{ _waitThenTimer :: Int
|
{ _waitThenTimer :: Int
|
||||||
@@ -98,7 +100,7 @@ data Action
|
|||||||
, _doActionWhileThenCondition :: WdCrBl
|
, _doActionWhileThenCondition :: WdCrBl
|
||||||
, _doActionWhileThenThen :: Action
|
, _doActionWhileThenThen :: Action
|
||||||
}
|
}
|
||||||
| DoActions { _doActionsList :: [Action] }
|
-- | DoActions { _doActionsList :: [Action] }
|
||||||
| DoActionThen
|
| DoActionThen
|
||||||
{ _doActionThenFirst :: Action
|
{ _doActionThenFirst :: Action
|
||||||
, _doActionThenSecond :: Action
|
, _doActionThenSecond :: Action
|
||||||
@@ -140,9 +142,9 @@ data Strategy
|
|||||||
| CloseToMelee {_meleeTarget :: Int}
|
| CloseToMelee {_meleeTarget :: Int}
|
||||||
| StrategyActions Strategy [Action]
|
| StrategyActions Strategy [Action]
|
||||||
| GetTo Point2
|
| GetTo Point2
|
||||||
| Reload
|
-- | Reload
|
||||||
| Flee
|
| Flee
|
||||||
| MeleeStrike
|
-- | MeleeStrike
|
||||||
| Search
|
| Search
|
||||||
deriving (Eq, Ord, Show) --Generic, Flat)
|
deriving (Eq, Ord, Show) --Generic, Flat)
|
||||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|||||||
@@ -58,6 +58,13 @@ data CreatureType
|
|||||||
, _footForward :: FootForward
|
, _footForward :: FootForward
|
||||||
, _strideAmount :: Float
|
, _strideAmount :: Float
|
||||||
}
|
}
|
||||||
|
| CrabCrit
|
||||||
|
{ _meleeCooldownL :: Int
|
||||||
|
, _meleeCooldownR :: Int
|
||||||
|
, _footForward :: FootForward
|
||||||
|
, _strideAmount :: Float
|
||||||
|
, _dodgeCooldown :: Int
|
||||||
|
}
|
||||||
| HoverCrit {_meleeCooldown :: Int}
|
| HoverCrit {_meleeCooldown :: Int}
|
||||||
| SwarmCrit
|
| SwarmCrit
|
||||||
| AutoCrit
|
| AutoCrit
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ data MouseContext
|
|||||||
= NoMouseContext
|
= NoMouseContext
|
||||||
| MouseAiming
|
| MouseAiming
|
||||||
| MouseInGame
|
| MouseInGame
|
||||||
| MouseMenuClick {_mcoMenuClick :: Int}
|
| MouseMenu {_mcoMenuClick :: Maybe Int}
|
||||||
| MouseMenuCursor
|
|
||||||
| OverInvDrag {_mcoDragSection :: Int , _mcoMaybeSelect :: Maybe (Int,Int) }
|
| OverInvDrag {_mcoDragSection :: Int , _mcoMaybeSelect :: Maybe (Int,Int) }
|
||||||
| OverInvDragSelect { _mcoSecSelStart :: Maybe (Int,Int), _mcoSelEnd :: Maybe Int }
|
| OverInvDragSelect { _mcoSecSelStart :: Maybe (Int,Int), _mcoSelEnd :: Maybe Int }
|
||||||
| OverInvSelect { _mcoInvSelect :: (Int,Int)}
|
| OverInvSelect { _mcoInvSelect :: (Int,Int)}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ defaultCreature =
|
|||||||
, _posture = AtEase
|
, _posture = AtEase
|
||||||
}
|
}
|
||||||
, _crVocalization = VocReady
|
, _crVocalization = VocReady
|
||||||
, _crActionPlan = ActionPlan [] (StrategyActions WatchAndWait [StartSentinelPost]) [LiveLongAndProsper]
|
, _crActionPlan = ActionPlan NoAction (StrategyActions WatchAndWait [StartSentinelPost]) [LiveLongAndProsper]
|
||||||
, _crPerception = defaultPerceptionState
|
, _crPerception = defaultPerceptionState
|
||||||
, _crMemory = defaultCreatureMemory
|
, _crMemory = defaultCreatureMemory
|
||||||
, _crFaction = NoFaction
|
, _crFaction = NoFaction
|
||||||
|
|||||||
+18
-2
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.Humanoid (
|
module Dodge.Humanoid (
|
||||||
chaseCritInternal,
|
chaseCritInternal,
|
||||||
|
crabCritInternal,
|
||||||
hoverCritInternal,
|
hoverCritInternal,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ chaseCritInternal w cr =
|
|||||||
[ const doStrategyActions
|
[ const doStrategyActions
|
||||||
, overrideMeleeCloseTarget
|
, overrideMeleeCloseTarget
|
||||||
, setViewPos
|
, setViewPos
|
||||||
, setMvPos
|
, setMvPosToTargetCr
|
||||||
, chaseCritMv
|
, chaseCritMv
|
||||||
, perceptionUpdate [0]
|
, perceptionUpdate [0]
|
||||||
, targetYouWhenCognizant
|
, targetYouWhenCognizant
|
||||||
@@ -25,6 +26,21 @@ chaseCritInternal w cr =
|
|||||||
, const (crVocalization %~ updateVocTimer)
|
, const (crVocalization %~ updateVocTimer)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
crabCritInternal :: World -> Creature -> Creature
|
||||||
|
crabCritInternal w =
|
||||||
|
(crVocalization %~ updateVocTimer)
|
||||||
|
. (crType . meleeCooldownL %~ max 0 . subtract 1)
|
||||||
|
. (crType . meleeCooldownR %~ max 0 . subtract 1)
|
||||||
|
. (crType . dodgeCooldown %~ max 0 . subtract 1)
|
||||||
|
. searchIfDamaged
|
||||||
|
. targetYouWhenCognizant w
|
||||||
|
. perceptionUpdate [0] w
|
||||||
|
. crabCritMv w
|
||||||
|
. setMvPosToTargetCr w
|
||||||
|
. setViewPos w
|
||||||
|
-- . overrideMeleeCloseTarget w
|
||||||
|
. doStrategyActions
|
||||||
|
|
||||||
hoverCritInternal :: World -> Creature -> Creature
|
hoverCritInternal :: World -> Creature -> Creature
|
||||||
hoverCritInternal w cr =
|
hoverCritInternal w cr =
|
||||||
foldl'
|
foldl'
|
||||||
@@ -33,7 +49,7 @@ hoverCritInternal w cr =
|
|||||||
[ const doStrategyActions
|
[ const doStrategyActions
|
||||||
, overrideMeleeCloseTarget
|
, overrideMeleeCloseTarget
|
||||||
, setViewPos
|
, setViewPos
|
||||||
, setMvPos
|
, setMvPosToTargetCr
|
||||||
, hoverCritMv
|
, hoverCritMv
|
||||||
, perceptionUpdate [0]
|
, perceptionUpdate [0]
|
||||||
, targetYouWhenCognizant
|
, targetYouWhenCognizant
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ secondColumnLDP = defaultLDP & ldpPos . spPixelOff .~ V2 subInvX (-20)
|
|||||||
terminalLDP :: LDParams
|
terminalLDP :: LDParams
|
||||||
terminalLDP = secondColumnLDP & ldpSize ?~ V2 50 16
|
terminalLDP = secondColumnLDP & ldpSize ?~ V2 50 16
|
||||||
& ldpPos . spScreenOff .~ V2 0.5 0.5
|
& ldpPos . spScreenOff .~ V2 0.5 0.5
|
||||||
& ldpPos . spPixelOff .~ V2 (-250) (-40)
|
& ldpPos . spPixelOff .~ V2 (-250) 200
|
||||||
|
|
||||||
subInvX :: Float
|
subInvX :: Float
|
||||||
subInvX = 10 * fromIntegral topInvW + 170
|
subInvX = 10 * fromIntegral topInvW + 170
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
module Dodge.Placement.Instance.Creature where
|
module Dodge.Placement.Instance.Creature where
|
||||||
|
|
||||||
import Dodge.Creature.ArmourChase
|
--import Dodge.Creature.ArmourChase
|
||||||
import Dodge.Creature.ChaseCrit
|
import Dodge.Creature.ChaseCrit
|
||||||
import Dodge.Data.GenWorld
|
import Dodge.Data.GenWorld
|
||||||
import RandomHelp
|
import RandomHelp
|
||||||
|
|
||||||
randC1 :: PSType
|
randC1 :: PSType
|
||||||
randC1 = RandPS $ takeOne $ map PutCrit $ armourChaseCrit : replicate 50 hoverCrit
|
randC1 = RandPS $ takeOne $ map PutCrit [hoverCrit,chaseCrit]
|
||||||
--randC1 = RandPS $ takeOne $ map PutCrit [hoverCrit]
|
--randC1 = RandPS $ takeOne $ map PutCrit [hoverCrit]
|
||||||
|
|||||||
+11
-4
@@ -372,10 +372,16 @@ drawTerminalDisplay w cfig tid = fold $ do
|
|||||||
TerminalLineRead -> (++ [(spincurs, termTextColor)])
|
TerminalLineRead -> (++ [(spincurs, termTextColor)])
|
||||||
TerminalTextInput s -> (++ [(getPromptTM ++ s ++ [cFilledRect], white)])
|
TerminalTextInput s -> (++ [(getPromptTM ++ s ++ [cFilledRect], white)])
|
||||||
TerminalPressTo s -> (++ [(s, white)])
|
TerminalPressTo s -> (++ [(s, white)])
|
||||||
return $
|
return . (each . vxPos . _z -~ 0.05) $
|
||||||
|
drawTerminalCursorLink w cfig tm
|
||||||
|
<> (
|
||||||
drawSelectionList (w ^. tmLDP) cfig f
|
drawSelectionList (w ^. tmLDP) cfig f
|
||||||
<> drawTerminalCursorLink w cfig tm
|
<> (hackInvertText black white ("TERMINAL-" ++ show tid)
|
||||||
|
& each . vxPos *~ 0.1
|
||||||
|
& each . vxPos . _xy +~ rp)
|
||||||
|
& each . vxPos . _z -~ 0.05)
|
||||||
where
|
where
|
||||||
|
rp = screenPosAbs cfig (w ^. tmLDP . ldpPos)
|
||||||
-- <> invHead cfig ("TERMINAL-" ++ show tid)
|
-- <> invHead cfig ("TERMINAL-" ++ show tid)
|
||||||
-- <> color
|
-- <> color
|
||||||
-- (withAlpha 0.5 green) -- consider integrating termScreenColor somehow
|
-- (withAlpha 0.5 green) -- consider integrating termScreenColor somehow
|
||||||
@@ -391,7 +397,7 @@ drawTerminalCursorLink :: World -> Config -> Terminal -> Picture
|
|||||||
drawTerminalCursorLink w cfig tm = fold $ do
|
drawTerminalCursorLink w cfig tm = fold $ do
|
||||||
j <- elemIndex (tm ^. tmButtonID) $ w ^. hud . closeButtons
|
j <- elemIndex (tm ^. tmButtonID) $ w ^. hud . closeButtons
|
||||||
lp <- selNumPos cfig invDP (w ^. hud . diSections) 5 j
|
lp <- selNumPos cfig invDP (w ^. hud . diSections) 5 j
|
||||||
let rp = screenPosAbs cfig (secondColumnLDP ^. ldpPos) - V2 5 10
|
let rp = screenPosAbs cfig (w ^. tmLDP . ldpPos)
|
||||||
lcol <- selSecSelCol 5 j (w ^. hud . diSections)
|
lcol <- selSecSelCol 5 j (w ^. hud . diSections)
|
||||||
return $
|
return $
|
||||||
translateScreenPos
|
translateScreenPos
|
||||||
@@ -403,7 +409,8 @@ drawTerminalCursorLink w cfig tm = fold $ do
|
|||||||
(w ^. hud . diSections)
|
(w ^. hud . diSections)
|
||||||
(Sel 5 j mempty)
|
(Sel 5 j mempty)
|
||||||
)
|
)
|
||||||
<> lConnectCol (lp + V2 155 0) rp lcol white white
|
<>
|
||||||
|
lConnectCol (lp + V2 155 0) rp lcol white white
|
||||||
|
|
||||||
lnkMidPosInvSelsCol :: Config -> World -> Int -> Color -> [Int] -> Picture
|
lnkMidPosInvSelsCol :: Config -> World -> Int -> Color -> [Int] -> Picture
|
||||||
lnkMidPosInvSelsCol cfig w i col = fromMaybe mempty . foldMap f
|
lnkMidPosInvSelsCol cfig w i col = fromMaybe mempty . foldMap f
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ drawSelectionList ldps cfig sl =
|
|||||||
(drawListYgapScaleYoff ygap sf 0 (makeSelectionListPictures sl))
|
(drawListYgapScaleYoff ygap sf 0 (makeSelectionListPictures sl))
|
||||||
<> foldMap (g . f) (ldpRect cfig ldps)
|
<> foldMap (g . f) (ldpRect cfig ldps)
|
||||||
where
|
where
|
||||||
g xs = color white (polygonWire xs) <> setDepth 0.5 (polygon xs)
|
g xs = color white (polygonWire xs) <> setDepth 0.05 (polygon xs)
|
||||||
ygap = ldps ^. ldpVerticalGap
|
ygap = ldps ^. ldpVerticalGap
|
||||||
sf = ldps ^. ldpScale
|
sf = ldps ^. ldpScale
|
||||||
f (V2 xmin ymax, V2 xmax ymin) = rectNSWE ymax ymin xmin xmax
|
f (V2 xmin ymax, V2 xmax ymin) = rectNSWE ymax ymin xmin xmax
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
module Dodge.Render.Picture (fixedCoordPictures) where
|
module Dodge.Render.Picture (fixedCoordPictures) where
|
||||||
|
|
||||||
|
import Linear hiding (rotate)
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
@@ -14,7 +15,6 @@ import Dodge.Render.List
|
|||||||
import Dodge.Render.MenuScreen
|
import Dodge.Render.MenuScreen
|
||||||
import Geometry
|
import Geometry
|
||||||
import HelpNum
|
import HelpNum
|
||||||
import Linear (_xy)
|
|
||||||
import Picture
|
import Picture
|
||||||
|
|
||||||
fixedCoordPictures :: Universe -> Picture
|
fixedCoordPictures :: Universe -> Picture
|
||||||
@@ -67,7 +67,7 @@ fpsText x = scale 0.2 0.2 . color col . text $ "ms/frame " ++ show x
|
|||||||
drawMenuOrHUD :: Config -> Universe -> Picture
|
drawMenuOrHUD :: Config -> Universe -> Picture
|
||||||
drawMenuOrHUD cf u = case u ^. uvScreenLayers of
|
drawMenuOrHUD cf u = case u ^. uvScreenLayers of
|
||||||
[] -> drawHUD (u ^. uvConfig) (u ^. uvWorld)
|
[] -> drawHUD (u ^. uvConfig) (u ^. uvWorld)
|
||||||
(x : _) -> drawMenuScreen (u ^? uvWorld . input . mouseContext . mcoMenuClick) x cf
|
(x : _) -> drawMenuScreen (u ^? uvWorld . input . mouseContext . mcoMenuClick . _Just) x cf
|
||||||
|
|
||||||
drawConcurrentMessage :: Universe -> Picture
|
drawConcurrentMessage :: Universe -> Picture
|
||||||
drawConcurrentMessage u =
|
drawConcurrentMessage u =
|
||||||
@@ -83,16 +83,17 @@ drawConcurrentMessage u =
|
|||||||
drawMouseCursor :: Universe -> Picture
|
drawMouseCursor :: Universe -> Picture
|
||||||
drawMouseCursor u =
|
drawMouseCursor u =
|
||||||
uncurryV translate (u ^. uvWorld . input . mousePos)
|
uncurryV translate (u ^. uvWorld . input . mousePos)
|
||||||
. color white
|
. (each . vxCol . _xyz +~ 1)
|
||||||
. setDepth (-1)
|
. (each . vxPos . _z -~ 1)
|
||||||
$ mouseCursorType u
|
$ mouseCursorType u
|
||||||
|
|
||||||
mouseCursorType :: Universe -> Picture
|
mouseCursorType :: Universe -> Picture
|
||||||
mouseCursorType u = case u ^. uvWorld . input . mouseContext of
|
mouseCursorType u = case u ^. uvWorld . input . mouseContext of
|
||||||
NoMouseContext -> drawEmptySet 5
|
NoMouseContext -> drawEmptySet 5
|
||||||
MouseAiming -> rotate a (drawPlus 5)
|
MouseAiming -> rotate a (drawPlus 5)
|
||||||
MouseMenuClick{} -> drawMenuClick 5
|
MouseMenu Nothing -> drawMenuCursor 5
|
||||||
MouseMenuCursor -> drawMenuCursor 5
|
MouseMenu{} -> drawMenuClick 5
|
||||||
|
-- MouseMenuCursor -> drawMenuCursor 5
|
||||||
MouseInGame -> drawPlus 5
|
MouseInGame -> drawPlus 5
|
||||||
OverInvDrag 0 (Just (3, _)) -> drawDragDrop 5
|
OverInvDrag 0 (Just (3, _)) -> drawDragDrop 5
|
||||||
OverInvDrag 0 Nothing -> drawDragDrop 5
|
OverInvDrag 0 Nothing -> drawDragDrop 5
|
||||||
@@ -194,7 +195,11 @@ drawJumpDown x =
|
|||||||
rotate (0.25 * pi) $ line [V2 x 0, V2 0 0, V2 0 x]
|
rotate (0.25 * pi) $ line [V2 x 0, V2 0 0, V2 0 x]
|
||||||
|
|
||||||
drawDragSelect :: Float -> Picture
|
drawDragSelect :: Float -> Picture
|
||||||
drawDragSelect x = polygonWire $ rectWH (0.5 * x) x
|
drawDragSelect x = polygonWire (rectWH (0.5 * x) x)
|
||||||
|
<> (polygon (rectWH (0.5*x) x)
|
||||||
|
& each . vxCol . _xyz -~ 1
|
||||||
|
& each . vxPos . _z +~ 0.05
|
||||||
|
)
|
||||||
|
|
||||||
drawDrag :: Float -> Picture
|
drawDrag :: Float -> Picture
|
||||||
drawDrag x =
|
drawDrag x =
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ drawCreature w m cr = translateSP (_crPos cr) . rotateSP (_crDir cr) $
|
|||||||
Avatar {} -> basicCrPict m cr
|
Avatar {} -> basicCrPict m cr
|
||||||
SwarmCrit -> basicCrPict m cr
|
SwarmCrit -> basicCrPict m cr
|
||||||
AutoCrit -> basicCrPict m cr
|
AutoCrit -> basicCrPict m cr
|
||||||
|
CrabCrit {} -> noPic $ drawCrabCrit w cr
|
||||||
HoverCrit{} -> noPic $ drawHoverCrit cr
|
HoverCrit{} -> noPic $ drawHoverCrit cr
|
||||||
|
|
||||||
barrelShape :: SPic
|
barrelShape :: SPic
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
module Dodge.Room.Tutorial where
|
module Dodge.Room.Tutorial where
|
||||||
|
|
||||||
|
import Dodge.Item.Held.Stick
|
||||||
import Dodge.Creature.ChaseCrit
|
import Dodge.Creature.ChaseCrit
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
@@ -57,7 +58,10 @@ tutAnoTree = do
|
|||||||
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
||||||
, corDoor
|
, corDoor
|
||||||
, chasmSpitTerminal
|
, chasmSpitTerminal
|
||||||
-- , loadAmmoTut
|
, corDoor
|
||||||
|
, loadAmmoTut
|
||||||
|
, corDoor
|
||||||
|
, chasmSpitTerminal
|
||||||
--b , corDoor
|
--b , corDoor
|
||||||
--b , tToBTree "slowCrush" . return . cleatOnward <$> pushCaverns
|
--b , tToBTree "slowCrush" . return . cleatOnward <$> pushCaverns
|
||||||
--b , corDoor
|
--b , corDoor
|
||||||
@@ -339,10 +343,10 @@ chasmSpitTerminal = do
|
|||||||
tToBTree "chasmTerm" $
|
tToBTree "chasmTerm" $
|
||||||
Node
|
Node
|
||||||
(addDoorToggleTerminal' i1 (PS 150 0) y')
|
(addDoorToggleTerminal' i1 (PS 150 0) y')
|
||||||
[ treePost [triggerDoorRoom i1, deadEndPSType (PutCrit chaseCrit)]
|
[ treePost [triggerDoorRoom i1, deadEndPSType (PutCrit crabCrit)]
|
||||||
--[ treePost [triggerDoorRoom i1, deadEndPSType (PutCrit hoverCrit)]
|
--[ treePost [triggerDoorRoom i1, deadEndPSType (PutCrit hoverCrit)]
|
||||||
--[ treePost [triggerDoorRoom i1, deadEndRoom]
|
--[ treePost [triggerDoorRoom i1, deadEndRoom]
|
||||||
, treePost [triggerDoorRoom i1, deadEndPSType (PutCrit chaseCrit)]
|
, treePost [triggerDoorRoom i1, deadEndPSType (PutCrit crabCrit)]
|
||||||
, return $ cleatOnward $ triggerDoorRoom i1
|
, return $ cleatOnward $ triggerDoorRoom i1
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
@@ -426,6 +430,10 @@ tutLight = do
|
|||||||
)
|
)
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
|
crabRoom :: State LayoutVars Room
|
||||||
|
crabRoom = (putSingleLight =<< roomNgon 6 150)
|
||||||
|
<&> rmPmnts .:~ psPtPl (PS 100 0) (PutCrit crabCrit)
|
||||||
|
|
||||||
loadAmmoTut :: State LayoutVars (MetaTree Room String)
|
loadAmmoTut :: State LayoutVars (MetaTree Room String)
|
||||||
loadAmmoTut = do
|
loadAmmoTut = do
|
||||||
i <- nextLayoutInt
|
i <- nextLayoutInt
|
||||||
@@ -444,8 +452,8 @@ loadAmmoTut = do
|
|||||||
=<< join (takeOne [roomNgon 6 80, roomRectAutoLights 100 100])
|
=<< join (takeOne [roomNgon 6 80, roomRectAutoLights 100 100])
|
||||||
-- =<< join (takeOne [roomNgon 6 80])
|
-- =<< join (takeOne [roomNgon 6 80])
|
||||||
droom <- distributerRoom BulletAmmo (10 ^ (4::Int))
|
droom <- distributerRoom BulletAmmo (10 ^ (4::Int))
|
||||||
ncrits <- takeOne [1,1,2,2,2,3]
|
croom <- crabRoom
|
||||||
croom <- roomCCrits ncrits
|
wep <- takeOne [burstRifle,smg]
|
||||||
return $
|
return $
|
||||||
tToBTree "loadAmmoTest" $
|
tToBTree "loadAmmoTest" $
|
||||||
treePost
|
treePost
|
||||||
@@ -453,7 +461,7 @@ loadAmmoTut = do
|
|||||||
, door
|
, door
|
||||||
, amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
|
, amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
|
||||||
, triggerDoorRoom i
|
, triggerDoorRoom i
|
||||||
, wprm & rmPmnts .:~ sps (PS 50 0) (PutFlIt burstRifle)
|
, wprm & rmPmnts .:~ sps (PS 50 0) (PutFlIt wep)
|
||||||
, triggerDoorRoom j
|
, triggerDoorRoom j
|
||||||
, droom
|
, droom
|
||||||
, door
|
, door
|
||||||
@@ -479,11 +487,13 @@ putSingleLight rm = do
|
|||||||
, (V2 0 y', V2 x y')
|
, (V2 0 y', V2 x y')
|
||||||
]
|
]
|
||||||
return $ rmPmnts .:~ uncurry spanLightI ps
|
return $ rmPmnts .:~ uncurry spanLightI ps
|
||||||
RoomNgon{_rmngonSize = x} -> do
|
RoomNgon{} -> do
|
||||||
y <- takeOne [21, -21]
|
let p = rm ^?! rmPolys . ix 0 . ix 0
|
||||||
return $ rmPmnts .:~ spanLightI (V2 (-x) y) (V2 x y)
|
return $ rmPmnts .:~ spanLightI p (-p)
|
||||||
return . f $ removeLights rm
|
return . f $ removeLights rm
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tutHub :: State LayoutVars (MetaTree Room String)
|
tutHub :: State LayoutVars (MetaTree Room String)
|
||||||
tutHub = do
|
tutHub = do
|
||||||
(is, wbp) <- setTreeInts =<< critsRoom 1
|
(is, wbp) <- setTreeInts =<< critsRoom 1
|
||||||
|
|||||||
@@ -190,16 +190,24 @@ inverseSelSecYint yint sss
|
|||||||
return $ NonInf (i, j)
|
return $ NonInf (i, j)
|
||||||
|
|
||||||
inverseSelSecYintXPosCheck ::
|
inverseSelSecYintXPosCheck ::
|
||||||
Config -> LDParams -> Float -> Int -> IMSS a -> Maybe (Int, Int)
|
Config -> LDParams -> Float -> Int -> IMSS a -> Maybe (XInfinity (Int, Int))
|
||||||
inverseSelSecYintXPosCheck cfig ldp x yint sss = do
|
inverseSelSecYintXPosCheck cfig ldp x yint sss = do
|
||||||
(i, j) <- inverseSelSecYint yint sss ^? nonInf
|
let sel = inverseSelSecYint yint sss
|
||||||
|
(i,j) <- case sel of
|
||||||
|
NonInf v -> Just v
|
||||||
|
NegInf -> do
|
||||||
|
(i',j',_) <- ssLookupMin sss
|
||||||
|
return (i',j')
|
||||||
|
PosInf -> do
|
||||||
|
(i',j',_) <- ssLookupMax sss
|
||||||
|
return (i',j')
|
||||||
let V2 x0 _ = screenPosAbs cfig (ldp ^. ldpPos)
|
let V2 x0 _ = screenPosAbs cfig (ldp ^. ldpPos)
|
||||||
sindent <- sss ^? ix i . ssIndent
|
sindent <- sss ^? ix i . ssIndent
|
||||||
itindent <- sss ^? ix i . ssItems . ix j . siOffX
|
itindent <- sss ^? ix i . ssItems . ix j . siOffX
|
||||||
let x1 = x0 + _ldpScale ldp * 10 * (fromIntegral (sindent + itindent) - 0.5)
|
let x1 = x0 + _ldpScale ldp * 10 * (fromIntegral (sindent + itindent) - 0.5)
|
||||||
guard $ x - x1 < 160 && x > x1
|
guard $ x - x1 < 160 && x > x1
|
||||||
return (i, j)
|
return sel
|
||||||
|
|
||||||
inverseSelNumPos :: Config -> LDParams -> Point2 -> IMSS a -> Maybe (Int, Int)
|
inverseSelNumPos :: Config -> LDParams -> Point2 -> IMSS a -> Maybe (XInfinity (Int, Int))
|
||||||
inverseSelNumPos cfig ldp (V2 x y) =
|
inverseSelNumPos cfig ldp (V2 x y) =
|
||||||
inverseSelSecYintXPosCheck cfig ldp x (posSelSecYint cfig ldp y)
|
inverseSelSecYintXPosCheck cfig ldp x (posSelSecYint cfig ldp y)
|
||||||
|
|||||||
@@ -41,9 +41,8 @@ tocrs :: (IM.IntMap Creature
|
|||||||
tocrs = uvWorld . cWorld . lWorld . creatures
|
tocrs = uvWorld . cWorld . lWorld . creatures
|
||||||
|
|
||||||
testStringInit :: Universe -> [String]
|
testStringInit :: Universe -> [String]
|
||||||
testStringInit u = u ^.. tocrs . each . crStance . carriage . to show
|
testStringInit u = u ^.. tocrs . ix 1 . crActionPlan . apStrategy . to show
|
||||||
<> u ^.. tocrs . each . crPos . _z . to show
|
<> u ^.. tocrs . ix 1 . crActionPlan . apAction . to show
|
||||||
|
|
||||||
-- where
|
-- where
|
||||||
-- tocr = uvWorld . cWorld . lWorld . creatures . ix 0
|
-- tocr = uvWorld . cWorld . lWorld . creatures . ix 0
|
||||||
-- f = fromMaybe 0
|
-- f = fromMaybe 0
|
||||||
|
|||||||
+6
-5
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
module Dodge.Update (updateUniverse) where
|
module Dodge.Update (updateUniverse) where
|
||||||
|
|
||||||
|
import Dodge.Data.CardinalPoint
|
||||||
import Dodge.Data.ScreenPos
|
import Dodge.Data.ScreenPos
|
||||||
import Bound
|
import Bound
|
||||||
import Color
|
import Color
|
||||||
@@ -409,7 +410,7 @@ updateMouseContext cfig u = case u ^? uvScreenLayers . ix 0 of
|
|||||||
|
|
||||||
updateMouseContextGame :: Config -> Universe -> MouseContext -> MouseContext
|
updateMouseContextGame :: Config -> Universe -> MouseContext -> MouseContext
|
||||||
updateMouseContextGame cfig u = \case
|
updateMouseContextGame cfig u = \case
|
||||||
OverInvDrag i _ -> OverInvDrag i (inverseSelNumPos cfig invDP mpos disss)
|
OverInvDrag i _ -> OverInvDrag i (inverseSelNumPos cfig invDP mpos disss ^? _Just . nonInf)
|
||||||
x@OverInvDragSelect{} -> x
|
x@OverInvDragSelect{} -> x
|
||||||
MouseGameRotate x
|
MouseGameRotate x
|
||||||
| ButtonRight `M.member` (w ^. input . mouseButtons) -> MouseGameRotate x
|
| ButtonRight `M.member` (w ^. input . mouseButtons) -> MouseGameRotate x
|
||||||
@@ -424,7 +425,7 @@ updateMouseContextGame cfig u = \case
|
|||||||
mpos = w ^. input . mousePos
|
mpos = w ^. input . mousePos
|
||||||
disss = w ^. hud . diSections
|
disss = w ^. hud . diSections
|
||||||
overinv = do
|
overinv = do
|
||||||
selpos@(i, j) <- inverseSelNumPos cfig invDP mpos disss
|
selpos@(i, j) <- inverseSelNumPos cfig invDP mpos disss ^? _Just . nonInf
|
||||||
case w ^? hud . subInventory . ciSelection of
|
case w ^? hud . subInventory . ciSelection of
|
||||||
Just _ | i == 0 -> return $ OverCombFiltInv selpos
|
Just _ | i == 0 -> return $ OverCombFiltInv selpos
|
||||||
Just _ -> Nothing
|
Just _ -> Nothing
|
||||||
@@ -436,7 +437,7 @@ updateMouseContextGame cfig u = \case
|
|||||||
sss <- w ^? hud . subInventory . ciSections
|
sss <- w ^? hud . subInventory . ciSections
|
||||||
Sel xl xr _ <- w ^? hud . subInventory . ciSelection . _Just
|
Sel xl xr _ <- w ^? hud . subInventory . ciSelection . _Just
|
||||||
let msel = (xl, xr)
|
let msel = (xl, xr)
|
||||||
let mpossel = inverseSelNumPos cfig secondColumnLDP (w ^. input . mousePos) sss
|
let mpossel = inverseSelNumPos cfig secondColumnLDP (w ^. input . mousePos) sss ^? _Just . nonInf
|
||||||
return $ case mpossel of
|
return $ case mpossel of
|
||||||
Nothing -> OverCombEscape
|
Nothing -> OverCombEscape
|
||||||
Just (-1, i) | (-1, i) == msel -> OverCombFilter
|
Just (-1, i) | (-1, i) == msel -> OverCombFilter
|
||||||
@@ -471,10 +472,10 @@ getDebugMouseOver u = fromMaybe MouseInGame $ do
|
|||||||
getMenuMouseContext :: ScreenLayer -> Universe -> MouseContext
|
getMenuMouseContext :: ScreenLayer -> Universe -> MouseContext
|
||||||
getMenuMouseContext screen u = case screen ^. scOptions of
|
getMenuMouseContext screen u = case screen ^. scOptions of
|
||||||
[] -> NoMouseContext
|
[] -> NoMouseContext
|
||||||
_ -> fromMaybe MouseMenuCursor $ do
|
_ -> fromMaybe (MouseMenu Nothing) $ do
|
||||||
yi <- ldpSelection (u ^. uvConfig) menuLDP (u ^. uvWorld . input . mousePos)
|
yi <- ldpSelection (u ^. uvConfig) menuLDP (u ^. uvWorld . input . mousePos)
|
||||||
t <- screen ^? scSelectionList . ix yi . siIsSelectable
|
t <- screen ^? scSelectionList . ix yi . siIsSelectable
|
||||||
return $ if t then MouseMenuClick yi else NoMouseContext
|
return $ if t then MouseMenu (Just yi) else NoMouseContext
|
||||||
|
|
||||||
updateWheelEvents :: World -> World
|
updateWheelEvents :: World -> World
|
||||||
updateWheelEvents w = case w ^. input . scrollAmount of
|
updateWheelEvents w = case w ^. input . scrollAmount of
|
||||||
|
|||||||
@@ -104,13 +104,18 @@ updateMouseHeldInGame cfig w = case w ^. input . mouseContext of
|
|||||||
w & input . mouseContext .~ MouseGameRotate (dist (mouseWorldPosW w) (w ^. wCam . camCenter))
|
w & input . mouseContext .~ MouseGameRotate (dist (mouseWorldPosW w) (w ^. wCam . camCenter))
|
||||||
OverInvDragSelect (Just sstart) _ ->
|
OverInvDragSelect (Just sstart) _ ->
|
||||||
let sss = w ^. hud . diSections
|
let sss = w ^. hud . diSections
|
||||||
msel = inverseSelNumPos cfig invDP (w ^. input . mousePos) sss
|
in case inverseSelNumPos cfig invDP (w ^. input . mousePos) sss of
|
||||||
in case msel of
|
|
||||||
Nothing -> w & input . mouseContext . mcoSelEnd .~ Nothing
|
Nothing -> w & input . mouseContext . mcoSelEnd .~ Nothing
|
||||||
Just (i, j)
|
Just (NonInf (i, j))
|
||||||
| i == fst sstart -> w & input . mouseContext . mcoSelEnd ?~ j
|
| i == fst sstart -> w & input . mouseContext . mcoSelEnd ?~ j
|
||||||
| i < fst sstart -> w & input . mouseContext . mcoSelEnd ?~ 0
|
| i < fst sstart -> w & input . mouseContext . mcoSelEnd ?~ 0
|
||||||
| otherwise ->
|
| otherwise -> w
|
||||||
|
& input . mouseContext . mcoSelEnd
|
||||||
|
.~ fmap
|
||||||
|
fst
|
||||||
|
(IM.lookupMax =<< sss ^? ix (fst sstart) . ssItems)
|
||||||
|
Just NegInf -> w & input . mouseContext . mcoSelEnd ?~ 0
|
||||||
|
Just PosInf ->
|
||||||
w & input . mouseContext . mcoSelEnd
|
w & input . mouseContext . mcoSelEnd
|
||||||
.~ fmap
|
.~ fmap
|
||||||
fst
|
fst
|
||||||
@@ -136,21 +141,16 @@ setPixelOffsetBounded cfig (V2 x y) ldp = ldp & ldpPos . spPixelOff .~ V2 x' y'
|
|||||||
w = fromIntegral $ cfig ^. windowX
|
w = fromIntegral $ cfig ^. windowX
|
||||||
x' = min (w - (w*a + 1+10*ldp ^?! ldpSize . _Just . _x . to fromIntegral))
|
x' = min (w - (w*a + 1+10*ldp ^?! ldpSize . _Just . _x . to fromIntegral))
|
||||||
$ max (1 - w * a) x
|
$ max (1 - w * a) x
|
||||||
y' = min (h-(h*b + 40))
|
y' = min (h-(h*b + 20))
|
||||||
$ max (1+20*(ldp^.ldpVerticalGap + ldp^?!ldpSize._Just._y.to fromIntegral)-h*b) y
|
$ max (1+20*(ldp^.ldpVerticalGap + ldp^?!ldpSize._Just._y.to fromIntegral)-h*b) y
|
||||||
V2 a b = ldp ^. ldpPos . spScreenOff
|
V2 a b = ldp ^. ldpPos . spScreenOff
|
||||||
|
|
||||||
--leftHeldPosShift :: World -> Point2
|
|
||||||
--leftHeldPosShift w = fromMaybe 0 $ do
|
|
||||||
-- p <- w ^? input . heldPos . ix SDL.ButtonLeft
|
|
||||||
-- return $ w ^. input . mousePos - p
|
|
||||||
|
|
||||||
doDrag :: Config -> Int -> Int -> Maybe (Int, Int) -> World -> World
|
doDrag :: Config -> Int -> Int -> Maybe (Int, Int) -> World -> World
|
||||||
doDrag cfig n k mmouseover w = fromMaybe w $ do
|
doDrag cfig n k mmouseover w = fromMaybe w $ do
|
||||||
guard (n /= 0)
|
guard (n /= 0)
|
||||||
ss <- w ^? hud . diSections . ix k . ssItems
|
ss <- w ^? hud . diSections . ix k . ssItems
|
||||||
x <- mmouseover
|
x <- mmouseover
|
||||||
is <- w ^? hud . diSelection . _Just . slSet
|
is <- selectionSet w
|
||||||
return $
|
return $
|
||||||
if concurrentIS is
|
if concurrentIS is
|
||||||
then shiftInvItems cfig n k x is ss w
|
then shiftInvItems cfig n k x is ss w
|
||||||
@@ -160,26 +160,40 @@ tryDropSelected :: Maybe (Int, Int) -> World -> Maybe World
|
|||||||
tryDropSelected mpos w = do
|
tryDropSelected mpos w = do
|
||||||
guard $ maybe True (\(i, _) -> i == 3) mpos
|
guard $ maybe True (\(i, _) -> i == 3) mpos
|
||||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||||
Sel 0 _ xs <- w ^? hud . diSelection . _Just
|
0 <- w ^? hud . diSelection . _Just . slSec
|
||||||
return . foldl' (flip $ dropItem cr) w . IS.toDescList $ xs
|
j <- w ^? hud . diSelection . _Just . slInt
|
||||||
|
xs <- selectionSet w
|
||||||
|
let xmin = IS.findMin xs
|
||||||
|
return
|
||||||
|
. (hud . diSelection ?~ Sel 3 (j-xmin) (IS.fromDistinctAscList [0..IS.size xs - 1]))
|
||||||
|
. foldl' (flip $ dropItem cr) w . IS.toDescList $ xs
|
||||||
|
|
||||||
|
selectionSet :: World -> Maybe IS.IntSet
|
||||||
|
selectionSet w = case w ^? hud . diSelection . _Just . slSet of
|
||||||
|
Just is' | not $ IS.null is' -> Just is'
|
||||||
|
_ -> IS.singleton <$> w ^? hud . diSelection . _Just . slInt
|
||||||
|
|
||||||
|
|
||||||
tryPickupSelected :: Int -> Maybe (Int, Int) -> World -> Maybe World
|
tryPickupSelected :: Int -> Maybe (Int, Int) -> World -> Maybe World
|
||||||
tryPickupSelected k mpos w = do
|
tryPickupSelected k mpos w = do
|
||||||
guard $ k == 3
|
guard $ k == 3
|
||||||
guard $ maybe True (\(i, _) -> i == 0 || i == 1) mpos
|
guard $ maybe True (\(i, _) -> i == 0 || i == 1) mpos
|
||||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||||
xs <- w ^? hud . diSelection . _Just . slSet
|
xs <- selectionSet w
|
||||||
|
sli <- w ^? hud . diSelection . _Just . slInt
|
||||||
|
let xmin = IS.findMin xs
|
||||||
|
joff = sli - xmin
|
||||||
let nfreeslots = crNumFreeSlots (w ^. cWorld . lWorld . items) cr
|
let nfreeslots = crNumFreeSlots (w ^. cWorld . lWorld . items) cr
|
||||||
itmstopickup = mapMaybe g $ IS.toList xs
|
itmstopickup = mapMaybe g $ IS.toList xs
|
||||||
slotsneeded = alaf Sum foldMap itInvHeight itmstopickup
|
slotsneeded = alaf Sum foldMap itInvHeight itmstopickup
|
||||||
ispickup = map (_unNInt . _itID) itmstopickup
|
ispickup = map (_unNInt . _itID) itmstopickup
|
||||||
guard $ nfreeslots >= slotsneeded
|
guard $ nfreeslots >= slotsneeded
|
||||||
return $ case mpos of
|
return $ case mpos of
|
||||||
Just (0, j) -> foldr (pickUpItemAt j 0) w ispickup & newdisel j xs
|
Just (0, j) -> foldr (pickUpItemAt j 0) w ispickup & newdisel j joff xs
|
||||||
_ -> foldl' (flip $ pickUpItem 0) w ispickup & newdisel (length (cr ^. crInv)) xs
|
_ -> foldl' (flip $ pickUpItem 0) w ispickup & newdisel (length (cr ^. crInv)) joff xs
|
||||||
where
|
where
|
||||||
newdisel j xs =
|
newdisel j joff xs =
|
||||||
hud . diSelection ?~ Sel 0 j (IS.fromDistinctAscList [j .. j + IS.size xs -1])
|
hud . diSelection ?~ Sel 0 (j+joff) (IS.fromDistinctAscList [j .. j + IS.size xs -1])
|
||||||
g i = do
|
g i = do
|
||||||
NInt j <- w ^? hud . closeItems . ix i
|
NInt j <- w ^? hud . closeItems . ix i
|
||||||
w ^? cWorld . lWorld . items . ix j
|
w ^? cWorld . lWorld . items . ix j
|
||||||
@@ -305,7 +319,8 @@ endCombineRegex w = ssSetCursor (ssLookupDown 0 j) sss
|
|||||||
startDrag :: (Int, Int) -> World -> World
|
startDrag :: (Int, Int) -> World -> World
|
||||||
startDrag (a, b) w = setcontext $ case w ^? hud . diSelection . _Just of
|
startDrag (a, b) w = setcontext $ case w ^? hud . diSelection . _Just of
|
||||||
Just (Sel i _ xs) | i == a && b `IS.member` xs -> w
|
Just (Sel i _ xs) | i == a && b `IS.member` xs -> w
|
||||||
_ -> invSetSelection (Sel a b (IS.singleton b)) w
|
-- _ -> invSetSelection (Sel a b (IS.singleton b)) w
|
||||||
|
_ -> invSetSelection (Sel a b mempty) w
|
||||||
where
|
where
|
||||||
setcontext = input . mouseContext .~ OverInvDrag a (Just (a, b))
|
setcontext = input . mouseContext .~ OverInvDrag a (Just (a, b))
|
||||||
|
|
||||||
|
|||||||
@@ -69,17 +69,13 @@ optionScreenDefaultEffect u = fromMaybe u $ do
|
|||||||
-- ouch this is not good
|
-- ouch this is not good
|
||||||
mouseClickOptionsList :: Universe -> Universe
|
mouseClickOptionsList :: Universe -> Universe
|
||||||
mouseClickOptionsList u = fromMaybe u $ do
|
mouseClickOptionsList u = fromMaybe u $ do
|
||||||
sl <- u ^? uvScreenLayers . ix 0 . scSelectionList
|
l <- case u ^. uvWorld . input . mouseButtons of
|
||||||
case u ^. uvWorld . input . mouseButtons of
|
mbs | mbs ^. at ButtonLeft == Just 0 -> Just _1
|
||||||
mbs | mbs ^. at ButtonLeft == Just 0 -> do
|
mbs | mbs ^. at ButtonRight == Just 0 -> Just _2
|
||||||
i <- u ^? uvWorld . input . mouseContext . mcoMenuClick
|
|
||||||
f <- sl ^? ix i . siPayload . _Just . _1
|
|
||||||
return $ f u & uvSoundQueue .:~ click1S
|
|
||||||
mbs | mbs ^. at ButtonRight == Just 0 -> do
|
|
||||||
i <- u ^? uvWorld . input . mouseContext . mcoMenuClick
|
|
||||||
f <- sl ^? ix i . siPayload . _Just . _2
|
|
||||||
return $ f u & uvSoundQueue .:~ click1S
|
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
i <- u ^? uvWorld . input . mouseContext . mcoMenuClick . _Just
|
||||||
|
f <- u ^? uvScreenLayers . ix 0 . scSelectionList . ix i . siPayload . _Just . l
|
||||||
|
return $ f u & uvSoundQueue .:~ click1S
|
||||||
|
|
||||||
ldpSelection :: Config -> LDParams -> Point2 -> Maybe Int
|
ldpSelection :: Config -> LDParams -> Point2 -> Maybe Int
|
||||||
ldpSelection cfig ldp (V2 _ y)
|
ldpSelection cfig ldp (V2 _ y)
|
||||||
|
|||||||
+5
-5
@@ -42,7 +42,7 @@ module Picture.Base (
|
|||||||
color,
|
color,
|
||||||
zeroZ,
|
zeroZ,
|
||||||
setDepth,
|
setDepth,
|
||||||
addDepth,
|
-- addDepth,
|
||||||
setLayer,
|
setLayer,
|
||||||
mirroryz,
|
mirroryz,
|
||||||
mirrorxz,
|
mirrorxz,
|
||||||
@@ -122,10 +122,10 @@ setDepth :: Float -> Picture -> Picture
|
|||||||
--setDepth d = map $ second $ overPos (\(x,y,_) -> (x,y,d))
|
--setDepth d = map $ second $ overPos (\(x,y,_) -> (x,y,d))
|
||||||
setDepth d = fmap $ overPos (\(V3 x y _) -> V3 x y d)
|
setDepth d = fmap $ overPos (\(V3 x y _) -> V3 x y d)
|
||||||
|
|
||||||
addDepth :: Float -> Picture -> Picture
|
--addDepth :: Float -> Picture -> Picture
|
||||||
{-# INLINE addDepth #-}
|
--{-# INLINE addDepth #-}
|
||||||
--addDepth d = map $ second $ overPos (\(x,y,z) -> (x,y,z+d))
|
----addDepth d = map $ second $ overPos (\(x,y,z) -> (x,y,z+d))
|
||||||
addDepth d = fmap $ overPos (\(V3 x y z) -> V3 x y (z + d))
|
--addDepth d = fmap $ overPos (\(V3 x y z) -> V3 x y (z + d))
|
||||||
|
|
||||||
-- TODO change the Int here to a dedicated type
|
-- TODO change the Int here to a dedicated type
|
||||||
setLayer :: Layer -> Picture -> Picture
|
setLayer :: Layer -> Picture -> Picture
|
||||||
|
|||||||
Reference in New Issue
Block a user