Skip to content

Commit

Permalink
Implemented smooth movement for look and peek
Browse files Browse the repository at this point in the history
  • Loading branch information
howroyd committed Nov 11, 2023
1 parent af377d8 commit 652899b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/simonsays_drgreengiant/gameactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions src/simonsays_drgreengiant/phasmoactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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))

#####################################################################

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 652899b

Please sign in to comment.