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

refactor(player): factor out LocalPlayerControlSystem #4586

Conversation

antag99
Copy link
Contributor

@antag99 antag99 commented Mar 17, 2021

Contains

LocalPlayerControlSystem now handles input events, LocalPlayerSystem still handles sending character movement events. Current motion control state is stored in a component (LocalPlayerControlComponent).

Introduces a tag component (LocalPlayerComponent) for the local player, along with a DoNotPersist annotation to ensure the component only lasts for the current session.

Both LocalPlayerSystem and LocalPlayerControlSystem use the tag component to find the local player. I think this is easier and less error-prone than having a LocalPlayer object that may or may not be in the correct state. The tag component can also be used for filtering events.

Draft, input needed before further work is done.

Tested locally but not with local multiplayer server.

How to test

Not yet.

LocalPlayerControlSystem now handles input events, LocalPlayerSystem still
handles sending character movement events.

Introduces a tag component for the local player, along with a DoNotPersist
annotation to ensure the component only lasts for the current session.

Both LocalPlayerSystem and LocalPlayerControlSystem use the tag component
to find the local player.
@keturn keturn self-requested a review March 18, 2021 02:15
@keturn keturn marked this pull request as draft March 18, 2021 02:16
@DarkWeird DarkWeird self-requested a review March 18, 2021 06:17
@keturn keturn added this to the v4.4.0 milestone Mar 19, 2021
Copy link
Member

@keturn keturn left a comment

Choose a reason for hiding this comment

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

As someone who just started familiarizing themselves with how movement inputs work the other day, this Sounds Good To Me.

But I have neither the experience with the ECS system nor the familiarity with how far-reaching changes to the LocalPlayerSystem would be to able to give much more intelligent feedback than that.

@antag99
Copy link
Contributor Author

antag99 commented Mar 19, 2021

There are some points with regards to this draft that needs to be considered,

  • Is it good to have components on the local player that live as long as the in-game-session, facilated via a DoNotPersist annotation?
  • Is it good to have a tag component for the local player?
  • Is it good to factor out input handling in LocalPlayerSystem?

If the answer to these are yes, then the general idea in this draft is good. However these are three different things that would really have to be done in separare pull requests, and the implementation of the DoNotPersist annotation as well as the adding of the tag component for the local player would need a bit of cleanup.

@jdrueckert jdrueckert added the Status: Needs Discussion Requires help discussing a reported issue or provided PR label Jun 12, 2021
@jdrueckert jdrueckert modified the milestones: v5.0.0, v5.1.0 Jun 12, 2021
@keturn keturn modified the milestones: v5.1.0, v5.2.0 Aug 15, 2021
…yer-control-system

# Conflicts:
#	engine/src/main/java/org/terasology/engine/logic/players/LocalPlayerSystem.java
#	engine/src/main/java/org/terasology/engine/persistence/serializers/ComponentSerializeCheck.java
chore: update engine package paths for MovingBlocks#4560
@DarkWeird
Copy link
Contributor

@antag99
Sorry for long waiting

Is it good to have a tag component for the local player?
Yeah. it is ECS.
Tag components it is normal (also prefer tag components then using component with boolean)

Is it good to factor out input handling in LocalPlayerSystem?
Decoupled systems - that nice too.

Is it good to have components on the local player that live as long as the in-game-session, facilated via a DoNotPersist annotation?

Components can have any life time. (one tick, or infinity via persistance)

I updated code, a bit choring annotations and some idea issues.

And then detects that player cannot moves in multiplayer.
Are you check this at multiplayer?

@antag99
Copy link
Contributor Author

antag99 commented Sep 11, 2021

@antag99
Sorry for long waiting

Thanks for taking a look!

I updated code, a bit choring annotations and some idea issues.

And then detects that player cannot moves in multiplayer.
Are you check this at multiplayer?

No, I have not tested the patch on multiplayer if i remember correctly. I do not have the time to work on this for the time being, so I will close this PR and open a new one if I get back to working on it. I remember the most tricky part was to get the tag component added whenever the local player appeared, and I think there may be a lot of work (and testing) to get this done properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Discussion Requires help discussing a reported issue or provided PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants