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

Changing player skins through skeletal mesh #80

Merged
merged 6 commits into from Jun 10, 2019

Conversation

4 participants
@darshan3
Copy link
Member

commented May 26, 2019

Solves #72

How to test:

  1. Host a Light and Shadow game
  2. Join the game using one more client instance
  3. Choose one team with each of the players

Player Skin should initially be a white pawn and it should change to a black pawn for the black team, a red pawn for the red team.

@iaronaraujo
Copy link
Contributor

left a comment

Same thing as the other PR, Javadoc!

import org.terasology.registry.In;
import org.terasology.logic.characters.VisualCharacterComponent;
import org.terasology.rendering.logic.SkeletalMeshComponent;
import org.terasology.utilities.Assets;

This comment has been minimized.

Copy link
@iaronaraujo

iaronaraujo May 28, 2019

Contributor

Could you add the class Javadoc too?

This comment has been minimized.

Copy link
@darshan3

darshan3 May 29, 2019

Author Member

Added in other PR. It would lead to a merge conflict if I added it to both.

@Cervator
Copy link
Member

left a comment

Looks fine, haven't tested though. Sitting in an airport :-)

Left one curious line comment but haven't dug into the code to confirm.


/**
* Changes a player's skin on receiving the corresponding event
*/
@ReceiveEvent
public void onAddPlayerSkinToPlayer(AddPlayerSkinToPlayerEvent event, EntityRef entity) {

This comment has been minimized.

Copy link
@Cervator

Cervator May 29, 2019

Member

In this case is entity distinct from event.player ? Just curious. If it is you could add VisualCharacterComponent as a method parameter to both automatically filter by having it present (skipping one if statement) and assigning in to a variable (skipping a line to then declare a var normally)

This comment has been minimized.

Copy link
@darshan3

darshan3 May 31, 2019

Author Member

Yes, the receiving entities are client entities, hence it is necessary to have a player entity in the event for changing the skin of that particular player.

@nihal111
Copy link
Member

left a comment

Tested it out a couple times, didn't work as expected.
Created two clients, and chose one team for each, both red and black teams got spawned at respective bases but each had the skin of the team selected for the second client.
It seems that the AddPlayerSkinToPlayerEvent that is being sent out to all the clients changes the skin of the local player too. @dacharya64 had similar problems in #72. This might require some deeper digging.

@skaldarnar skaldarnar added this to In progress in GSOC 2019: Light & Shadows via automation Jun 4, 2019

@darshan3 darshan3 force-pushed the PlayerSkin branch from 49f38aa to 156c389 Jun 6, 2019

@darshan3

This comment has been minimized.

Copy link
Member Author

commented Jun 6, 2019

Rebased with current master

@nihal111
Copy link
Member

left a comment

Works great, even with restarts and reconnects. Just extract out a method in LASUtils and let's get to merging this.

EntityRef visualCharacter = visualCharacterComponent.visualCharacter;
if (visualCharacter != EntityRef.NULL && visualCharacter.hasComponent(SkeletalMeshComponent.class)) {
SkeletalMeshComponent skeletalMeshComponent = visualCharacter.getComponent(SkeletalMeshComponent.class);
if (lasTeamComponent.team.equals(LASUtils.BLACK_TEAM)) {

This comment has been minimized.

Copy link
@nihal111

nihal111 Jun 9, 2019

Member

Instead of having the logic below for team check and skeletal mesh update, can you do something similar as done in the case of Health HUD? i.e. create a method in LASUtils to give the respective Pawn skin after checking the team, as in-

public static String getHealthSkin (String team) {
if (team.equals(RED_TEAM)) {
return RED_HEALTH_SKIN;
}
if (team.equals(BLACK_TEAM)) {
return BLACK_HEALTH_SKIN;
}
if (team.equals(WHITE_TEAM)) {
return WHITE_HEALTH_SKIN;
}
return null;

This comment has been minimized.

Copy link
@darshan3

darshan3 Jun 10, 2019

Author Member

Done!

@nihal111 nihal111 merged commit 483b971 into master Jun 10, 2019

GSOC 2019: Light & Shadows automation moved this from In progress to Done Jun 10, 2019

@nihal111 nihal111 deleted the PlayerSkin branch Jun 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.