Page 1 of 1

[FND] Entity/Agent refacto

Posted: 17 Feb 2023, 13:51
by Reid

I'm currently doing a pretty huge refacto on all of our entity system (mobs, npcs, players) to split everything to work with a client/server style.

The first version will feature a pretty heavy/greedy system that mimic the 0.0.3 milestone, it will be laggy but it will give us a first implementation to work on.

To differentiate the client and server side entity I renamed this last in "Agent".

The client will send player movement (both click events and input vector) at each frame to the server.
The server will then manage all of the move logic and create a velocity vector based on the computed navigation path or collision avoidance for both movement cases.
This velocity vector is then sent back along all other surrounding agents to each client.


The mock-up currently looks like this:

Navigation by mouse:

  • Service Action: Click

  • Service Client: SetClickPos to Server

  • Service Server: SetClickPos through the navigation agent

  • Service Server: Apply NavigationPath to Agent

  • Service Agent: Update along the NavigationPath with the navigation server

  • Service Agent: Receive _velocity_computed() apply and forward to Client

  • Service Client: Receive _velocity_computed(), forward to Entity

  • Service Entity: Receive _velocity_computed() and (lerp a) set_position(new_pos)

Navigation by sticks/keys:

  • Service Action: Move input

  • Service Client: SetMovePos to Server

  • Service Server: SetMovePos to the Agent

  • Service Agent: Call direction_to() on (pos + velocity)

  • Service Agent: Trigger manually the _velocity_computed()

  • Service Agent: Receive _velocity_computed() apply and forward to Client

  • Service Client: Receive _velocity_computed(), forward to Entity

  • Service Entity: Receive _velocity_computed() and (lerp a) set_position(new_pos)

Surrounding Agents (npcs, mobs, other players):

  • Service Agent: Randomly apply a new NavigationPath to Agent

  • Service Agent: Update along the NavigationPath with the navigation server

  • Service Agent: Receive _velocity_computed() apply and forward to Client

  • Service Client: Receive _velocity_computed(), forward to Entity

  • Service Entity: Receive _velocity_computed() and (lerp a) set_position(new_pos)

All of this is being worked on this branch: https://gitlab.com/sourceofmana/sourceo ... ic_network
More info about the on-going network integration: viewtopic.php?t=21582


Re: [FND] Entity/Agent refacto

Posted: 20 Feb 2023, 22:29
by Reid

This refacto has been completed, the current version is still a huge work in progress but we now have something to work with!

A little change on the implementation: the server is meant to be working without physic and thus collision-less. All displacement will be computed within the navigation server, it's a different system but it should ease up some of our development.
I made some change on our implementation of "Navigation by sticks/keys" to reflect this design. We now have all entities and agents sync in the offline mode as it was on 0.0.3.


Re: [FND] Entity/Agent refacto

Posted: 21 Feb 2023, 00:42
by WildX

It's good to see the [FND] tag once again!


Re: [FND] Entity/Agent refacto

Posted: 21 Feb 2023, 09:30
by jesusalva

As long that you don't do it tmwa style it's fine.

(In tmwa, with proper packet forgery, it's possible to ignore completely the collision map).