-
Notifications
You must be signed in to change notification settings - Fork 22
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: add documentation #221
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have a few suggestions, but overall I like how you write documentation 👍
...ain/java/org/terasology/ligthandshadow/componentsystem/controllers/ClientParticleSystem.java
Outdated
Show resolved
Hide resolved
package org.terasology.ligthandshadow.componentsystem.events; | ||
|
||
import org.terasology.engine.entitySystem.event.Event; | ||
import org.terasology.engine.network.BroadcastEvent; | ||
|
||
/** | ||
* Notification event to indicate that the score has been updated. | ||
*/ | ||
@BroadcastEvent | ||
public class ScoreUpdateFromServerEvent implements Event { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to align the naming with the other notification events such as OnFlagDropped
.
Same for the game state notification events.
As this PR is for adding documentation, I'm fine with doing so in a follow-up
...a/org/terasology/ligthandshadow/componentsystem/controllers/TakeBlockOnActivationSystem.java
Outdated
Show resolved
Hide resolved
* | ||
* @param event | ||
* @param entity | ||
*/ | ||
@ReceiveEvent(components = {WinConditionCheckOnActivateComponent.class, LASTeamComponent.class}) | ||
public void onActivate(ActivateEvent event, EntityRef entity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I'd like to rename this to updateScoreOnActivate
(in a follow-up PR).
I always feel like event handlers' names should indicate what happens in reaction to the event, not only "repeat" the event that is handled...
src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/ScoreSystem.java
Outdated
Show resolved
Hide resolved
@@ -16,6 +16,9 @@ | |||
import org.terasology.ligthandshadow.componentsystem.components.LASConfigComponent; | |||
import org.terasology.engine.registry.In; | |||
|
|||
/** | |||
* Provides an entity that keeps track of game state information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a system, not an entity, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is a system.
@ReceiveEvent | ||
public void onRestartRequest(RestartRequestEvent event, EntityRef clientEntity, ClientComponent clientComponent) { | ||
Iterable<EntityRef> clients = entityManager.getEntitiesWith(ClientComponent.class); | ||
for (EntityRef client: clients) { | ||
EntityRef player = client.getComponent(ClientComponent.class).character; | ||
String team = player.getComponent(LASTeamComponent.class).team; | ||
player.send(new RestoreFullHealthEvent(player)); | ||
player.send(new CharacterTeleportEvent(LASUtils.getTeleportDestination(team))); | ||
client.send(new ClientRestartEvent()); | ||
} | ||
} | ||
|
||
/** | ||
* System to close game over screen once restart is complete. | ||
* | ||
* @param event | ||
* @param clientEntity | ||
*/ | ||
@ReceiveEvent(netFilter = RegisterMode.CLIENT) | ||
public void onClientRestart(ClientRestartEvent event, EntityRef clientEntity) { | ||
if (localPlayer.getClientEntity().equals(clientEntity)) { | ||
if (nuiManager.isOpen(LASUtils.DEATH_SCREEN)) { | ||
DeathScreen deathScreen = (DeathScreen) nuiManager.getScreen(LASUtils.DEATH_SCREEN); | ||
MigLayout migLayout = deathScreen.find("playerStatistics", MigLayout.class); | ||
if (migLayout != null) { | ||
migLayout.removeAllWidgets(); | ||
} | ||
nuiManager.closeScreen(LASUtils.DEATH_SCREEN); | ||
} | ||
Iterable<EntityRef> clients = entityManager.getEntitiesWith(ClientComponent.class); | ||
for (EntityRef client: clients) { | ||
EntityRef player = client.getComponent(ClientComponent.class).character; | ||
String team = player.getComponent(LASTeamComponent.class).team; | ||
player.send(new RestoreFullHealthEvent(player)); | ||
player.send(new CharacterTeleportEvent(LASUtils.getTeleportDestination(team))); | ||
client.send(new ClientRestartEvent()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a documentation change. Please extract this to another PR.
src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/ClientSkinSystem.java
Outdated
Show resolved
Hide resolved
src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/ClientSkinSystem.java
Outdated
Show resolved
Hide resolved
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.ligthandshadow.componentsystem.controllers; | ||
|
||
import org.terasology.engine.entitySystem.entity.EntityRef; | ||
import org.terasology.engine.entitySystem.event.ReceiveEvent; | ||
import org.terasology.engine.entitySystem.systems.BaseComponentSystem; | ||
import org.terasology.engine.entitySystem.systems.RegisterMode; | ||
import org.terasology.engine.entitySystem.systems.RegisterSystem; | ||
import org.terasology.engine.logic.players.LocalPlayer; | ||
import org.terasology.engine.registry.In; | ||
import org.terasology.engine.rendering.nui.NUIManager; | ||
import org.terasology.engine.rendering.nui.layers.ingame.DeathScreen; | ||
import org.terasology.ligthandshadow.componentsystem.LASUtils; | ||
import org.terasology.ligthandshadow.componentsystem.events.ClientRestartEvent; | ||
import org.terasology.nui.layouts.miglayout.MigLayout; | ||
|
||
/** | ||
* System to close game over screen once restart is complete. | ||
*/ | ||
|
||
@RegisterSystem(RegisterMode.CLIENT) | ||
public class ClientRestartSystem extends BaseComponentSystem { | ||
@In | ||
LocalPlayer localPlayer; | ||
@In | ||
NUIManager nuiManager; | ||
|
||
@ReceiveEvent | ||
public void onClientRestart(ClientRestartEvent event, EntityRef clientEntity) { | ||
if (localPlayer.getClientEntity().equals(clientEntity)) { | ||
if (nuiManager.isOpen(LASUtils.DEATH_SCREEN)) { | ||
DeathScreen deathScreen = (DeathScreen) nuiManager.getScreen(LASUtils.DEATH_SCREEN); | ||
MigLayout migLayout = deathScreen.find("playerStatistics", MigLayout.class); | ||
if (migLayout != null) { | ||
migLayout.removeAllWidgets(); | ||
} | ||
nuiManager.closeScreen(LASUtils.DEATH_SCREEN); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a documentation change, please extract it to another PR
No description provided.