runejs / server

RuneJS is a RuneScape game server written in TypeScript and JavaScript. The goal of the project is to create a comprehensive game engine, while also providing simple and easy to use content development systems and APIs.
GNU General Public License v3.0
242 stars 83 forks source link

feat: create tick-based task system #382

Closed Jameskmonger closed 2 years ago

Jameskmonger commented 2 years ago

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.