Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create tick-based task system #382

Merged
merged 8 commits into from
Sep 26, 2022
Merged

Conversation

Jameskmonger
Copy link
Collaborator

This PR implements a tick-based task system for Actors (Player/Npc) and the World.

The main practical difference between this implementation and the previous Behaviour system is that the tasks here are synchronized for all entities in the world, and delays are handled by tick count rather than by milliseconds.

There are a number of configuration options for a Task as well as some useful subtasks. You can read more about these in the attached README.md file. The current set of subtasks is a starting point, and we will surely want to create more for more interaction types.

If you'd like to see how content is written in this new task system, there are some PRs on my fork that you can view: https://github.com/Jameskmonger/runejs-server/pulls

There are a number of TODOs around adding unit tests, I would like to propose that we keep these included for now - currently the areas are difficult to test due to complications with mocking the player class, but I have been working on other PRs to improve this.

feat: don't add task if already active

refactor: rename addTask to enqueue

feat: handle stacking/overriding of tasks

feat: add a BreakType property to tasks

feat: add a clear() method to the scheduler

feat: create TaskStackGroup enum

feat: add onStop callback to Task

refactor: create TaskConfig container type

feat: create ActorTask and WalkToTask

feat: make breakType an array

feat: allow `execute` to return a bool indicating task termination

feat: create Task subclasses for Actor
This also refactors the `Player.loggedIn` property into an
`Actor.active` property so that I can use it in the generic
`Actor`-level task processing

refactor: move active to base Actor class, create init/destroy methods

feat: add a scheduler to Actor

feat: add a scheduler to World
docs: fix Task docs

docs: update task README with impl plan

docs: update @engine/task progress
fix: fix enqueueTask for only 1 arg

fix: support enqueueTask for a task with 0 params (besides Actor)
fix: export ActorLandscapeObjectInteractionTask to index
docs: add docs around Task configuration

docs: add docs on task subtypes

docs: update progress tracker

docs: update documentation
@SchauweM SchauweM added documentation Improvements or additions to documentation new feature A new feature or request game engine Updates involving the main game engine or game logic labels Sep 25, 2022
Copy link
Contributor

@Katilith Katilith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Freakin' beautiful 🙌

@Katilith Katilith merged commit 4bb508f into runejs:develop Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation game engine Updates involving the main game engine or game logic new feature A new feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants