mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-18 23:34:51 +01:00
Implement sending gifts
This commit is contained in:
60
src/main/java/emu/nebula/data/resources/CharacterDesDef.java
Normal file
60
src/main/java/emu/nebula/data/resources/CharacterDesDef.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package emu.nebula.data.resources;
|
||||
|
||||
import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import emu.nebula.data.ResourceType.LoadPriority;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = "CharacterDes.json", loadPriority = LoadPriority.LOW)
|
||||
public class CharacterDesDef extends BaseDef {
|
||||
private int Id;
|
||||
private int[] Tag;
|
||||
private IntOpenHashSet PreferTags;
|
||||
private IntOpenHashSet HateTags;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
public boolean isPreferGift(AffinityGiftDef gift) {
|
||||
if (this.getPreferTags() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < gift.getTags().length; i++) {
|
||||
int tag = gift.getTags()[i];
|
||||
if (this.getPreferTags().contains(tag)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isHateGift(AffinityGiftDef gift) {
|
||||
if (this.getHateTags() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < gift.getTags().length; i++) {
|
||||
int tag = gift.getTags()[i];
|
||||
if (this.getHateTags().contains(tag)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
var character = GameData.getCharacterDataTable().get(this.getId());
|
||||
if (character != null) {
|
||||
character.setDes(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user