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

fix(ecs-gestalt): Migrate Components to gestalt's Components. #8

Merged
merged 3 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2020 The Terasology Foundation
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.notifications.model;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.notifications.events.ExpireNotificationEvent;
import org.terasology.notifications.events.ShowNotificationEvent;

Expand All @@ -15,7 +15,7 @@
* <p>
* Please use {@link ShowNotificationEvent} and {@link ExpireNotificationEvent} to modify the displayed notifications.
*/
public class NotificationComponent implements Component {
public class NotificationComponent implements Component<NotificationComponent> {
/**
* The ordered list of notifications to show in the notification overlay.
*/
Expand All @@ -24,4 +24,10 @@ public class NotificationComponent implements Component {
public NotificationComponent() {
notifications = new ArrayList<>();
}

@Override
public void copyFrom(NotificationComponent other) {
notifications.clear();
notifications.addAll(other.notifications);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.terasology.nui.databinding.ReadOnlyBinding;
import org.terasology.nui.widgets.UIList;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -43,9 +44,10 @@ public void initialise() {
@Override
public List<TimedNotification> get() {
EntityRef client = localPlayer.getClientEntity();
return Optional.ofNullable(client.getComponent(NotificationComponent.class))
List<TimedNotification> timedNotifications = Optional.ofNullable(client.getComponent(NotificationComponent.class))
.map(component -> component.notifications)
.orElse(Collections.emptyList());
return timedNotifications;
}
});
}
Expand Down