Add capability to examine you (empty slots) and close objects

This commit is contained in:
2023-01-11 22:23:01 +00:00
parent 25912fe3eb
commit 994496e964
4 changed files with 65 additions and 38 deletions
+9 -18
View File
@@ -2,15 +2,15 @@ module Dodge.Creature.YourControl (
yourControl,
) where
import Data.Maybe
import Data.Foldable
import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Base.Coordinate
import Dodge.Creature.Impulse.Movement
import Dodge.Creature.Test
import Dodge.Data.World
import Dodge.InputFocus
import Dodge.LightSource
--import Dodge.LightSource
import Dodge.Update.UsingInput
import Geometry
import LensHelp
@@ -19,15 +19,15 @@ import qualified SDL
-- | The AI equivalent for your control.
yourControl :: Creature -> World -> World
yourControl cr w
| inTermFocus w = dimCreatureLight cr w & updateUsingInput
| inTermFocus w = w & updateUsingInput
| otherwise =
dimCreatureLight cr w
w
& cWorld . lWorld . creatures . ix (_crID cr)
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_input w)))
& updateUsingInput
dimCreatureLight :: Creature -> World -> World
dimCreatureLight cr = cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 300 0.1 (addZ 100 $ _crPos cr)
--dimCreatureLight :: Creature -> World -> World
--dimCreatureLight cr = cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 300 0.1 (addZ 100 $ _crPos cr)
-- note the order of operation, setting the posture first--this prevents the twist fire bug
@@ -41,7 +41,6 @@ wasdWithAiming ::
wasdWithAiming w speed cr
| isAiming = addAnyTwist $ aimTurn mouseDir $ theMovement $ setMvAim cr
| crIsReloading cr && SDL.ButtonRight `M.member` _mouseButtons (_input w) =
--addAnyTwist $ aimTurn (mouseDir + anytwist) $ theMovement $ setMvAim cr
aimTurn mouseDir $ removeTwist $ theMovement $ setMvAim cr
| otherwise = noaimmove $ theTurn $ removeTwist $ setMvAim cr
where
@@ -51,17 +50,10 @@ wasdWithAiming w speed cr
cr'
& crDir +~ _crTwist cr'
& crTwist .~ 0
anytwist = case cr ^? crInv . ix (crSel cr) . itUse . heldAim . aimStance of
Just TwoHandTwist -> twistamount * pi
_ -> 0
--addAnyTwist = crTwist .~ anytwist
addAnyTwist = case cr ^? crInv . ix (crSel cr) . itUse . heldAim . aimStance of
Just TwoHandTwist -> case cr ^. crTwist of
0 -> (crTwist .~ twistamount * pi)
. (crDir -~ twistamount * pi)
_ -> id
addAnyTwist = case (cr ^? crInv . ix (crSel cr) . itUse . heldAim . aimStance, cr^. crTwist) of
(Just TwoHandTwist, 0) -> (crTwist .~ twistamount * pi)
. (crDir -~ twistamount * pi)
_ -> id
theMovement
| movDir == V2 0 0 = id
| otherwise = crMvAbsolute (speed *.* movAbs)
@@ -69,7 +61,6 @@ wasdWithAiming w speed cr
| movDir == V2 0 0 = id
| otherwise = crMvForward speed
theTurn cr' = creatureTurnTowardDir (_crMvAim cr') 0.2 cr'
-- theTurn' cr' = creatureTurnTowardDir dir 0.2 cr'
movDir = wasdDir w
dir = fmap ((w ^. cWorld . camPos . camRot) +) (safeArgV movDir)
movAbs = rotateV (w ^. cWorld . camPos . camRot) $ normalizeV movDir