Allow mouse click interaction for nearby objects

This commit is contained in:
2025-01-02 00:32:45 +00:00
parent 3b60ad6023
commit 03b25565f1
4 changed files with 106 additions and 167 deletions
+5 -5
View File
@@ -2,6 +2,7 @@ module Dodge.Creature.YourControl (
yourControl,
) where
import Dodge.SelectedClose
import Control.Monad
import Data.Foldable
import qualified Data.Map.Strict as M
@@ -178,13 +179,12 @@ tryClickUse pkeys w = fromMaybe w $ do
ltime <- pkeys ^? ix SDL.ButtonLeft
rtime <- pkeys ^? ix SDL.ButtonRight
guard $ ltime <= rtime
invid <-
w
^? cWorld . lWorld . creatures . ix 0
case w ^? cWorld . lWorld . creatures . ix 0
. crManipulation
. manObject
. imSelectedItem
useItem invid (f ltime) w
. imSelectedItem of
Just invid -> useItem invid (f ltime) w
Nothing -> interactWithCloseObj <$> getSelectedCloseObj w ?? w
where
f 0 = InitialPress
f _ = ShortPress