From 652899b8058855241d077d6c0db2dbd2e2a5a21c Mon Sep 17 00:00:00 2001 From: Simon Howroyd Date: Sat, 11 Nov 2023 13:52:04 +0000 Subject: [PATCH] Implemented smooth movement for look and peek --- src/simonsays_drgreengiant/gameactions.py | 2 ++ src/simonsays_drgreengiant/phasmoactions.py | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/simonsays_drgreengiant/gameactions.py b/src/simonsays_drgreengiant/gameactions.py index c980185..b58da02 100644 --- a/src/simonsays_drgreengiant/gameactions.py +++ b/src/simonsays_drgreengiant/gameactions.py @@ -125,6 +125,8 @@ def run(self, *, force: bool = False) -> errorcodes.ErrorSet: return hidactions.MoveMouseRelative(actionconfig.hidconfig).run(force=force) elif isinstance(actionconfig.hidconfig, hidactions.MouseMoveDirectionActionConfig): return hidactions.MoveMouseRelativeDirection(actionconfig.hidconfig).run(force=force) + elif isinstance(actionconfig.hidconfig, hidactions.MouseMoveDirectionSmoothActionConfig): + return hidactions.MoveMouseRelativeDirectionSmooth(actionconfig.hidconfig).run(force=force) else: return errorcodes.errorset(errorcodes.ErrorCode.NOT_IMPLEMENTED) diff --git a/src/simonsays_drgreengiant/phasmoactions.py b/src/simonsays_drgreengiant/phasmoactions.py index 58062dd..a491178 100644 --- a/src/simonsays_drgreengiant/phasmoactions.py +++ b/src/simonsays_drgreengiant/phasmoactions.py @@ -405,7 +405,7 @@ class PeekUp(GenericAction): @dataclasses.dataclass(slots=True) class PeekUpConfig(PeekConfig): """Peek up config""" - hidconfig: hidactions.Config = dataclasses.field(default_factory=lambda: hidactions.MouseMoveDirectionActionConfig(DEFAULTS.PEEK_DISTANCE, hidactions.MouseMoveDirection.UP)) + hidconfig: hidactions.Config = dataclasses.field(default_factory=lambda: hidactions.MouseMoveDirectionSmoothActionConfig(DEFAULTS.PEEK_DISTANCE, hidactions.MouseMoveDirection.UP)) @dataclasses.dataclass(slots=True) @@ -418,7 +418,7 @@ class PeekDown(GenericAction): @dataclasses.dataclass(slots=True) class PeekDownConfig(PeekConfig): """Peek down config""" - hidconfig: hidactions.Config = dataclasses.field(default_factory=lambda: hidactions.MouseMoveDirectionActionConfig(DEFAULTS.PEEK_DISTANCE, hidactions.MouseMoveDirection.DOWN)) + hidconfig: hidactions.Config = dataclasses.field(default_factory=lambda: hidactions.MouseMoveDirectionSmoothActionConfig(DEFAULTS.PEEK_DISTANCE, hidactions.MouseMoveDirection.DOWN)) @dataclasses.dataclass(slots=True) @@ -431,7 +431,7 @@ class PeekLeft(GenericAction): @dataclasses.dataclass(slots=True) class PeekLeftConfig(PeekConfig): """Peek left config""" - hidconfig: hidactions.Config = dataclasses.field(default_factory=lambda: hidactions.MouseMoveDirectionActionConfig(DEFAULTS.PEEK_DISTANCE, hidactions.MouseMoveDirection.LEFT)) + hidconfig: hidactions.Config = dataclasses.field(default_factory=lambda: hidactions.MouseMoveDirectionSmoothActionConfig(DEFAULTS.PEEK_DISTANCE, hidactions.MouseMoveDirection.LEFT)) @dataclasses.dataclass(slots=True) @@ -444,7 +444,7 @@ class PeekRight(GenericAction): @dataclasses.dataclass(slots=True) class PeekRightConfig(PeekConfig): """Peek right config""" - hidconfig: hidactions.Config = dataclasses.field(default_factory=lambda: hidactions.MouseMoveDirectionActionConfig(DEFAULTS.PEEK_DISTANCE, hidactions.MouseMoveDirection.RIGHT)) + hidconfig: hidactions.Config = dataclasses.field(default_factory=lambda: hidactions.MouseMoveDirectionSmoothActionConfig(DEFAULTS.PEEK_DISTANCE, hidactions.MouseMoveDirection.RIGHT)) ##################################################################### @@ -734,8 +734,8 @@ def run(self, *, force: bool = False) -> errorcodes.ErrorSet: distance = actionconfig.distance or DEFAULTS.PEEK_DISTANCE - lookup = hidactions.MoveMouseRelativeDirection(hidactions.MouseMoveDirectionSmoothActionConfig(distance, hidactions.MouseMoveDirection.UP)) - lookdown = hidactions.MoveMouseRelativeDirection(hidactions.MouseMoveDirectionSmoothActionConfig(distance, hidactions.MouseMoveDirection.DOWN)) + lookup = hidactions.MoveMouseRelativeDirectionSmooth(hidactions.MouseMoveDirectionSmoothActionConfig(distance, hidactions.MouseMoveDirection.UP)) + lookdown = hidactions.MoveMouseRelativeDirectionSmooth(hidactions.MouseMoveDirectionSmoothActionConfig(distance, hidactions.MouseMoveDirection.DOWN)) once = actions.ActionSequence([lookup, actions.Wait(pause), lookdown]) return actions.ActionRepeatWithWait(once, repeats, actions.Wait(pause)).run(force=force)