-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathWildAnimalsTooltipSystem.java
44 lines (38 loc) · 1.9 KB
/
WildAnimalsTooltipSystem.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.wildAnimals.WorldlyTooltipDisplay;
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.common.DisplayNameComponent;
import org.terasology.module.inventory.ui.GetItemTooltip;
import org.terasology.nui.widgets.TooltipLine;
import org.terasology.wildAnimals.component.WildAnimalComponent;
import org.terasology.worldlyTooltipAPI.events.GetTooltipIconEvent;
import org.terasology.worldlyTooltipAPI.events.GetTooltipNameEvent;
@RegisterSystem(value = RegisterMode.CLIENT)
public class WildAnimalsTooltipSystem extends BaseComponentSystem {
/*
* Sets the Name at the top of the WorldlyTooltip to show the animal name
*/
@ReceiveEvent
public void getTooltipName(GetTooltipNameEvent event, EntityRef entity, WildAnimalComponent wildAnimalComponent) {
event.setName(wildAnimalComponent.name);
}
/*
* Adds the Name inside WorldlyTooltip to show the DisplayName generated by the RandomNameGenerator
*/
@ReceiveEvent
public void addDisplayNameToTooltip(GetItemTooltip event, EntityRef entity, DisplayNameComponent displayNameComponent, WildAnimalComponent wildAnimalComponent) {
event.getTooltipLines().add(new TooltipLine("Name: " + displayNameComponent.name));
}
/*
* Adds the Icon to the WorldlyTooltip to show the corresponding WildAnimal's icon
*/
@ReceiveEvent
public void addIconToWorldlyTooltip(GetTooltipIconEvent event, EntityRef entity, WildAnimalComponent wildAnimalComponent) {
event.setIcon(wildAnimalComponent.icon);
}
}