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: add documentation #221

Merged
merged 11 commits into from
Jul 7, 2021
Merged

Conversation

ahv15
Copy link
Member

@ahv15 ahv15 commented Jul 1, 2021

No description provided.

@ahv15 ahv15 marked this pull request as draft July 1, 2021 15:00
@ahv15 ahv15 marked this pull request as ready for review July 1, 2021 17:47
Copy link
Member

@jdrueckert jdrueckert left a 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 👍

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 {
Copy link
Member

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

*
* @param event
* @param entity
*/
@ReceiveEvent(components = {WinConditionCheckOnActivateComponent.class, LASTeamComponent.class})
public void onActivate(ActivateEvent event, EntityRef entity) {
Copy link
Member

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...

@@ -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.
Copy link
Member

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?

Copy link
Member Author

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.

Comment on lines 34 to 42
@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());
Copy link
Member

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.

Comment on lines 1 to 42
// 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);
}
}
}
}
Copy link
Member

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

@ahv15 ahv15 requested a review from jdrueckert July 5, 2021 18:36
@jdrueckert jdrueckert merged commit 4dbada1 into Terasology:develop Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants