Data cleanup
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-07-28 13:35:34 -04:00
parent 1578eb3780
commit ceb4786228
23 changed files with 412 additions and 411 deletions

View File

@ -183,21 +183,25 @@
},
{
"type" : "FALL",
"animationFall" : {
"name" : "Fall",
"length" : 1,
"loops" : true
"fallState" : {
"firstPersonAnimation" : {
"name" : "Fall",
"priority": 4
},
"thirdPersonAnimation" : {
"name" : "Fall",
"priority": 4
}
},
"animationFirstPersonFall" : {
"name" : "Fall"
},
"animationLand" : {
"name" : "Land",
"length" : 1,
"loops" : true
},
"animationFirstPersonLand" : {
"name" : "Land"
"landState" : {
"firstPersonAnimation" : {
"name" : "Land",
"priority": 4
},
"thirdPersonAnimation" : {
"name" : "Land",
"priority": 4
}
}
}
],

View File

@ -7,6 +7,10 @@ import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.game.data.common.TreeDataAnimation;
import electrosphere.game.data.common.TreeDataAudio;
import electrosphere.game.data.common.TreeDataState;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.actor.Actor;
import electrosphere.server.poseactor.PoseActor;
@ -79,7 +83,7 @@ public class StateTransitionUtil {
}
}
if(state == null){
throw new IllegalArgumentException("Trying to simulate state that is not registered with this util object");
LoggerInterface.loggerEngine.DEBUG("Skipping state " + stateEnum + " because there is not a state registered to that enum value!");
} else {
if(this.isServer){
simulateServerState(this.parent,state);
@ -98,49 +102,43 @@ public class StateTransitionUtil {
Actor actor = EntityUtils.getActor(parent);
if(actor != null){
//determine the third person animation to play
String animationToPlay = state.thirdPersonAnimation;
if(animationToPlay == null && state.getThirdPersonAnimation != null){
animationToPlay = state.getThirdPersonAnimation.get();
}
String thirdPersonAnimation = state.getThirdPersonAnimation();
//determine the first person animation to play
String firstPersonAnimation = state.firstPersonAnimation;
if(firstPersonAnimation == null && state.getFirstPersonAnimation != null){
firstPersonAnimation = state.getFirstPersonAnimation.get();
}
String firstPersonAnimation = state.getFirstPersonAnimation();
//Main simulation
if(!actor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true){
if(!actor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true && thirdPersonAnimation != null){
//state transition if this isn't set to loop
state.onComplete.run();
state.startedAnimation = false;
} else if(!actor.isPlayingAnimation() || !actor.isPlayingAnimation(animationToPlay)){
} else if(!actor.isPlayingAnimation() || !actor.isPlayingAnimation(thirdPersonAnimation)){
//play animation, audio, etc, for state
if(parent == Globals.playerEntity && !Globals.controlHandler.cameraIsThirdPerson()){
if(parent == Globals.playerEntity && !Globals.controlHandler.cameraIsThirdPerson() && thirdPersonAnimation != null){
//first person
//play first person audio
if(state.audioPath != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(state.audioPath, VirtualAudioSourceType.CREATURE, false);
if(state.audioData != null && state.audioData.getAudioPath() != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(state.audioData.getAudioPath(), VirtualAudioSourceType.CREATURE, false);
}
} else {
//play third person audio
if(state.audioPath != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(state.audioPath, VirtualAudioSourceType.CREATURE, false, EntityUtils.getPosition(parent));
if(state.audioData != null && state.audioData.getAudioPath() != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(state.audioData.getAudioPath(), VirtualAudioSourceType.CREATURE, false, EntityUtils.getPosition(parent));
}
}
actor.playAnimation(animationToPlay,state.animPriority);
actor.playAnimation(thirdPersonAnimation,state.getAnimationPriority());
actor.incrementAnimationTime(0.0001);
state.startedAnimation = true;
} else if(animationToPlay == null && state.onComplete != null){
} else if(thirdPersonAnimation == null && state.onComplete != null){
state.onComplete.run();
state.startedAnimation = false;
}
if(firstPersonAnimation != null){
FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, firstPersonAnimation, state.animPriority);
FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, firstPersonAnimation, state.getAnimationPriority());
}
}
}
@ -154,23 +152,20 @@ public class StateTransitionUtil {
PoseActor poseActor = EntityUtils.getPoseActor(parent);
if(poseActor != null){
//determine the third person animation to play
String animationToPlay = state.thirdPersonAnimation;
if(animationToPlay == null && state.getThirdPersonAnimation != null){
animationToPlay = state.getThirdPersonAnimation.get();
}
String thirdPersonAnimation = state.getThirdPersonAnimation();
//Main simulation
if(!poseActor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true){
if(!poseActor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true && thirdPersonAnimation != null){
//state transition if this isn't set to loop
state.onComplete.run();
state.startedAnimation = false;
} else if(animationToPlay != null && (!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animationToPlay))){
} else if(thirdPersonAnimation != null && (!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(thirdPersonAnimation))){
//play animation for state
poseActor.playAnimation(animationToPlay,state.animPriority);
poseActor.playAnimation(thirdPersonAnimation,state.getAnimationPriority());
poseActor.incrementAnimationTime(0.0001);
state.startedAnimation = true;
} else if(animationToPlay == null && state.onComplete != null){
} else if(thirdPersonAnimation == null && state.onComplete != null){
state.onComplete.run();
state.startedAnimation = false;
}
@ -188,20 +183,20 @@ public class StateTransitionUtil {
//the priority of this animation in particular
int animPriority;
//T1he animation to play in first person
String firstPersonAnimation;
//The animation to play in first person
TreeDataAnimation firstPersonAnimation;
//Gets the first person animation's name
Supplier<String> getFirstPersonAnimation;
//The animation to play in third person
String thirdPersonAnimation;
TreeDataAnimation thirdPersonAnimation;
//Gets the third person animation's name
Supplier<String> getThirdPersonAnimation;
//The audio path
String audioPath;
//The audio data
TreeDataAudio audioData;
//The function to fire on completion (ie to transition to the next state)
Runnable onComplete;
@ -209,150 +204,93 @@ public class StateTransitionUtil {
//Tracks whether the animation has been played or not
boolean startedAnimation = false;
/**
* Gets the animation to play for third person
* @return The animation's name
*/
String getThirdPersonAnimation(){
String toPlay = null;
if(thirdPersonAnimation != null){
toPlay = thirdPersonAnimation.getName();
}
if(getThirdPersonAnimation != null){
toPlay = getThirdPersonAnimation.get();
}
return toPlay;
}
/**
* Gets the animation to play for first person
* @return The animation's name
*/
String getFirstPersonAnimation(){
String toPlay = null;
if(firstPersonAnimation != null){
toPlay = firstPersonAnimation.getName();
}
if(getFirstPersonAnimation != null){
toPlay = getFirstPersonAnimation.get();
}
return toPlay;
}
/**
* Gets the animation priority
* @return The animation priority
*/
int getAnimationPriority(){
int priority = this.animPriority;
if(thirdPersonAnimation != null && thirdPersonAnimation.getPriority() != null){
priority = thirdPersonAnimation.getPriority();
}
return priority;
}
/**
* Constructor
*/
private StateTransitionUtilItem(
Object stateEnum,
int animPriority,
String firstPersonAnimation,
Supplier<String> getFirstPersonAnimation,
String thirdPersonAnimation,
Supplier<String> getThirdPersonAnimation,
String audioPath,
TreeDataAnimation firstPersonAnimation,
TreeDataAnimation thirdPersonAnimation,
TreeDataAudio audioData,
Runnable onComplete
){
this.stateEnum = stateEnum;
this.animPriority = animPriority;
this.firstPersonAnimation = firstPersonAnimation;
this.getFirstPersonAnimation = getFirstPersonAnimation;
this.thirdPersonAnimation = thirdPersonAnimation;
this.getThirdPersonAnimation = getThirdPersonAnimation;
this.audioPath = audioPath;
this.audioData = audioData;
this.onComplete = onComplete;
}
/**
* Constructor
* @param stateEnum The enum value for this state
* @param animPriority The priority of this state's animations
* @param firstPersonAnimation The animation to play in first person. If this is null, it will not play any animation in first person
* @param getFirstPersonAnimation The supplier for a first person animation name. If it is null, it will not play any animation in first person
* @param thirdPersonAnimation The animation to play in third person. If this is null, it will not play any animation in third person
* @param getThirdPersonAnimation The supplier for a third person animation name. If it is null, it will not play any animation in the third person
* @param audioPath The path to an audio file to play on starting the animation. If null, no audio will be played
* @param onComplete !!Must transition to the next state!! Fires when the animation completes. If not supplied, animations and autio will loop
* Constructor for supplier type
*/
public static StateTransitionUtilItem create(
private StateTransitionUtilItem(
Object stateEnum,
int animPriority,
String firstPersonAnimation,
Supplier<String> getFirstPersonAnimation,
String thirdPersonAnimation,
Supplier<String> getThirdPersonAnimation,
String audioPath,
TreeDataAudio audioData,
Runnable onComplete
){
return new StateTransitionUtilItem(
stateEnum,
animPriority,
firstPersonAnimation,
getFirstPersonAnimation,
thirdPersonAnimation,
getThirdPersonAnimation,
audioPath,
onComplete
);
){
this.stateEnum = stateEnum;
this.animPriority = animPriority;
this.getFirstPersonAnimation = getFirstPersonAnimation;
this.getThirdPersonAnimation = getThirdPersonAnimation;
this.audioData = audioData;
this.onComplete = onComplete;
}
/**
* Constructor
* @param stateEnum The enum value for this state
* @param animPriority The priority of this state's animations
* @param firstPersonAnimation The animation to play in first person. If this is null, it will not play any animation in first person
* @param thirdPersonAnimation The animation to play in third person. If this is null, it will not play any animation in third person
* @param audioPath The path to an audio file to play on starting the animation. If null, no audio will be played
* @param onComplete !!Must transition to the next state!! Fires when the animation completes. If not supplied, animations and autio will loop
*/
public static StateTransitionUtilItem create(
Object stateEnum,
int animPriority,
String firstPersonAnimation,
String thirdPersonAnimation,
String audioPath,
Runnable onComplete
){
return create(
stateEnum,
animPriority,
firstPersonAnimation,
null,
thirdPersonAnimation,
null,
audioPath,
onComplete
);
}
/**
* Constructor
* @param stateEnum The enum value for this state
* @param animPriority The priority of this state's animations
* @param firstPersonAnimation The animation to play in first person. If this is null, it will not play any animation in first person
* @param thirdPersonAnimation The animation to play in third person. If this is null, it will not play any animation in third person
* @param audioPath The path to an audio file to play on starting the animation. If null, no audio will be played
*/
public static StateTransitionUtilItem create(
Object stateEnum,
int animPriority,
String firstPersonAnimation,
String thirdPersonAnimation,
String audioPath
){
return create(
stateEnum,
animPriority,
firstPersonAnimation,
null,
thirdPersonAnimation,
null,
audioPath,
null
);
}
/**
* Constructor
* @param stateEnum The enum value for this state
* @param animPriority The priority of this state's animations
* @param thirdPersonAnimation The animation to play in third person. If this is null, it will not play any animation in third person
* @param onComplete !!Must transition to the next state!! Fires when the animation completes. If not supplied, animations and autio will loop
*/
public static StateTransitionUtilItem create(
Object stateEnum,
int animPriority,
String thirdPersonAnimation,
Runnable onComplete
){
return create(
stateEnum,
animPriority,
null,
null,
thirdPersonAnimation,
null,
null,
onComplete
);
}
/**
* Constructor
* Constructor for a supplier-based approach. This takes suppliers that will provide animation data on demand.
* This decouples the animations from the initialization of the tree.
* The intended usecase is if the animation could change based on some state in the tree.
* @param stateEnum The enum value for this state
* @param animPriority The priority of this state's animations
* @param getFirstPersonAnimation The supplier for a first person animation name. If it is null, it will not play any animation in first person
* @param getThirdPersonAnimation The supplier for a third person animation name. If it is null, it will not play any animation in the third person
* @param audioPath The path to an audio file to play on starting the animation. If null, no audio will be played
* @param audioData The path to an audio file to play on starting the animation. If null, no audio will be played
* @param onComplete !!Must transition to the next state!! Fires when the animation completes. If not supplied, animations and autio will loop
*/
public static StateTransitionUtilItem create(
@ -360,119 +298,41 @@ public class StateTransitionUtil {
int animPriority,
Supplier<String> getFirstPersonAnimation,
Supplier<String> getThirdPersonAnimation,
String audioPath,
TreeDataAudio audioData,
Runnable onComplete
){
return new StateTransitionUtilItem(
stateEnum,
animPriority,
null,
getFirstPersonAnimation,
null,
getThirdPersonAnimation,
audioPath,
audioData,
onComplete
);
}
/**
* Constructor
* @param stateEnum The enum value for this state
* @param animPriority The priority of this state's animations
* @param getFirstPersonAnimation The supplier for a first person animation name. If it is null, it will not play any animation in first person
* @param getThirdPersonAnimation The supplier for a third person animation name. If it is null, it will not play any animation in the third person
* @param onComplete !!Must transition to the next state!! Fires when the animation completes. If not supplied, animations and autio will loop
* Creates a state transition based on tree data for the state
* @param stateEnum The enum value for this state in particular in the tree
* @param treeData The tree data for this state
* @return The item for the transition util
*/
public static StateTransitionUtilItem create(
Object stateEnum,
int animPriority,
Supplier<String> getFirstPersonAnimation,
Supplier<String> getThirdPersonAnimation,
TreeDataState treeData,
Runnable onComplete
){
return new StateTransitionUtilItem(
stateEnum,
animPriority,
null,
getFirstPersonAnimation,
null,
getThirdPersonAnimation,
null,
onComplete
);
}
/**
* Constructor
* @param stateEnum The enum value for this state
* @param animPriority The priority of this state's animations
* @param getThirdPersonAnimation The supplier for a third person animation name. If it is null, it will not play any animation in the third person
* @param onComplete !!Must transition to the next state!! Fires when the animation completes. If not supplied, animations and autio will loop
*/
public static StateTransitionUtilItem create(
Object stateEnum,
int animPriority,
Supplier<String> getThirdPersonAnimation,
Runnable onComplete
){
return new StateTransitionUtilItem(
stateEnum,
animPriority,
null,
null,
null,
getThirdPersonAnimation,
null,
onComplete
);
}
/**
* Constructor
* @param stateEnum The enum value for this state
* @param animPriority The priority of this state's animations
* @param getThirdPersonAnimation The supplier for a third person animation name. If it is null, it will not play any animation in the third person
*/
public static StateTransitionUtilItem create(
Object stateEnum,
int animPriority,
Supplier<String> getThirdPersonAnimation
){
return new StateTransitionUtilItem(
stateEnum,
animPriority,
null,
null,
null,
getThirdPersonAnimation,
null,
null
);
}
/**
* Constructor
* @param stateEnum The enum value for this state
* @param animPriority The priority of this state's animations
* @param getFirstPersonAnimation The supplier for a first person animation name. If it is null, it will not play any animation in first person
* @param getThirdPersonAnimation The supplier for a third person animation name. If it is null, it will not play any animation in the third person
*/
public static StateTransitionUtilItem create(
Object stateEnum,
int animPriority,
Supplier<String> getFirstPersonAnimation,
Supplier<String> getThirdPersonAnimation
){
return new StateTransitionUtilItem(
stateEnum,
animPriority,
null,
getFirstPersonAnimation,
null,
getThirdPersonAnimation,
null,
null
);
){
StateTransitionUtilItem rVal = null;
if(treeData != null){
rVal = new StateTransitionUtilItem(
stateEnum,
treeData.getFirstPersonAnimation(),
treeData.getThirdPersonAnimation(),
treeData.getAudioData(),
onComplete
);
}
return rVal;
}

View File

@ -42,4 +42,10 @@ public class AnimationPriorities {
//
public static final int IDLE = 10;
//
//50
//
public static final int DEFAULT = 50;
}

View File

@ -58,19 +58,25 @@ public class ClientBlockTree implements BehaviorTree {
BlockState.WIND_UP,
AnimationPriorities.BLOCK,
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getWindUpFirstPersonAnimation();},
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getWindUpAnimation();}
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getWindUpAnimation();},
null,
null
),
StateTransitionUtilItem.create(
BlockState.BLOCKING,
AnimationPriorities.BLOCK,
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getMainFirstPersonAnimation();},
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getMainAnimation();}
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getMainAnimation();},
null,
null
),
StateTransitionUtilItem.create(
BlockState.COOLDOWN,
AnimationPriorities.BLOCK,
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getCooldownFirstPersonAnimation();},
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getCooldownAnimation();}
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getCooldownAnimation();},
null,
null
),
});
}

View File

@ -51,18 +51,25 @@ public class ServerBlockTree implements BehaviorTree {
StateTransitionUtilItem.create(
BlockState.WIND_UP,
AnimationPriorities.BLOCK,
null,
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getWindUpAnimation();},
null,
() -> {this.setState(BlockState.BLOCKING);}
),
StateTransitionUtilItem.create(
BlockState.BLOCKING,
AnimationPriorities.BLOCK,
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getMainAnimation();}
null,
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getMainAnimation();},
null,
null
),
StateTransitionUtilItem.create(
BlockState.COOLDOWN,
AnimationPriorities.BLOCK,
null,
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getCooldownAnimation();},
null,
() -> {this.setState(BlockState.NOT_BLOCKING);}
),
});

View File

@ -5,7 +5,6 @@ import electrosphere.net.synchronization.BehaviorTreeIdEnums;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.btree.StateTransitionUtil;
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
import electrosphere.entity.state.AnimationPriorities;
import electrosphere.game.data.creature.type.HealthSystem;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.Entity;
@ -120,10 +119,8 @@ public class ClientLifeTree implements BehaviorTree {
stateTransitionUtil = StateTransitionUtil.create(parent, false, new StateTransitionUtilItem[]{
StateTransitionUtilItem.create(
LifeStateEnum.DYING,
AnimationPriorities.DEATH,
healthSystem.getDyingFirstPersonAnimation(),
healthSystem.getDyingThirdPersonAnimation(),
healthSystem.getAudioPath()
healthSystem.getDyingState(),
() -> {}
)
});
}

View File

@ -13,7 +13,6 @@ import electrosphere.net.parser.net.message.SynchronizationMessage;
import electrosphere.server.datacell.utils.DataCellSearchUtils;
import electrosphere.engine.Globals;
import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.life.ClientLifeTree.LifeStateEnum;
import electrosphere.game.data.creature.type.HealthSystem;
import electrosphere.net.synchronization.annotation.SyncedField;
@ -177,8 +176,7 @@ public class ServerLifeTree implements BehaviorTree {
stateTransitionUtil = StateTransitionUtil.create(parent, true, new StateTransitionUtilItem[]{
StateTransitionUtilItem.create(
LifeStateEnum.DYING,
AnimationPriorities.DEATH,
this.healthSystem.getDyingThirdPersonAnimation(),
this.healthSystem.getDyingState(),
() -> {
this.setState(LifeStateEnum.DEAD);
}

View File

@ -5,6 +5,8 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.btree.StateTransitionUtil;
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.game.data.creature.type.movement.FallMovementSystem;
@ -35,26 +37,30 @@ public class FallTree implements BehaviorTree {
//the related jump tree
JumpTree jumpTree;
//The state transition util
StateTransitionUtil stateTransitionUtil;
public FallTree(Entity parent, FallMovementSystem fallMovementSystem){
this.parent = parent;
this.fallMovementSystem = fallMovementSystem;
stateTransitionUtil = StateTransitionUtil.create(
parent,
false,
new StateTransitionUtilItem[]{
StateTransitionUtilItem.create(
FallState.ACTIVE,
fallMovementSystem.getFallState(),
null
)
}
);
}
@Override
public void simulate(float deltaTime) {
Actor entityActor = EntityUtils.getActor(parent);
switch(state){
case ACTIVE:
if(entityActor != null){
if(
!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(fallMovementSystem.getAnimationFall().getName()) &&
(jumpTree == null || !jumpTree.isJumping())
){
entityActor.playAnimation(fallMovementSystem.getAnimationFall().getName(),AnimationPriorities.FALL);
entityActor.incrementAnimationTime(0.0001);
}
FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, fallMovementSystem.getAnimationFirstPersonFall().getName(), AnimationPriorities.FALL);
}
stateTransitionUtil.simulate(FallState.ACTIVE);
break;
case INACTIVE:
break;
@ -85,12 +91,12 @@ public class FallTree implements BehaviorTree {
Actor entityActor = EntityUtils.getActor(parent);
if(entityActor != null){
if(
!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(fallMovementSystem.getAnimationLand().getName())
!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(fallMovementSystem.getLandState().getThirdPersonAnimation().getName())
){
entityActor.playAnimation(fallMovementSystem.getAnimationLand().getName(),AnimationPriorities.LAND);
entityActor.playAnimation(fallMovementSystem.getLandState().getThirdPersonAnimation().getName(),AnimationPriorities.LAND);
entityActor.incrementAnimationTime(0.0001);
}
FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, fallMovementSystem.getAnimationFirstPersonLand().getName(), AnimationPriorities.LAND);
FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, fallMovementSystem.getLandState().getFirstPersonAnimation().getName(), AnimationPriorities.LAND);
}
}
}

View File

@ -5,6 +5,7 @@ import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.AnimationPriorities;
import electrosphere.game.data.creature.type.movement.FallMovementSystem;
import electrosphere.server.poseactor.PoseActor;
public class ServerFallTree implements BehaviorTree {
@ -23,7 +24,7 @@ public class ServerFallTree implements BehaviorTree {
ServerJumpTree jumpTree;
public ServerFallTree(Entity parent){
public ServerFallTree(Entity parent, FallMovementSystem fallMovementSystem){
this.parent = parent;
}

View File

@ -1,7 +1,6 @@
package electrosphere.entity.state.movement.groundmove;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.net.synchronization.FieldIdEnums;
import electrosphere.net.parser.net.message.SynchronizationMessage;

View File

@ -474,13 +474,7 @@ public class CreatureUtils {
// Falling
case FallMovementSystem.FALL_MOVEMENT_SYSTEM:
FallMovementSystem fallMovementSystem = (FallMovementSystem)movementSystem;
ServerFallTree fallTree = new ServerFallTree(rVal);
if(fallMovementSystem.getAnimationFall()!=null){
fallTree.setAnimationFall(fallMovementSystem.getAnimationFall().getName());
}
if(fallMovementSystem.getAnimationLand()!=null){
fallTree.setAnimationLand(fallMovementSystem.getAnimationLand().getName());
}
ServerFallTree fallTree = new ServerFallTree(rVal,fallMovementSystem);
if(CreatureUtils.serverGetEntityMovementTree(rVal) != null && CreatureUtils.serverGetEntityMovementTree(rVal) instanceof ClientGroundMovementTree){
((ServerGroundMovementTree)CreatureUtils.serverGetEntityMovementTree(rVal)).setServerFallTree(fallTree);
}

View File

@ -0,0 +1,60 @@
package electrosphere.game.data.common;
/**
* Data about an animation
*/
public class TreeDataAnimation {
/**
* The name of the animation if it exists, null otherwise
*/
String name;
/**
* The length of the animation in frames if it exists, null otherwise
*/
int length;
/**
* If boolean, should loop if it exists, null otherwise
*/
boolean loops;
/**
* The priority for this animation in particular
*/
Integer priority;
/**
* Gets the name of the animation
* @return The name of the animation
*/
public String getName() {
return name;
}
/**
* Gets the length of the animation in frames
* @return The length in number of frames
*/
public int getLength() {
return length;
}
/**
* Gets whether the animation loops or not
* @return true if loops, false otherwise
*/
public boolean isLoops() {
return loops;
}
/**
* Gets the priority for this animation
* @return The priority
*/
public Integer getPriority(){
return priority;
}
}

View File

@ -0,0 +1,21 @@
package electrosphere.game.data.common;
/**
* Audio data to use when running a given tree state
*/
public class TreeDataAudio {
/**
* The path to the audio file to play if it exists, null otherwise
*/
String audioPath;
/**
* Gets the audio path
*/
public String getAudioPath(){
return audioPath;
}
}

View File

@ -0,0 +1,47 @@
package electrosphere.game.data.common;
/**
* A simple tree state
*/
public class TreeDataState {
/**
* The animation to play for the tree's state when in first person
*/
TreeDataAnimation firstPersonAnimation;
/**
* The animation to play for the tree's state when in third person
*/
TreeDataAnimation thirdPersonAnimation;
/**
* The audio to play when running this state of the tree
*/
TreeDataAudio audioData;
/**
* Gets the first person animation data
* @return The first person animation data if it exists, null otherwise
*/
public TreeDataAnimation getFirstPersonAnimation(){
return firstPersonAnimation;
}
/**
* Gets the third person animation data
* @return The third person animation data if it exists, null otherwise
*/
public TreeDataAnimation getThirdPersonAnimation(){
return thirdPersonAnimation;
}
/**
* Gets the audio data
* @return The audio data if it exists, null otherwise
*/
public TreeDataAudio getAudioData(){
return audioData;
}
}

View File

@ -1,24 +0,0 @@
package electrosphere.game.data.creature.type;
/**
* Data about an animation
*/
public class Animation {
String name;
int length;
boolean loops;
public String getName() {
return name;
}
public int getLength() {
return length;
}
public boolean isLoops() {
return loops;
}
}

View File

@ -6,6 +6,7 @@ import electrosphere.game.data.creature.type.ai.AITreeData;
import electrosphere.game.data.creature.type.attack.AttackMove;
import electrosphere.game.data.creature.type.attack.AttackMoveResolver;
import electrosphere.game.data.creature.type.block.BlockSystem;
import electrosphere.game.data.creature.type.bonegroups.BoneGroup;
import electrosphere.game.data.creature.type.equip.EquipPoint;
import electrosphere.game.data.creature.type.movement.MovementSystem;
import electrosphere.game.data.creature.type.rotator.RotatorSystem;
@ -103,6 +104,11 @@ public class CreatureType {
*/
AttackMoveResolver attackMoveResolver;
/**
* The list of bone groups for this creature
*/
List<BoneGroup> boneGroups;
/**
* Gets the id for this creature type
* @return The id
@ -247,5 +253,13 @@ public class CreatureType {
return aiTrees;
}
/**
* Gets the list of bone groups for this creature
* @return The list of bone groups
*/
public List<BoneGroup> getBoneGroups(){
return boneGroups;
}
}

View File

@ -1,5 +1,7 @@
package electrosphere.game.data.creature.type;
import electrosphere.game.data.common.TreeDataState;
/**
* Data about the health of a creature
*/
@ -11,14 +13,10 @@ public class HealthSystem {
//the number of iframes on taking damage
int onDamageIFrames;
//the third person animation to play when the entity is dying
String dyingThirdPersonAnimation;
//the first person animation to play when the entity is dying
String dyingFirstPersonAnimation;
//The audio file to play when the entity dies
String audioPath;
/**
* The dying state
*/
TreeDataState dyingState;
/**
* Gets the maximum health
@ -37,27 +35,11 @@ public class HealthSystem {
}
/**
* Gets the animation to play in third person when the entity is dying
* @return The animation
* Gets the dying state data
* @return The dying state data
*/
public String getDyingThirdPersonAnimation(){
return dyingThirdPersonAnimation;
}
/**
* Gets the animation to play in first person when the entity is dying
* @return The animation
*/
public String getDyingFirstPersonAnimation(){
return dyingFirstPersonAnimation;
}
/**
* Gets the audio path to play when the entity is dying
* @return The audio path
*/
public String getAudioPath(){
return audioPath;
public TreeDataState getDyingState(){
return dyingState;
}
/**
@ -67,8 +49,7 @@ public class HealthSystem {
HealthSystem rVal = new HealthSystem();
rVal.maxHealth = maxHealth;
rVal.onDamageIFrames = onDamageIFrames;
rVal.dyingThirdPersonAnimation = dyingThirdPersonAnimation;
rVal.dyingFirstPersonAnimation = dyingFirstPersonAnimation;
rVal.dyingState = dyingState;
return rVal;
}

View File

@ -1,24 +1,26 @@
package electrosphere.game.data.creature.type;
import electrosphere.game.data.common.TreeDataAnimation;
/**
* Sprint data
*/
public class SprintSystem {
Animation animationStartUp;
Animation animationMain;
Animation animationWindDown;
TreeDataAnimation animationStartUp;
TreeDataAnimation animationMain;
TreeDataAnimation animationWindDown;
float maxVelocity;
int staminaMax;
public Animation getAnimationStartUp() {
public TreeDataAnimation getAnimationStartUp() {
return animationStartUp;
}
public Animation getAnimationMain() {
public TreeDataAnimation getAnimationMain() {
return animationMain;
}
public Animation getAnimationWindDown() {
public TreeDataAnimation getAnimationWindDown() {
return animationWindDown;
}

View File

@ -1,6 +1,6 @@
package electrosphere.game.data.creature.type.attack;
import electrosphere.game.data.creature.type.Animation;
import electrosphere.game.data.common.TreeDataAnimation;
/**
* Data about a single attack move this creature is capable of
@ -20,9 +20,9 @@ public class AttackMove {
String holdAnimationName;
String attackAnimationName;
Animation animationFirstPersonWindup;
Animation animationFirstPersonHold;
Animation animationFirstPersonAttack;
TreeDataAnimation animationFirstPersonWindup;
TreeDataAnimation animationFirstPersonHold;
TreeDataAnimation animationFirstPersonAttack;
/*
Damage stuff
@ -92,7 +92,7 @@ public class AttackMove {
* Gets the animation data for the 1st person windup
* @return the animation data
*/
public Animation getAnimationFirstPersonWindup(){
public TreeDataAnimation getAnimationFirstPersonWindup(){
return animationFirstPersonWindup;
}
@ -100,7 +100,7 @@ public class AttackMove {
* Gets the animation data for the 1st person hold
* @return the animation data
*/
public Animation getAnimationFirstPersonHold(){
public TreeDataAnimation getAnimationFirstPersonHold(){
return animationFirstPersonHold;
}
@ -108,7 +108,7 @@ public class AttackMove {
* Gets the animation data for the 1st person attack
* @return the animation data
*/
public Animation getAnimationFirstPersonAttack(){
public TreeDataAnimation getAnimationFirstPersonAttack(){
return animationFirstPersonAttack;
}

View File

@ -0,0 +1,36 @@
package electrosphere.game.data.creature.type.bonegroups;
import java.util.List;
/**
* Groups of bones that can be used for functions (ie priority on animations, hitbox data macros, etc)
*/
public class BoneGroup {
/**
* The id for the bone group
*/
String id;
/**
* The list of names of bones that are within this group
*/
List<String> boneNames;
/**
* Gets the id of the bone group
* @return The bone group id
*/
public String getId(){
return id;
}
/**
* Gets the list of names of bones in the group
* @return The list of names of bones
*/
public List<String> getBoneNames(){
return boneNames;
}
}

View File

@ -1,54 +1,40 @@
package electrosphere.game.data.creature.type.movement;
import electrosphere.game.data.creature.type.Animation;
import electrosphere.game.data.common.TreeDataState;
/**
* Data about a falling movement system
*/
public class FallMovementSystem implements MovementSystem {
/**
* The name of this movement system type in particular
*/
public static final String FALL_MOVEMENT_SYSTEM = "FALL";
//The type of movement syste,
String type;
//Fall data
Animation animationFall;
Animation animationFirstPersonFall;
//Falling data
TreeDataState fallState;
//landing data
Animation animationLand;
Animation animationFirstPersonLand;
//Landing data
TreeDataState landState;
/**
* Gets the animation to play in 3rd person when the creature is falling
* @return the animation data
* Gets the fall state data
* @return The fall state data
*/
public Animation getAnimationFall(){
return animationFall;
public TreeDataState getFallState(){
return fallState;
}
/**
* Gets the animation to play in 1st person when the creature is falling
* @return the animation data
* Gets the land state data
* @return The land state data
*/
public Animation getAnimationFirstPersonFall(){
return animationFirstPersonFall;
}
/**
* Gets the animation to play in 3rd person when the creature is landing
* @return the animation data
*/
public Animation getAnimationLand(){
return animationLand;
}
/**
* Gets the animation to play in 1st person when the creature is landing
* @return the animation data
*/
public Animation getAnimationFirstPersonLand(){
return animationFirstPersonLand;
public TreeDataState getLandState(){
return landState;
}
@Override

View File

@ -1,6 +1,6 @@
package electrosphere.game.data.creature.type.movement;
import electrosphere.game.data.creature.type.Animation;
import electrosphere.game.data.common.TreeDataAnimation;
import electrosphere.game.data.creature.type.SprintSystem;
/**
@ -19,16 +19,16 @@ public class GroundMovementSystem implements MovementSystem {
float maxVelocity;
//startup data
Animation animationStartup;
Animation animationFirstPersonStartup;
TreeDataAnimation animationStartup;
TreeDataAnimation animationFirstPersonStartup;
//loop data
Animation animationLoop;
Animation animationFirstPersonLoop;
TreeDataAnimation animationLoop;
TreeDataAnimation animationFirstPersonLoop;
//wind down data
Animation animationWindDown;
Animation animationFirstPersonWindDown;
TreeDataAnimation animationWindDown;
TreeDataAnimation animationFirstPersonWindDown;
//sprint data
SprintSystem sprintSystem;
@ -54,7 +54,7 @@ public class GroundMovementSystem implements MovementSystem {
* Gets the animation to play in 3rd person for startup
* @return The animation data
*/
public Animation getAnimationStartup() {
public TreeDataAnimation getAnimationStartup() {
return animationStartup;
}
@ -62,7 +62,7 @@ public class GroundMovementSystem implements MovementSystem {
* Gets the animation to play in 1st person for startup
* @return The animation data
*/
public Animation getAnimationFirstPersonStartup(){
public TreeDataAnimation getAnimationFirstPersonStartup(){
return animationFirstPersonStartup;
}
@ -70,7 +70,7 @@ public class GroundMovementSystem implements MovementSystem {
* Gets the animation to loop in 3rd person
* @return The animation data
*/
public Animation getAnimationLoop() {
public TreeDataAnimation getAnimationLoop() {
return animationLoop;
}
@ -78,7 +78,7 @@ public class GroundMovementSystem implements MovementSystem {
* Gets the animation to loop in 1st person
* @return The animation data
*/
public Animation getAnimationFirstPersonLoop(){
public TreeDataAnimation getAnimationFirstPersonLoop(){
return animationFirstPersonLoop;
}
@ -86,7 +86,7 @@ public class GroundMovementSystem implements MovementSystem {
* Gets the animation to play in 3rd person to wind down
* @return The animation data
*/
public Animation getAnimationWindDown() {
public TreeDataAnimation getAnimationWindDown() {
return animationWindDown;
}
@ -94,7 +94,7 @@ public class GroundMovementSystem implements MovementSystem {
* Gets the animation to play in 1st person to wind down
* @return The animation data
*/
public Animation getAnimationFirstPersonWindDown(){
public TreeDataAnimation getAnimationFirstPersonWindDown(){
return animationFirstPersonWindDown;
}

View File

@ -1,6 +1,6 @@
package electrosphere.game.data.creature.type.movement;
import electrosphere.game.data.creature.type.Animation;
import electrosphere.game.data.common.TreeDataAnimation;
public class JumpMovementSystem implements MovementSystem {
@ -8,8 +8,8 @@ public class JumpMovementSystem implements MovementSystem {
String type;
Animation animationJump;
Animation animationFirstPersonJump;
TreeDataAnimation animationJump;
TreeDataAnimation animationFirstPersonJump;
int jumpFrames;
float jumpForce;
@ -22,11 +22,11 @@ public class JumpMovementSystem implements MovementSystem {
return jumpForce;
}
public Animation getAnimationJump(){
public TreeDataAnimation getAnimationJump(){
return animationJump;
}
public Animation getAnimationFirstPersonJump(){
public TreeDataAnimation getAnimationFirstPersonJump(){
return animationFirstPersonJump;
}