skeleton of charge state
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
austin 2025-04-13 12:28:42 -04:00
parent 18cf677bd3
commit 0ae74d294f
7 changed files with 270 additions and 2 deletions

View File

@ -209,6 +209,8 @@ public class EntityDataStrings {
public static final String ITEM_WEAPON_DATA_RAW = "itemWeaponDataRaw"; public static final String ITEM_WEAPON_DATA_RAW = "itemWeaponDataRaw";
public static final String ITEM_IS_IN_INVENTORY = "itemIsInInventory"; public static final String ITEM_IS_IN_INVENTORY = "itemIsInInventory";
public static final String ITEM_CONTAINING_PARENT = "itemContainingParent"; public static final String ITEM_CONTAINING_PARENT = "itemContainingParent";
public static final String TREE_SERVERCHARGESTATE = "treeServerChargeState";
public static final String TREE_CLIENTCHARGESTATE = "treeClientChargeState";
/* /*

View File

@ -0,0 +1,117 @@
package electrosphere.entity.state.item;
import electrosphere.entity.Entity;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.engine.Globals;
import electrosphere.entity.EntityDataStrings;
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
@SynchronizedBehaviorTree(name = "clientChargeState", isServer = false, correspondingTree="serverChargeState")
/**
* Item charge state
*/
public class ClientChargeState implements BehaviorTree {
/**
* The charges on the item
*/
@SyncedField
int charges;
/**
* The parent of this state
*/
Entity parent;
/**
* Constructor
* @param parent The parent of this state
* @param params The params
*/
private ClientChargeState(Entity parent, Object ... params){
this.parent = parent;
}
/**
* <p> (initially) Automatically generated </p>
* <p>
* Attaches this tree to the entity.
* </p>
* @param entity The entity to attach to
* @param tree The behavior tree to attach
* @param params Optional parameters that will be provided to the constructor
*/
public static ClientChargeState attachTree(Entity parent, Object ... params){
ClientChargeState rVal = new ClientChargeState(parent,params);
//!!WARNING!! from here below should not be touched
//This was generated automatically to properly alert various systems that the btree exists and should be tracked
parent.putData(EntityDataStrings.TREE_CLIENTCHARGESTATE, rVal);
Globals.clientSceneWrapper.getScene().registerBehaviorTree(rVal);
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_CLIENTCHARGESTATE_ID);
return rVal;
}
/**
* <p> Automatically generated </p>
* <p>
* Detatches this tree from the entity.
* </p>
* @param entity The entity to detach to
* @param tree The behavior tree to detach
*/
public static void detachTree(Entity entity, BehaviorTree tree){
Globals.entityValueTrackingService.detatchTreeFromEntity(entity, BehaviorTreeIdEnums.BTREE_CLIENTCHARGESTATE_ID);
}
/**
* <p>
* Gets the ClientChargeState of the entity
* </p>
* @param entity the entity
* @return The ClientChargeState
*/
public static ClientChargeState getClientChargeState(Entity entity){
return (ClientChargeState)entity.getData(EntityDataStrings.TREE_CLIENTCHARGESTATE);
}
/**
* <p>
* Checks if the entity has a ClientChargeState component
* </p>
* @param entity the entity
* @return true if the entity contains the component, false otherwise
*/
public static boolean hasClientChargeState(Entity entity){
return entity.containsKey(EntityDataStrings.TREE_CLIENTCHARGESTATE);
}
/**
* <p> Automatically generated </p>
* <p>
* Sets charges and handles the synchronization logic for it.
* </p>
* @param charges The value to set charges to.
*/
public void setCharges(int charges){
this.charges = charges;
}
/**
* <p> Automatically generated </p>
* <p>
* Gets charges.
* </p>
*/
public int getCharges(){
return charges;
}
@Override
public void simulate(float deltaTime) {
}
}

View File

@ -0,0 +1,124 @@
package electrosphere.entity.state.item;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings;
import electrosphere.net.synchronization.enums.FieldIdEnums;
import electrosphere.server.datacell.utils.DataCellSearchUtils;
import electrosphere.net.parser.net.message.SynchronizationMessage;
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
@SynchronizedBehaviorTree(name = "serverChargeState", isServer = true, correspondingTree="clientChargeState")
/**
* Item charge state
*/
public class ServerChargeState implements BehaviorTree {
/**
* The charges on the item
*/
@SyncedField
int charges;
/**
* The parent of this state
*/
Entity parent;
/**
* Constructor
* @param parent The parent of this state
* @param params The params
*/
private ServerChargeState(Entity parent, Object ... params){
this.parent = parent;
}
/**
* <p> (initially) Automatically generated </p>
* <p>
* Attaches this tree to the entity.
* </p>
* @param entity The entity to attach to
* @param tree The behavior tree to attach
* @param params Optional parameters that will be provided to the constructor
*/
public static ServerChargeState attachTree(Entity parent, Object ... params){
ServerChargeState rVal = new ServerChargeState(parent,params);
//!!WARNING!! from here below should not be touched
//This was generated automatically to properly alert various systems that the btree exists and should be tracked
ServerBehaviorTreeUtils.attachBTreeToEntity(parent, rVal);
parent.putData(EntityDataStrings.TREE_SERVERCHARGESTATE, rVal);
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_SERVERCHARGESTATE_ID);
return rVal;
}
/**
* <p> Automatically generated </p>
* <p>
* Detatches this tree from the entity.
* </p>
* @param entity The entity to detach to
* @param tree The behavior tree to detach
*/
public static void detachTree(Entity entity, BehaviorTree tree){
Globals.entityValueTrackingService.detatchTreeFromEntity(entity, BehaviorTreeIdEnums.BTREE_SERVERCHARGESTATE_ID);
}
/**
* <p>
* Gets the ServerChargeState of the entity
* </p>
* @param entity the entity
* @return The ServerChargeState
*/
public static ServerChargeState getServerChargeState(Entity entity){
return (ServerChargeState)entity.getData(EntityDataStrings.TREE_SERVERCHARGESTATE);
}
/**
* <p>
* Checks if the entity has a ServerChargeState component
* </p>
* @param entity the entity
* @return true if the entity contains the component, false otherwise
*/
public static boolean hasServerChargeState(Entity entity){
return entity.containsKey(EntityDataStrings.TREE_SERVERCHARGESTATE);
}
/**
* <p> Automatically generated </p>
* <p>
* Sets charges and handles the synchronization logic for it.
* </p>
* @param charges The value to set charges to.
*/
public void setCharges(int charges){
this.charges = charges;
if(DataCellSearchUtils.getEntityDataCell(parent) != null){
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientIntStateMessage(parent.getId(), BehaviorTreeIdEnums.BTREE_SERVERCHARGESTATE_ID, FieldIdEnums.TREE_SERVERCHARGESTATE_SYNCEDFIELD_CHARGES_ID, charges));
}
}
/**
* <p> Automatically generated </p>
* <p>
* Gets charges.
* </p>
*/
public int getCharges(){
return charges;
}
@Override
public void simulate(float deltaTime) {
}
}

View File

@ -1,7 +1,7 @@
package electrosphere.net.synchronization.client; package electrosphere.net.synchronization.client;
import electrosphere.util.Utilities; import electrosphere.entity.state.item.ClientChargeState;
import electrosphere.entity.state.movement.editor.ClientEditorMovementTree; import electrosphere.entity.state.movement.editor.ClientEditorMovementTree;
import electrosphere.entity.state.equip.ClientToolbarState; import electrosphere.entity.state.equip.ClientToolbarState;
import electrosphere.entity.state.stance.ClientStanceComponent; import electrosphere.entity.state.stance.ClientStanceComponent;
@ -213,6 +213,14 @@ public class ClientSynchronizationManager {
} break; } break;
} }
} break; } break;
case BehaviorTreeIdEnums.BTREE_SERVERCHARGESTATE_ID: {
switch(message.getfieldId()){
case FieldIdEnums.TREE_SERVERCHARGESTATE_SYNCEDFIELD_CHARGES_ID:{
ClientChargeState tree = ClientChargeState.getClientChargeState(entity);
tree.setCharges(message.getintValue());
} break;
}
} break;
case BehaviorTreeIdEnums.BTREE_SERVERLIFETREE_ID: { case BehaviorTreeIdEnums.BTREE_SERVERLIFETREE_ID: {
switch(message.getfieldId()){ switch(message.getfieldId()){
case FieldIdEnums.TREE_SERVERLIFETREE_SYNCEDFIELD_STATE_ID:{ case FieldIdEnums.TREE_SERVERLIFETREE_SYNCEDFIELD_STATE_ID:{

View File

@ -17,6 +17,8 @@ public class BehaviorTreeIdEnums {
public static final int BTREE_SERVERGRAVITY_ID = 7; public static final int BTREE_SERVERGRAVITY_ID = 7;
public static final int BTREE_IDLE_ID = 8; public static final int BTREE_IDLE_ID = 8;
public static final int BTREE_SERVERIDLE_ID = 9; public static final int BTREE_SERVERIDLE_ID = 9;
public static final int BTREE_CLIENTCHARGESTATE_ID = 26;
public static final int BTREE_SERVERCHARGESTATE_ID = 27;
public static final int BTREE_CLIENTLIFETREE_ID = 6; public static final int BTREE_CLIENTLIFETREE_ID = 6;
public static final int BTREE_SERVERLIFETREE_ID = 13; public static final int BTREE_SERVERLIFETREE_ID = 13;
public static final int BTREE_CLIENTSTANCECOMPONENT_ID = 20; public static final int BTREE_CLIENTSTANCECOMPONENT_ID = 20;

View File

@ -21,6 +21,8 @@ public class FieldIdEnums {
public static final int TREE_SERVERGRAVITY_SYNCEDFIELD_STATE_ID = 11; public static final int TREE_SERVERGRAVITY_SYNCEDFIELD_STATE_ID = 11;
public static final int TREE_IDLE_SYNCEDFIELD_STATE_ID = 12; public static final int TREE_IDLE_SYNCEDFIELD_STATE_ID = 12;
public static final int TREE_SERVERIDLE_SYNCEDFIELD_STATE_ID = 13; public static final int TREE_SERVERIDLE_SYNCEDFIELD_STATE_ID = 13;
public static final int TREE_CLIENTCHARGESTATE_SYNCEDFIELD_CHARGES_ID = 34;
public static final int TREE_SERVERCHARGESTATE_SYNCEDFIELD_CHARGES_ID = 35;
public static final int TREE_CLIENTLIFETREE_SYNCEDFIELD_STATE_ID = 10; public static final int TREE_CLIENTLIFETREE_SYNCEDFIELD_STATE_ID = 10;
public static final int TREE_SERVERLIFETREE_SYNCEDFIELD_STATE_ID = 17; public static final int TREE_SERVERLIFETREE_SYNCEDFIELD_STATE_ID = 17;
public static final int TREE_CLIENTSTANCECOMPONENT_SYNCEDFIELD_STATE_ID = 28; public static final int TREE_CLIENTSTANCECOMPONENT_SYNCEDFIELD_STATE_ID = 28;

View File

@ -1,7 +1,8 @@
package electrosphere.net.synchronization.transport; package electrosphere.net.synchronization.transport;
import electrosphere.util.Utilities; import electrosphere.entity.state.item.ServerChargeState;
import electrosphere.entity.state.item.ClientChargeState;
import electrosphere.entity.state.movement.editor.ServerEditorMovementTree; import electrosphere.entity.state.movement.editor.ServerEditorMovementTree;
import electrosphere.entity.state.movement.editor.ClientEditorMovementTree; import electrosphere.entity.state.movement.editor.ClientEditorMovementTree;
import electrosphere.entity.state.equip.ServerToolbarState; import electrosphere.entity.state.equip.ServerToolbarState;
@ -96,6 +97,10 @@ public class StateCollection {
ServerIdleTree tree = ServerIdleTree.getServerIdleTree(entity); ServerIdleTree tree = ServerIdleTree.getServerIdleTree(entity);
collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERIDLE_ID,FieldIdEnums.TREE_SERVERIDLE_SYNCEDFIELD_STATE_ID,ClientIdleTree.getIdleTreeStateEnumAsShort(tree.getState()))); collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERIDLE_ID,FieldIdEnums.TREE_SERVERIDLE_SYNCEDFIELD_STATE_ID,ClientIdleTree.getIdleTreeStateEnumAsShort(tree.getState())));
} break; } break;
case BehaviorTreeIdEnums.BTREE_SERVERCHARGESTATE_ID: {
ServerChargeState tree = ServerChargeState.getServerChargeState(entity);
collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERCHARGESTATE_ID,FieldIdEnums.TREE_SERVERCHARGESTATE_SYNCEDFIELD_CHARGES_ID,tree.getCharges()));
} break;
case BehaviorTreeIdEnums.BTREE_SERVERLIFETREE_ID: { case BehaviorTreeIdEnums.BTREE_SERVERLIFETREE_ID: {
ServerLifeTree tree = ServerLifeTree.getServerLifeTree(entity); ServerLifeTree tree = ServerLifeTree.getServerLifeTree(entity);
collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERLIFETREE_ID,FieldIdEnums.TREE_SERVERLIFETREE_SYNCEDFIELD_STATE_ID,ClientLifeTree.getLifeStateEnumEnumAsShort(tree.getState()))); collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERLIFETREE_ID,FieldIdEnums.TREE_SERVERLIFETREE_SYNCEDFIELD_STATE_ID,ClientLifeTree.getLifeStateEnumEnumAsShort(tree.getState())));
@ -192,6 +197,14 @@ public class StateCollection {
} break; } break;
} }
} break; } break;
case BehaviorTreeIdEnums.BTREE_SERVERCHARGESTATE_ID: {
ClientChargeState tree = ClientChargeState.getClientChargeState(entity);
switch(syncedValue.getFieldId()){
case(FieldIdEnums.TREE_SERVERCHARGESTATE_SYNCEDFIELD_CHARGES_ID): {
tree.setCharges(((Double)syncedValue.getValue()).intValue());
} break;
}
} break;
case BehaviorTreeIdEnums.BTREE_SERVERLIFETREE_ID: { case BehaviorTreeIdEnums.BTREE_SERVERLIFETREE_ID: {
ClientLifeTree tree = ClientLifeTree.getClientLifeTree(entity); ClientLifeTree tree = ClientLifeTree.getClientLifeTree(entity);
switch(syncedValue.getFieldId()){ switch(syncedValue.getFieldId()){