creature template to object template
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-11 15:47:31 -04:00
parent 7217b5a5ba
commit d56d08204c
34 changed files with 231 additions and 200 deletions

View File

@ -1733,6 +1733,7 @@ Fix block generation thread filtering repairable structures
Catch errors in pathfinding threads
Remove old data classes
Update default block cursor size
Creature template -> object template

View File

@ -1,6 +1,6 @@
package electrosphere.client.entity.character;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
/**
* Describes a character
@ -15,7 +15,7 @@ public class CharacterDescriptionDTO {
/**
* The character's template data
*/
CreatureTemplate template;
ObjectTemplate template;
/**
* Gets the id of the character
@ -37,7 +37,7 @@ public class CharacterDescriptionDTO {
* Gets the creature template for the character
* @return The creature template
*/
public CreatureTemplate getTemplate() {
public ObjectTemplate getTemplate() {
return template;
}
@ -45,7 +45,7 @@ public class CharacterDescriptionDTO {
* Sets the creature template for the character
* @param template The creature template
*/
public void setTemplate(CreatureTemplate template) {
public void setTemplate(ObjectTemplate template) {
this.template = template;
}

View File

@ -9,7 +9,8 @@ import org.joml.Vector4d;
import electrosphere.client.entity.camera.CameraEntityUtils;
import electrosphere.engine.Globals;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.game.data.creature.type.CreatureData;
import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
@ -57,7 +58,7 @@ public class CharacterCustomizer {
* @param race The race of the character
* @return The panel component
*/
public static Element createCharacterCustomizerPanel(String race, Consumer<CreatureTemplate> onConfirm){
public static Element createCharacterCustomizerPanel(String race, Consumer<ObjectTemplate> onConfirm){
//figure out race data
CreatureData selectedRaceType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(race);
@ -81,7 +82,7 @@ public class CharacterCustomizer {
ActorStaticMorph staticMorph = new ActorStaticMorph();
//create creature template
CreatureTemplate template = CreatureTemplate.create(race);
ObjectTemplate template = ObjectTemplate.create(EntityType.CREATURE, race);
//create scrollable
ScrollableContainer scrollable = ScrollableContainer.createScrollable();

View File

@ -6,7 +6,7 @@ import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.Globals;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.net.parser.net.message.CharacterMessage;
import electrosphere.net.parser.net.message.TerrainMessage;
import electrosphere.renderer.ui.elements.Button;
@ -96,7 +96,7 @@ public class MenuCharacterCreation {
public static Element createCharacterCustomizationMenu(){
FormElement rVal = new FormElement();
rVal.addChild(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (CreatureTemplate template) -> {
rVal.addChild(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (ObjectTemplate template) -> {
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCreateCharacterMessage(Utilities.stringify(template)));
}));

View File

@ -8,7 +8,7 @@ import electrosphere.client.ui.menu.mainmenu.worldgen.MenuWorldSelect;
import electrosphere.engine.Globals;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.net.NetUtils;
import electrosphere.net.parser.net.message.CharacterMessage;
import electrosphere.renderer.ui.elements.Button;
@ -63,7 +63,7 @@ public class MenuGeneratorsMultiplayer {
createButton.addChild(createLabel);
rVal.addChild(createButton);
createButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
WindowUtils.replaceMainMenuContents(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (CreatureTemplate template) -> {
WindowUtils.replaceMainMenuContents(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (ObjectTemplate template) -> {
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCreateCharacterMessage(Utilities.stringify(template)));
}));
return false;

View File

@ -23,7 +23,7 @@ import electrosphere.entity.EntityCreationUtils;
import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.inventory.RelationalInventoryState;
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.game.data.common.CommonEntityType;
import electrosphere.game.data.crafting.RecipeData;
import electrosphere.game.data.creature.type.equip.EquipPoint;
@ -137,7 +137,7 @@ public class MenuGeneratorsUITesting {
formEl.addChild(panel);
} break;
case "CharacterCustomizer": {
formEl.addChild(CharacterCustomizer.createCharacterCustomizerPanel("human", (CreatureTemplate template) ->{}));
formEl.addChild(CharacterCustomizer.createCharacterCustomizerPanel("human", (ObjectTemplate template) ->{}));
} break;
case "NaturalInventoryPanel": {
Entity ent = EntityCreationUtils.TEST_createEntity();

View File

@ -14,7 +14,7 @@ import electrosphere.auth.AuthenticationManager;
import electrosphere.engine.Globals;
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.game.data.creature.type.CreatureData;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
import electrosphere.logger.LoggerInterface;
@ -153,7 +153,7 @@ public class LoadingUtils {
race = races.get(new Random().nextInt(races.size()));
}
CreatureData type = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(race);
CreatureTemplate template = CreatureTemplate.create(race);
ObjectTemplate template = ObjectTemplate.create(EntityType.CREATURE, race);
for(VisualAttribute attribute : type.getVisualAttributes()){
if(attribute.getType().equals(VisualAttribute.TYPE_BONE)){
float min = attribute.getMinValue();

View File

@ -77,7 +77,7 @@ public class EntityDataStrings {
public static final String TREE_CLIENTJUMPTREE = "treeClientJumpTree";
public static final String TREE_SERVERJUMPTREE = "treeServerJumpTree";
public static final String FALL_TREE = "fallTree";
public static final String CREATURE_TEMPLATE = "creatureTemplate";
public static final String OBJECT_TEMPLATE = "objectTemplate";
public static final String FIRST_PERSON_TREE = "firstPersonTree";

View File

@ -66,6 +66,8 @@ import electrosphere.entity.state.rotator.ServerRotatorTree;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.collision.CollisionObjUtils;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.creature.ObjectInventoryData;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.game.data.collidable.CollidableTemplate;
import electrosphere.game.data.common.CommonEntityType;
import electrosphere.game.data.creature.type.CreatureData;
@ -86,6 +88,7 @@ import electrosphere.game.data.item.Item;
import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.parser.net.message.NetworkMessage;
import electrosphere.net.server.player.Player;
import electrosphere.net.synchronization.transport.StateCollection;
import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.actor.ActorBoneRotator;
import electrosphere.renderer.actor.ActorUtils;
@ -93,6 +96,8 @@ import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
import electrosphere.server.entity.poseactor.PoseActor;
import electrosphere.server.entity.serialization.ContentSerialization;
import electrosphere.server.entity.serialization.EntitySerialization;
import electrosphere.util.math.SpatialMathUtils;
/**
@ -948,4 +953,52 @@ public class CommonEntityUtils {
entity.putData(EntityDataStrings.ENTITY_SUBTYPE, subtype);
}
/**
* Gets the template for the creature
* @param e The creature
* @return The template
*/
public static ObjectTemplate getObjectTemplate(Entity e){
ObjectTemplate template = (ObjectTemplate)e.getData(EntityDataStrings.OBJECT_TEMPLATE);
if(template == null){
return null;
}
ObjectInventoryData inventoryData = template.getInventoryData();
inventoryData.clear();
if(ServerEquipState.hasEquipState(e)){
ServerEquipState serverEquipState = ServerEquipState.getEquipState(e);
for(String point : serverEquipState.equippedPoints()){
Entity item = serverEquipState.getEquippedItemAtPoint(point);
EntitySerialization itemSerialized = ContentSerialization.constructEntitySerialization(item);
inventoryData.addEquippedItem(point, itemSerialized);
inventoryData.setEquippedId(point, item.getId());
}
}
if(InventoryUtils.hasToolbarInventory(e)){
RelationalInventoryState toolbarInventory = InventoryUtils.getToolbarInventory(e);
for(String slot : toolbarInventory.getSlots()){
Entity slotItem = toolbarInventory.getItemSlot(slot);
if(slotItem != null){
EntitySerialization itemSerialized = ContentSerialization.constructEntitySerialization(slotItem);
inventoryData.addToolbarItem(slot, itemSerialized);
inventoryData.setToolbarId(slot, slotItem.getId());
}
}
}
if(InventoryUtils.hasNaturalInventory(e)){
UnrelationalInventoryState toolbarInventory = InventoryUtils.getNaturalInventory(e);
int i = 0;
for(Entity item : toolbarInventory.getItems()){
if(item != null){
EntitySerialization itemSerialized = ContentSerialization.constructEntitySerialization(item);
inventoryData.addNaturalItem(itemSerialized);
inventoryData.setNaturalId(i, item.getId());
i++;
}
}
}
template.setStateCollection(StateCollection.getStateCollection(e));
return template;
}
}

View File

@ -22,8 +22,6 @@ import electrosphere.entity.state.equip.ServerEquipState;
import electrosphere.entity.state.equip.ServerToolbarState;
import electrosphere.entity.state.idle.ClientIdleTree;
import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.inventory.RelationalInventoryState;
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
import electrosphere.entity.types.EntityTypes.EntityType;
@ -37,7 +35,6 @@ import electrosphere.net.NetUtils;
import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.parser.net.message.NetworkMessage;
import electrosphere.net.server.player.Player;
import electrosphere.net.synchronization.transport.StateCollection;
import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.actor.ActorStaticMorph;
import electrosphere.server.datacell.Realm;
@ -58,7 +55,7 @@ public class CreatureUtils {
* @param template The creature template if applicable
* @return The creature entity
*/
public static Entity clientSpawnBasicCreature(String type, CreatureTemplate template){
public static Entity clientSpawnBasicCreature(String type, ObjectTemplate template){
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(type);
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
@ -73,7 +70,7 @@ public class CreatureUtils {
Actor creatureActor = EntityUtils.getActor(rVal);
//variants
CreatureTemplate storedTemplate = CreatureTemplate.create(rawType.getId());
ObjectTemplate storedTemplate = ObjectTemplate.create(EntityType.CREATURE, rawType.getId());
if(rawType.getVisualAttributes() != null){
ActorStaticMorph staticMorph = null;
for(VisualAttribute attributeType : rawType.getVisualAttributes()){
@ -138,7 +135,7 @@ public class CreatureUtils {
}
}
//set race
storedTemplate.creatureType = rawType.getId();
storedTemplate.objectType = rawType.getId();
//store template on creature
CreatureUtils.setCreatureTemplate(rVal, storedTemplate);
@ -153,13 +150,13 @@ public class CreatureUtils {
* @param creature The creature
* @param template The template
*/
public static void clientApplyTemplate(Entity creature, CreatureTemplate template){
public static void clientApplyTemplate(Entity creature, ObjectTemplate template){
//
//must happen after the player is attached to the entity, or server won't send packet to add item to player's entity
//now that creature has been spawned, need to create all attached items
if(template != null){
if(template.getInventoryData() != null){
CreatureInventoryData inventoryData = template.getInventoryData();
ObjectInventoryData inventoryData = template.getInventoryData();
for(Entry<String,EntitySerialization> toolbarItem : inventoryData.getToolbarItems()){
EntitySerialization serialization = toolbarItem.getValue();
String toolbarSlot = toolbarItem.getKey();
@ -210,7 +207,7 @@ public class CreatureUtils {
* @param template The creature template to use
* @return The creature entity
*/
public static Entity serverSpawnBasicCreature(Realm realm, Vector3d position, String type, CreatureTemplate template){
public static Entity serverSpawnBasicCreature(Realm realm, Vector3d position, String type, ObjectTemplate template){
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(type);
Entity rVal = EntityCreationUtils.createServerEntity(realm, position);
@ -230,7 +227,7 @@ public class CreatureUtils {
//variants
CreatureTemplate storedTemplate = CreatureTemplate.create(rawType.getId());
ObjectTemplate storedTemplate = ObjectTemplate.create(EntityType.CREATURE, rawType.getId());
if(rawType.getVisualAttributes() != null){
ActorStaticMorph staticMorph = null;
for(VisualAttribute attributeType : rawType.getVisualAttributes()){
@ -286,7 +283,7 @@ public class CreatureUtils {
}
}
//set race
storedTemplate.creatureType = rawType.getId();
storedTemplate.objectType = rawType.getId();
//store template on creature
CreatureUtils.setCreatureTemplate(rVal, storedTemplate);
@ -312,13 +309,13 @@ public class CreatureUtils {
* @param creature The creature
* @param template The template
*/
public static void serverApplyTemplate(Realm realm, Entity creature, CreatureTemplate template){
public static void serverApplyTemplate(Realm realm, Entity creature, ObjectTemplate template){
//
//must happen after the player is attached to the entity, or server won't send packet to add item to player's entity
//now that creature has been spawned, need to create all attached items
if(template != null){
if(template.getInventoryData() != null){
CreatureInventoryData inventoryData = template.getInventoryData();
ObjectInventoryData inventoryData = template.getInventoryData();
for(Entry<String,EntitySerialization> toolbarItem : inventoryData.getToolbarItems()){
EntitySerialization serialization = toolbarItem.getValue();
String toolbarSlot = toolbarItem.getKey();
@ -365,7 +362,7 @@ public class CreatureUtils {
*/
public static Entity clientCreateViewModel(
String type,
CreatureTemplate template
ObjectTemplate template
){
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(type);
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
@ -397,7 +394,7 @@ public class CreatureUtils {
int id = creature.getId();
Vector3d position = EntityUtils.getPosition(creature);
Quaterniond rotation = EntityUtils.getRotation(creature);
String template = Utilities.stringify(CreatureUtils.getCreatureTemplate(creature));
String template = Utilities.stringify(CommonEntityUtils.getObjectTemplate(creature));
NetworkMessage message = EntityMessage.constructCreateMessage(
id,
EntityType.CREATURE.getValue(),
@ -543,53 +540,8 @@ public class CreatureUtils {
return (ClientIdleTree)e.getData(EntityDataStrings.TREE_IDLE);
}
public static void setCreatureTemplate(Entity e, CreatureTemplate template){
e.putData(EntityDataStrings.CREATURE_TEMPLATE, template);
}
/**
* Gets the template for the creature
* @param e The creature
* @return The template
*/
public static CreatureTemplate getCreatureTemplate(Entity e){
CreatureTemplate template = (CreatureTemplate)e.getData(EntityDataStrings.CREATURE_TEMPLATE);
CreatureInventoryData inventoryData = template.getInventoryData();
inventoryData.clear();
if(ServerEquipState.hasEquipState(e)){
ServerEquipState serverEquipState = ServerEquipState.getEquipState(e);
for(String point : serverEquipState.equippedPoints()){
Entity item = serverEquipState.getEquippedItemAtPoint(point);
EntitySerialization itemSerialized = ContentSerialization.constructEntitySerialization(item);
inventoryData.addEquippedItem(point, itemSerialized);
inventoryData.setEquippedId(point, item.getId());
}
}
if(InventoryUtils.hasToolbarInventory(e)){
RelationalInventoryState toolbarInventory = InventoryUtils.getToolbarInventory(e);
for(String slot : toolbarInventory.getSlots()){
Entity slotItem = toolbarInventory.getItemSlot(slot);
if(slotItem != null){
EntitySerialization itemSerialized = ContentSerialization.constructEntitySerialization(slotItem);
inventoryData.addToolbarItem(slot, itemSerialized);
inventoryData.setToolbarId(slot, slotItem.getId());
}
}
}
if(InventoryUtils.hasNaturalInventory(e)){
UnrelationalInventoryState toolbarInventory = InventoryUtils.getNaturalInventory(e);
int i = 0;
for(Entity item : toolbarInventory.getItems()){
if(item != null){
EntitySerialization itemSerialized = ContentSerialization.constructEntitySerialization(item);
inventoryData.addNaturalItem(itemSerialized);
inventoryData.setNaturalId(i, item.getId());
i++;
}
}
}
template.setStateCollection(StateCollection.getStateCollection(e));
return template;
public static void setCreatureTemplate(Entity e, ObjectTemplate template){
e.putData(EntityDataStrings.OBJECT_TEMPLATE, template);
}

View File

@ -10,9 +10,9 @@ import java.util.Set;
import electrosphere.server.entity.serialization.EntitySerialization;
/**
* Inventory data for a creature template
* Inventory data for a object template
*/
public class CreatureInventoryData {
public class ObjectInventoryData {
/**
* Toolbar items

View File

@ -4,29 +4,35 @@ import java.util.HashMap;
import java.util.Map;
import electrosphere.engine.Globals;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.game.data.creature.type.CreatureData;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
import electrosphere.net.synchronization.transport.StateCollection;
/**
* The template used to construct the creature on the client
* The template used to construct the object on the client
*/
public class CreatureTemplate {
public class ObjectTemplate {
/**
* The type of the creature
* The type of the object
*/
String creatureType;
String objectType;
/**
* The category of entity
*/
EntityType entityType;
/**
* The attribute map for visual variants
*/
private Map<String,CreatureTemplateAttributeValue> attributeMap = new HashMap<String,CreatureTemplateAttributeValue>();
private Map<String,TemplateAttributeValue> attributeMap = new HashMap<String,TemplateAttributeValue>();
/**
* Data about the inventory of the creature
* Data about the inventory of the object
*/
private CreatureInventoryData inventoryData = new CreatureInventoryData();
private ObjectInventoryData inventoryData = new ObjectInventoryData();
/**
* The collection of synchronized values
@ -34,13 +40,15 @@ public class CreatureTemplate {
private StateCollection stateCollection;
/**
* Creates the creature template
* @param creatureType The type of creature
* @return The creature template
* Creates the object template
* @param category The category of entity
* @param subtype The type of object
* @return The object template
*/
public static CreatureTemplate create(String creatureType){
CreatureTemplate rVal = new CreatureTemplate();
rVal.creatureType = creatureType;
public static ObjectTemplate create(EntityType category, String subtype){
ObjectTemplate rVal = new ObjectTemplate();
rVal.entityType = category;
rVal.objectType = subtype;
return rVal;
}
@ -50,7 +58,7 @@ public class CreatureTemplate {
* @param value The value of the attribute
*/
public void putAttributeValue(String attributeName, float value){
attributeMap.put(attributeName,new CreatureTemplateAttributeValue(value));
attributeMap.put(attributeName,new TemplateAttributeValue(value));
}
/**
@ -59,7 +67,7 @@ public class CreatureTemplate {
* @param value The value of the attribute
*/
public void putAttributeValue(String attributeName, String value){
attributeMap.put(attributeName,new CreatureTemplateAttributeValue(value));
attributeMap.put(attributeName,new TemplateAttributeValue(value));
}
/**
@ -67,28 +75,28 @@ public class CreatureTemplate {
* @param attributeName The name of the attribute
* @return The value of the attribute
*/
public CreatureTemplateAttributeValue getAttributeValue(String attributeName){
public TemplateAttributeValue getAttributeValue(String attributeName){
return attributeMap.get(attributeName);
}
/**
* Gets the type of the creature
* @return The type of the creature
* Gets the type of the object
* @return The type of the object
*/
public String getCreatureType(){
return creatureType;
public String getObjectType(){
return objectType;
}
/**
* Gets the inventory data for the creature
* Gets the inventory data for the object
* @return The inventory data
*/
public CreatureInventoryData getInventoryData(){
public ObjectInventoryData getInventoryData(){
return this.inventoryData;
}
/**
* Gets the state collection for the creature
* Gets the state collection for the object
* @return The collection of synchronized values
*/
public StateCollection getStateCollection(){
@ -96,7 +104,7 @@ public class CreatureTemplate {
}
/**
* Sets the synchronized values for this creature
* Sets the synchronized values for this object
* @param stateCollection The synchronized values
*/
public void setStateCollection(StateCollection stateCollection){
@ -104,27 +112,29 @@ public class CreatureTemplate {
}
/**
* Creates a template for the creature with default values
* @param creatureType The type of creature
* Creates a template for the object with default values
* @param objectType The type of object
* @return The basic template
*/
public static CreatureTemplate createDefault(String creatureType){
CreatureTemplate storedTemplate = CreatureTemplate.create(creatureType);
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(creatureType);
if(rawType.getVisualAttributes() != null){
for(VisualAttribute attributeType : rawType.getVisualAttributes()){
if(attributeType.getType().equals("remesh")){
if(attributeType.getVariants() != null && attributeType.getVariants().size() > 0){
//make sure stored template contains creature data
if(storedTemplate.getAttributeValue(attributeType.getAttributeId())==null){
storedTemplate.putAttributeValue(attributeType.getAttributeId(), attributeType.getVariants().get(0).getId());
public static ObjectTemplate createDefault(EntityType category, String objectType){
ObjectTemplate storedTemplate = ObjectTemplate.create(category, objectType);
if(category == EntityType.CREATURE){
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(objectType);
if(rawType.getVisualAttributes() != null){
for(VisualAttribute attributeType : rawType.getVisualAttributes()){
if(attributeType.getType().equals("remesh")){
if(attributeType.getVariants() != null && attributeType.getVariants().size() > 0){
//make sure stored template contains creature data
if(storedTemplate.getAttributeValue(attributeType.getAttributeId())==null){
storedTemplate.putAttributeValue(attributeType.getAttributeId(), attributeType.getVariants().get(0).getId());
}
}
}
}
if(attributeType.getType().equals("bone")){
//make sure stored template contains creature data
float midpoint = (attributeType.getMaxValue() - attributeType.getMinValue())/2.0f + attributeType.getMinValue();
storedTemplate.putAttributeValue(attributeType.getAttributeId(), midpoint);
if(attributeType.getType().equals("bone")){
//make sure stored template contains creature data
float midpoint = (attributeType.getMaxValue() - attributeType.getMinValue())/2.0f + attributeType.getMinValue();
storedTemplate.putAttributeValue(attributeType.getAttributeId(), midpoint);
}
}
}
}
@ -132,9 +142,9 @@ public class CreatureTemplate {
}
/**
* A visual attribute of a creature (ie how wide is their nose, what type of hairstyle do they have, etc)
* A visual attribute of an object (ie how wide is their nose, what type of hairstyle do they have, etc)
*/
public class CreatureTemplateAttributeValue {
public class TemplateAttributeValue {
/**
* The string value of the attribute
@ -150,7 +160,7 @@ public class CreatureTemplate {
* Creates a float attribute
* @param value The value
*/
public CreatureTemplateAttributeValue(float value){
public TemplateAttributeValue(float value){
this.value = value;
}
@ -158,7 +168,7 @@ public class CreatureTemplate {
* Creates a string attribute
* @param variantId The string
*/
public CreatureTemplateAttributeValue(String variantId){
public TemplateAttributeValue(String variantId){
this.variantId = variantId;
}

View File

@ -14,7 +14,7 @@ import electrosphere.entity.state.physicssync.ClientPhysicsSyncTree;
import electrosphere.entity.types.EntityTypes;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.common.CommonEntityUtils;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.foliage.FoliageUtils;
import electrosphere.entity.types.item.ItemUtils;
@ -213,8 +213,8 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
*/
static Entity spawnCreature(EntityMessage message){
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Spawn Creature " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
CreatureTemplate template = Utilities.deserialize(message.getcreatureTemplate(), CreatureTemplate.class);
Entity newlySpawnedEntity = CreatureUtils.clientSpawnBasicCreature(template.getCreatureType(),template);
ObjectTemplate template = Utilities.deserialize(message.getcreatureTemplate(), ObjectTemplate.class);
Entity newlySpawnedEntity = CreatureUtils.clientSpawnBasicCreature(template.getObjectType(),template);
ClientEntityUtils.initiallyPositionEntity(
newlySpawnedEntity,
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),

View File

@ -1,6 +1,6 @@
package electrosphere.net.server;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.net.parser.net.message.AuthMessage;
@ -90,7 +90,7 @@ public class ServerConnectionHandler implements Runnable {
/**
* the creature template associated with this player
*/
CreatureTemplate currentCreatureTemplate;
ObjectTemplate currentCreatureTemplate;
/**
* the server protocol object associated with this player
@ -438,7 +438,7 @@ public class ServerConnectionHandler implements Runnable {
* Sets the current creature template for the connection
* @param currentCreatureTemplate The new creature template
*/
public void setCreatureTemplate(CreatureTemplate currentCreatureTemplate){
public void setCreatureTemplate(ObjectTemplate currentCreatureTemplate){
this.currentCreatureTemplate = currentCreatureTemplate;
}
@ -446,7 +446,7 @@ public class ServerConnectionHandler implements Runnable {
* Gets the current creature template for the connection
* @return The current template
*/
public CreatureTemplate getCurrentCreatureTemplate(){
public ObjectTemplate getCurrentCreatureTemplate(){
return this.currentCreatureTemplate;
}

View File

@ -16,7 +16,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.ServerEntityUtils;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.game.data.creature.type.CreatureData;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
import electrosphere.net.parser.net.message.CharacterMessage;
@ -67,11 +67,11 @@ public class CharacterProtocol implements ServerProtocolTemplate<CharacterMessag
public void handleSyncMessage(ServerConnectionHandler connectionHandler, CharacterMessage message) {
switch(message.getMessageSubtype()){
case REQUESTCREATECHARACTER: {
CreatureTemplate template = Utilities.deserialize(message.getdata(), CreatureTemplate.class);
ObjectTemplate template = Utilities.deserialize(message.getdata(), ObjectTemplate.class);
if(template != null){
Character charaData = Globals.characterService.createCharacter(template, connectionHandler.getPlayer().getDBID());
charaData.setPos(Globals.realmManager.first().getSpawnPoint());
connectionHandler.setCreatureTemplate(Utilities.deserialize(message.getdata(), CreatureTemplate.class));
connectionHandler.setCreatureTemplate(Utilities.deserialize(message.getdata(), ObjectTemplate.class));
connectionHandler.setCharacterId(charaData.getId());
connectionHandler.addMessagetoOutgoingQueue(CharacterMessage.constructResponseCreateCharacterSuccessMessage());
} else {
@ -128,7 +128,7 @@ public class CharacterProtocol implements ServerProtocolTemplate<CharacterMessag
*/
static Entity swapPlayerCharacter(ServerConnectionHandler connectionHandler){
//change the connection handler's creature template
if(connectionHandler.getCurrentCreatureTemplate() != null && connectionHandler.getCurrentCreatureTemplate().getCreatureType().matches(LoadingUtils.EDITOR_RACE_NAME)){
if(connectionHandler.getCurrentCreatureTemplate() != null && connectionHandler.getCurrentCreatureTemplate().getObjectType().matches(LoadingUtils.EDITOR_RACE_NAME)){
//solve what race to pick
String race = LoadingUtils.EDITOR_RACE_NAME;
List<String> races = Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces();
@ -137,7 +137,7 @@ public class CharacterProtocol implements ServerProtocolTemplate<CharacterMessag
}
//create template
CreatureData type = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(race);
CreatureTemplate template = CreatureTemplate.create(race);
ObjectTemplate template = ObjectTemplate.create(EntityType.CREATURE, race);
for(VisualAttribute attribute : type.getVisualAttributes()){
if(attribute.getType().equals(VisualAttribute.TYPE_BONE)){
float min = attribute.getMinValue();
@ -167,7 +167,7 @@ public class CharacterProtocol implements ServerProtocolTemplate<CharacterMessag
} else {
String race = LoadingUtils.EDITOR_RACE_NAME;
CreatureData type = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(race);
CreatureTemplate template = CreatureTemplate.create(race);
ObjectTemplate template = ObjectTemplate.create(EntityType.CREATURE, race);
for(VisualAttribute attribute : type.getVisualAttributes()){
if(attribute.getType().equals(VisualAttribute.TYPE_BONE)){
float min = attribute.getMinValue();

View File

@ -14,7 +14,7 @@ import electrosphere.entity.state.server.ServerCharacterData;
import electrosphere.entity.types.EntityTypes;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.common.CommonEntityUtils;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.foliage.FoliageUtils;
import electrosphere.entity.types.item.ItemUtils;
@ -71,8 +71,8 @@ public class ContentSerialization {
case CREATURE: {
serializedEntity.setType(EntityType.CREATURE.getValue());
serializedEntity.setSubtype(CommonEntityUtils.getEntitySubtype(entity));
if(CreatureUtils.getCreatureTemplate(entity) != null){
serializedEntity.setTemplate(Utilities.stringify(CreatureUtils.getCreatureTemplate(entity)));
if(CommonEntityUtils.getObjectTemplate(entity) != null){
serializedEntity.setTemplate(Utilities.stringify(CommonEntityUtils.getObjectTemplate(entity)));
}
} break;
case ITEM: {
@ -123,9 +123,9 @@ public class ContentSerialization {
}
switch(EntityTypes.fromInt(serializedEntity.getType())){
case CREATURE: {
CreatureTemplate template = null;
ObjectTemplate template = null;
if(serializedEntity.getTemplate() != null){
template = Utilities.deserialize(serializedEntity.getTemplate(), CreatureTemplate.class);
template = Utilities.deserialize(serializedEntity.getTemplate(), ObjectTemplate.class);
}
//
@ -162,9 +162,9 @@ public class ContentSerialization {
Entity rVal = null;
switch(EntityTypes.fromInt(serializedEntity.getType())){
case CREATURE: {
CreatureTemplate template = null;
ObjectTemplate template = null;
if(serializedEntity.getTemplate() != null){
template = Utilities.deserialize(serializedEntity.getTemplate(), CreatureTemplate.class);
template = Utilities.deserialize(serializedEntity.getTemplate(), ObjectTemplate.class);
}
//

View File

@ -6,7 +6,8 @@ import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.state.equip.ServerEquipState;
import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.game.data.units.UnitDefinition;
@ -39,7 +40,7 @@ public class UnitUtils {
LoggerInterface.loggerEngine.ERROR(new IllegalArgumentException("Tried to spawn unit with invalid creatureId! \"" + creatureId + "\""));
return null;
}
Entity rVal = CreatureUtils.serverSpawnBasicCreature(realm, position, creatureId, CreatureTemplate.createDefault(creatureId));
Entity rVal = CreatureUtils.serverSpawnBasicCreature(realm, position, creatureId, ObjectTemplate.createDefault(EntityType.CREATURE, creatureId));
//optionally apply ai
if(unitDefinition.getAI() != null){

View File

@ -5,7 +5,7 @@ import java.util.Map;
import org.joml.Vector3d;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.server.macro.character.data.CharacterData;
import electrosphere.server.macro.spatial.MacroObject;
@ -32,7 +32,7 @@ public class Character implements MacroObject {
/**
* The creature template
*/
CreatureTemplate creatureTemplate;
ObjectTemplate creatureTemplate;
/**
* The position of the character object
@ -103,7 +103,7 @@ public class Character implements MacroObject {
* Constructor
* @param template
*/
public Character(CreatureTemplate template){
public Character(ObjectTemplate template){
this.creatureTemplate = template;
}
@ -111,7 +111,7 @@ public class Character implements MacroObject {
* Gets the creature template for the character
* @return The template
*/
public CreatureTemplate getCreatureTemplate() {
public ObjectTemplate getCreatureTemplate() {
return creatureTemplate;
}
@ -119,7 +119,7 @@ public class Character implements MacroObject {
* Sets the creature template for the character
* @param creatureTemplate The template
*/
public void setCreatureTemplate(CreatureTemplate creatureTemplate) {
public void setCreatureTemplate(ObjectTemplate creatureTemplate) {
this.creatureTemplate = creatureTemplate;
}

View File

@ -3,7 +3,8 @@ package electrosphere.server.macro.character;
import org.joml.Vector3d;
import electrosphere.engine.Globals;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.server.datacell.Realm;
import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.character.data.CharacterAssociatedId;
@ -93,7 +94,7 @@ public class CharacterUtils {
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);
Character rVal = Globals.characterService.createCharacter(ObjectTemplate.createDefault(EntityType.CREATURE, creatureType), CharacterService.NO_PLAYER);
rVal.setPos(position);
Race.setRace(rVal, Race.create(race, creatureType));
realm.getDataCellManager().evaluateMacroObject(rVal);

View File

@ -7,7 +7,7 @@ import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.state.server.ServerCharacterData;
import electrosphere.entity.state.server.ServerPlayerViewDirTree;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.logger.LoggerInterface;
import electrosphere.net.server.ServerConnectionHandler;
@ -32,11 +32,11 @@ public class PlayerCharacterCreation {
//
//get template
Character charaData = Globals.characterService.getCharacter(connectionHandler.getCharacterId());
CreatureTemplate template = charaData.getCreatureTemplate();
ObjectTemplate template = charaData.getCreatureTemplate();
if(connectionHandler.getCharacterId() == CharacterProtocol.SPAWN_EXISTING_TEMPLATE){
template = connectionHandler.getCurrentCreatureTemplate();
}
String raceName = template.getCreatureType();
String raceName = template.getObjectType();
//
//spawn entity in world

View File

@ -16,8 +16,8 @@ import electrosphere.engine.signal.SignalServiceImpl;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.server.ServerCharacterData;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.common.CommonEntityUtils;
import electrosphere.logger.LoggerInterface;
import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.db.DatabaseResult;
@ -62,7 +62,7 @@ public class CharacterService extends SignalServiceImpl {
* @param template The creature template for the character
* @param playerId The player's id
*/
public Character createCharacter(CreatureTemplate template, int playerId){
public Character createCharacter(ObjectTemplate template, int playerId){
if(template == null){
throw new Error("Template is null!");
}
@ -155,7 +155,7 @@ public class CharacterService extends SignalServiceImpl {
Character charaData = characterData.getCharacterData();
//serialize
charaData.setCreatureTemplate(CreatureUtils.getCreatureTemplate(characterEntity));
charaData.setCreatureTemplate(CommonEntityUtils.getObjectTemplate(characterEntity));
charaData.setPos(EntityUtils.getPosition(characterEntity));
String toStore = SerializationUtils.serialize(charaData);
@ -254,10 +254,10 @@ public class CharacterService extends SignalServiceImpl {
public void saveAll(){
lock.lock();
for(Character chara : this.loadedCharacterMap.values()){
CreatureTemplate template = chara.getCreatureTemplate();
ObjectTemplate template = chara.getCreatureTemplate();
if(this.characterEntityMap.containsKey(chara)){
Entity characterEntity = this.characterEntityMap.get(chara);
template = CreatureUtils.getCreatureTemplate(characterEntity);
template = CommonEntityUtils.getObjectTemplate(characterEntity);
chara.setCreatureTemplate(template);
chara.setPos(EntityUtils.getPosition(characterEntity));
}

View File

@ -5,9 +5,9 @@ import java.util.stream.Collectors;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.types.creature.CreatureInventoryData;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.creature.ObjectInventoryData;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.common.CommonEntityUtils;
import electrosphere.server.entity.serialization.EntitySerialization;
import electrosphere.server.macro.character.Character;
@ -22,12 +22,12 @@ public class CharaInventoryUtils {
* @return The list of all items in the character's inventories
*/
public static List<EntitySerialization> getInventoryContents(Character chara){
CreatureTemplate template = chara.getCreatureTemplate();
ObjectTemplate template = chara.getCreatureTemplate();
if(CharaMacroUtils.isMicroSim(chara)){
Entity creature = Globals.characterService.getEntity(chara);
template = CreatureUtils.getCreatureTemplate(creature);
template = CommonEntityUtils.getObjectTemplate(creature);
}
CreatureInventoryData inventoryData = template.getInventoryData();
ObjectInventoryData inventoryData = template.getInventoryData();
return inventoryData.getAllItems();
}

View File

@ -6,8 +6,9 @@ import org.joml.Vector3d;
import org.junit.jupiter.api.Disabled;
import electrosphere.engine.Globals;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.common.CommonEntityUtils;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.foliage.FoliageUtils;
import electrosphere.entity.types.item.ItemUtils;
@ -36,7 +37,7 @@ public class SpawnAllEntitiesTests extends EntityTestTemplate {
CreatureTypeLoader creatureLoader = Globals.gameConfigCurrent.getCreatureTypeLoader();
for(CreatureData creature : creatureLoader.getTypes()){
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0.1,0.1,0.1), creature.getId(), CreatureTemplate.createDefault(creature.getId()));
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0.1,0.1,0.1), creature.getId(), ObjectTemplate.createDefault(EntityType.CREATURE, creature.getId()));
}
ItemDataMap itemMap = Globals.gameConfigCurrent.getItemMap();

View File

@ -6,7 +6,8 @@ import org.joml.Vector3d;
import electrosphere.test.annotations.IntegrationTest;
import electrosphere.engine.Globals;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.test.template.EntityTestTemplate;
import electrosphere.test.testutils.TestEntityUtils;
@ -19,7 +20,7 @@ public class SpawningCreaturesTest extends EntityTestTemplate {
//must wait on viewport testing, otherwise number of entities isn't going to be correct because the player character is spawning
@IntegrationTest
public void testSpawnCreature(){
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
assertEquals(1, TestEntityUtils.numberOfEntitiesInBox(new Vector3d(-1,-1,-1),new Vector3d(1,1,1)));
}
@ -28,7 +29,7 @@ public class SpawningCreaturesTest extends EntityTestTemplate {
public void testSpawnMultipleCreatures(){
int numberToSpawn = 100;
for(int i = 0; i < numberToSpawn; i++){
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
}
assertEquals(numberToSpawn, TestEntityUtils.numberOfEntitiesInBox(new Vector3d(-1,-1,-1),new Vector3d(1,1,1)));
}

View File

@ -14,7 +14,8 @@ import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.movement.fall.ServerFallTree;
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementRelativeFacing;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.test.template.EntityTestTemplate;
@ -35,7 +36,7 @@ public class ServerAttackTreeTests extends EntityTestTemplate {
TestEngineUtils.simulateFrames(1);
//spawn on server
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
//equip
@ -70,7 +71,7 @@ public class ServerAttackTreeTests extends EntityTestTemplate {
TestEngineUtils.simulateFrames(1);
//spawn on server
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
//equip

View File

@ -9,7 +9,8 @@ import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityTags;
import electrosphere.entity.state.movement.fall.ClientFallTree;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.test.template.EntityTestTemplate;
import electrosphere.test.testutils.TestEngineUtils;
@ -25,7 +26,7 @@ public class ClientCollidableTreeTests extends EntityTestTemplate {
TestEngineUtils.simulateFrames(1);
//spawn on server
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
//wait for the creature to land
TestEngineUtils.simulateFrames(3);

View File

@ -8,7 +8,8 @@ import electrosphere.test.annotations.IntegrationTest;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.state.movement.fall.ServerFallTree;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.test.template.EntityTestTemplate;
import electrosphere.test.testutils.TestEngineUtils;
@ -24,7 +25,7 @@ public class ServerCollidableTreeTests extends EntityTestTemplate {
TestEngineUtils.simulateFrames(1);
//spawn on server
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
//wait for the creature to land
TestEngineUtils.simulateFrames(3);

View File

@ -16,7 +16,8 @@ import electrosphere.entity.EntityTags;
import electrosphere.entity.state.attach.AttachUtils;
import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.test.template.EntityTestTemplate;
@ -39,7 +40,7 @@ public class ClientEquipStateTests extends EntityTestTemplate {
TestEngineUtils.simulateFrames(1);
//spawn entities
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human");
ObjectTemplate creatureTemplate = ObjectTemplate.createDefault(EntityType.CREATURE, "human");
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");

View File

@ -13,7 +13,8 @@ import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.state.attach.AttachUtils;
import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.test.template.EntityTestTemplate;
@ -31,7 +32,7 @@ public class ServerEquipStateTests extends EntityTestTemplate {
public void testServerEquipItem(){
TestEngineUtils.simulateFrames(1);
//spawn entities
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human");
ObjectTemplate creatureTemplate = ObjectTemplate.createDefault(EntityType.CREATURE, "human");
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
@ -63,7 +64,7 @@ public class ServerEquipStateTests extends EntityTestTemplate {
public void testServerFailEquipToOccupied(){
TestEngineUtils.simulateFrames(1);
//spawn entities
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human");
ObjectTemplate creatureTemplate = ObjectTemplate.createDefault(EntityType.CREATURE, "human");
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
Entity katana2 = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");

View File

@ -7,7 +7,8 @@ import org.joml.Vector3d;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.state.movement.jump.ClientJumpTree;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.test.annotations.IntegrationTest;
import electrosphere.test.template.EntityTestTemplate;
@ -21,7 +22,7 @@ public class ClientFallTreeTests extends EntityTestTemplate {
@IntegrationTest
public void isFalling_AtRest_false(){
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(), "human", CreatureTemplate.createDefault("human"));
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
ClientFallTree clientFallTree = ClientFallTree.getFallTree(clientEntity);
@ -30,7 +31,7 @@ public class ClientFallTreeTests extends EntityTestTemplate {
@IntegrationTest
public void isFalling_AfterJump_true(){
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(), "human", CreatureTemplate.createDefault("human"));
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
ClientFallTree clientFallTree = ClientFallTree.getFallTree(clientEntity);
@ -43,7 +44,7 @@ public class ClientFallTreeTests extends EntityTestTemplate {
@IntegrationTest
public void isFalling_AfterLand_false(){
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(), "human", CreatureTemplate.createDefault("human"));
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
ClientFallTree clientFallTree = ClientFallTree.getFallTree(clientEntity);

View File

@ -8,7 +8,8 @@ import org.joml.Vector3d;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.state.movement.jump.ServerJumpTree;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.test.annotations.IntegrationTest;
import electrosphere.test.template.EntityTestTemplate;
@ -22,7 +23,7 @@ public class ServerFallTreeTests extends EntityTestTemplate {
@IntegrationTest
public void isFalling_AtRest_false(){
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
ServerFallTree serverFallTree = ServerFallTree.getFallTree(creature);
assertEquals(false, serverFallTree.isFalling());
@ -30,7 +31,7 @@ public class ServerFallTreeTests extends EntityTestTemplate {
@IntegrationTest
public void isFalling_AfterJump_true(){
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
ServerFallTree serverFallTree = ServerFallTree.getFallTree(creature);
ServerJumpTree serverJumpTree = ServerJumpTree.getServerJumpTree(creature);
@ -45,7 +46,7 @@ public class ServerFallTreeTests extends EntityTestTemplate {
@IntegrationTest
public void isFalling_AfterLand_false(){
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
ServerFallTree serverFallTree = ServerFallTree.getFallTree(creature);
ServerJumpTree serverJumpTree = ServerJumpTree.getServerJumpTree(creature);

View File

@ -8,7 +8,8 @@ import electrosphere.test.annotations.IntegrationTest;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.ServerEntityUtils;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.server.ai.blackboard.Blackboard;
import electrosphere.server.ai.nodes.AITreeNode.AITreeNodeResult;
@ -26,7 +27,7 @@ public class MeleeTargetingNodeTests extends EntityTestTemplate {
//spawn test entities
Entity swordsman = UnitUtils.spawnUnit(Globals.realmManager.first(), new Vector3d(0,0,0), "humanSwordsman");
Entity target = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(1,0,0), "human", CreatureTemplate.createDefault("human"));
Entity target = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(1,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
//check if the swordsman can find a target
Blackboard blackboard = new Blackboard();

View File

@ -12,7 +12,8 @@ import electrosphere.engine.Globals;
import electrosphere.engine.Main;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.entity.Entity;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.net.server.ServerConnectionHandler;
import electrosphere.server.datacell.utils.EntityLookupUtils;
import electrosphere.server.macro.character.PlayerCharacterCreation;
@ -161,7 +162,7 @@ public class TestEngineUtils {
* @return The entity
*/
public static void spawnPlayerEntity(){
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human");
ObjectTemplate creatureTemplate = ObjectTemplate.createDefault(EntityType.CREATURE, "human");
ServerConnectionHandler serverConnection = Globals.server.getFirstConnection();
serverConnection.setCreatureTemplate(creatureTemplate);
Character chara = Globals.characterService.createCharacter(creatureTemplate, serverConnection.getPlayerId());

View File

@ -7,7 +7,8 @@ import org.joml.Vector3d;
import electrosphere.engine.Globals;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.entity.Entity;
import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.ObjectTemplate;
import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.net.NetUtils;
import electrosphere.net.server.ServerConnectionHandler;
@ -29,7 +30,7 @@ public class TestViewportUtils {
*/
public static Entity spawnPlayerCharacter(String creatureType){
//spawn creature
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault(creatureType);
ObjectTemplate creatureTemplate = ObjectTemplate.createDefault(EntityType.CREATURE, creatureType);
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), creatureType, creatureTemplate);
//get required data