Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
77 lines
2.6 KiB
Java
77 lines
2.6 KiB
Java
package electrosphere.server.macro.character;
|
|
|
|
import org.joml.Vector3d;
|
|
|
|
import electrosphere.engine.Globals;
|
|
import electrosphere.entity.types.creature.CreatureTemplate;
|
|
import electrosphere.server.datacell.Realm;
|
|
import electrosphere.server.macro.character.data.CharacterDataStrings;
|
|
import electrosphere.server.macro.character.diety.Diety;
|
|
import electrosphere.server.macro.race.Race;
|
|
import electrosphere.server.macro.structure.Structure;
|
|
import electrosphere.server.macro.town.Town;
|
|
import electrosphere.server.service.CharacterService;
|
|
|
|
/**
|
|
* Utility functions for dealing with characters
|
|
*/
|
|
public class CharacterUtils {
|
|
|
|
/**
|
|
* Default human for character stuff
|
|
*/
|
|
public static final String DEFAULT_RACE = "human";
|
|
|
|
/**
|
|
* Adds diety data for the character
|
|
* @param character The character
|
|
* @param diety The diety data
|
|
*/
|
|
public static void addDiety(Character character, Diety diety){
|
|
character.putData(CharacterDataStrings.DIETY, diety);
|
|
}
|
|
|
|
/**
|
|
* Gets diety data for the character
|
|
* @param character The character
|
|
* @return The diety data
|
|
*/
|
|
public static Diety getDiety(Character character){
|
|
return (Diety)character.getData(CharacterDataStrings.DIETY);
|
|
}
|
|
|
|
public static void addShelter(Character character, Structure shelter){
|
|
character.putData(CharacterDataStrings.SHELTER, shelter);
|
|
}
|
|
|
|
public static Structure getShelter(Character character){
|
|
return (Structure)character.getData(CharacterDataStrings.SHELTER);
|
|
}
|
|
|
|
public static void addHometown(Character character, Town town){
|
|
character.putData(CharacterDataStrings.HOMETOWN, town);
|
|
}
|
|
|
|
public static Town getHometown(Character character){
|
|
return (Town)character.getData(CharacterDataStrings.HOMETOWN);
|
|
}
|
|
|
|
/**
|
|
* Spawns a character
|
|
* @param realm The realm to spawn the character within
|
|
* @param position The position to create the character at
|
|
* @param race The race of the character to create
|
|
* @return The character
|
|
*/
|
|
public static Character spawnCharacter(Realm realm, Vector3d position, String race){
|
|
Race raceData = Globals.gameConfigCurrent.getRaceMap().getRace(race);
|
|
String creatureType = raceData.getAssociatedCreature();
|
|
Character rVal = Globals.characterService.createCharacter(CreatureTemplate.createDefault(creatureType), CharacterService.NO_PLAYER);
|
|
rVal.setPos(position);
|
|
Race.setRace(rVal, Race.create(race, creatureType));
|
|
realm.getDataCellManager().evaluateMacroObject(rVal);
|
|
return rVal;
|
|
}
|
|
|
|
}
|