eventual fall tree synchronization
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-09-09 18:32:34 -04:00
parent 99a7434557
commit d9d2a74f68
5 changed files with 51 additions and 7 deletions

View File

@ -17,6 +17,7 @@
+ bug fixes + bug fixes
Fix falling tree not always deactivating on server Fix falling tree not always deactivating on server
Fix cursor always placing at origin
Fix server ground movement tree playing animation over falling animation Fix server ground movement tree playing animation over falling animation
Fix empty item slot not showing underneath dragged item Fix empty item slot not showing underneath dragged item
Fix grass rendering distance Fix grass rendering distance

View File

@ -39,6 +39,9 @@ public class ClientGravityTree implements BehaviorTree {
DBody body; DBody body;
Collidable collidable; Collidable collidable;
static final float gravityConstant = 0.2f;
static final float linearDamping = 0.1f;
private ClientGravityTree(Entity e, Object ... params){ private ClientGravityTree(Entity e, Object ... params){
//Collidable collidable, DBody body, int fallFrame //Collidable collidable, DBody body, int fallFrame
@ -71,9 +74,14 @@ public class ClientGravityTree implements BehaviorTree {
public void stop(){ public void stop(){
state = GravityTreeState.NOT_ACTIVE; state = GravityTreeState.NOT_ACTIVE;
} }
static final float gravityConstant = 0.2f; /**
static final float linearDamping = 0.1f; * Checks if the gravity tree is active
* @return true if active, false otherwise
*/
public boolean isActive(){
return this.state == GravityTreeState.ACTIVE;
}
public void simulate(float deltaTime){ public void simulate(float deltaTime){

View File

@ -38,6 +38,9 @@ public class ServerGravityTree implements BehaviorTree {
DBody body; DBody body;
Collidable collidable; Collidable collidable;
static final float gravityConstant = 0.2f;
static final float linearDamping = 0.1f;
private ServerGravityTree(Entity e, Object ... params){ private ServerGravityTree(Entity e, Object ... params){
state = GravityTreeState.ACTIVE; state = GravityTreeState.ACTIVE;
@ -76,9 +79,14 @@ public class ServerGravityTree implements BehaviorTree {
public void stop(){ public void stop(){
setState(GravityTreeState.NOT_ACTIVE); setState(GravityTreeState.NOT_ACTIVE);
} }
static final float gravityConstant = 0.2f; /**
static final float linearDamping = 0.1f; * Checks if the gravity tree is active
* @return true if active, false otherwise
*/
public boolean isActive(){
return this.state == GravityTreeState.ACTIVE;
}
public void simulate(float deltaTime){ public void simulate(float deltaTime){
@ -117,6 +125,10 @@ public class ServerGravityTree implements BehaviorTree {
} }
} }
/**
* Checks if the gravity tree had a collision with a structure
* @return true if collided on the most recent frame, false otherwise
*/
public boolean hadStructureCollision(){ public boolean hadStructureCollision(){
boolean rVal = false; boolean rVal = false;
for(Impulse impulse : collidable.getImpulses()){ for(Impulse impulse : collidable.getImpulses()){
@ -128,6 +140,10 @@ public class ServerGravityTree implements BehaviorTree {
return rVal; return rVal;
} }
/**
* Checks if the gravity tree had a collision with terrain
* @return true if collided on the most recent frame, false otherwise
*/
public boolean hadGroundCollision(){ public boolean hadGroundCollision(){
boolean rVal = false; boolean rVal = false;
for(Impulse impulse : collidable.getImpulses()){ for(Impulse impulse : collidable.getImpulses()){
@ -144,6 +160,10 @@ public class ServerGravityTree implements BehaviorTree {
return rVal; return rVal;
} }
/**
* Checks if the gravity tree had a collision with an entity
* @return true if collided on the most recent frame, false otherwise
*/
public boolean hadEntityCollision(){ public boolean hadEntityCollision(){
boolean rVal = false; boolean rVal = false;
for(Impulse impulse : collidable.getImpulses()){ for(Impulse impulse : collidable.getImpulses()){

View File

@ -11,6 +11,7 @@ import electrosphere.entity.btree.StateTransitionUtil;
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem; import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
import electrosphere.entity.state.AnimationPriorities; import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree; import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.entity.state.gravity.ClientGravityTree;
import electrosphere.entity.state.movement.jump.ClientJumpTree; import electrosphere.entity.state.movement.jump.ClientJumpTree;
import electrosphere.game.data.creature.type.movement.FallMovementSystem; import electrosphere.game.data.creature.type.movement.FallMovementSystem;
import electrosphere.renderer.actor.Actor; import electrosphere.renderer.actor.Actor;
@ -64,6 +65,9 @@ public class ClientFallTree implements BehaviorTree {
switch(state){ switch(state){
case ACTIVE: case ACTIVE:
stateTransitionUtil.simulate(FallState.ACTIVE); stateTransitionUtil.simulate(FallState.ACTIVE);
if(ClientGravityTree.getClientGravityTree(parent) != null && !ClientGravityTree.getClientGravityTree(parent).isActive()){
this.land();
}
break; break;
case INACTIVE: case INACTIVE:
break; break;

View File

@ -5,6 +5,7 @@ import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.AnimationPriorities; import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.gravity.ServerGravityTree;
import electrosphere.entity.state.movement.jump.ServerJumpTree; import electrosphere.entity.state.movement.jump.ServerJumpTree;
import electrosphere.game.data.creature.type.movement.FallMovementSystem; import electrosphere.game.data.creature.type.movement.FallMovementSystem;
import electrosphere.server.poseactor.PoseActor; import electrosphere.server.poseactor.PoseActor;
@ -39,7 +40,6 @@ public class ServerFallTree implements BehaviorTree {
PoseActor poseActor = EntityUtils.getPoseActor(parent); PoseActor poseActor = EntityUtils.getPoseActor(parent);
switch(state){ switch(state){
case ACTIVE: case ACTIVE:
frameCurrent++;
if(poseActor != null){ if(poseActor != null){
String animationToPlay = determineCorrectAnimation(); String animationToPlay = determineCorrectAnimation();
if( if(
@ -50,16 +50,27 @@ public class ServerFallTree implements BehaviorTree {
poseActor.incrementAnimationTime(0.0001); poseActor.incrementAnimationTime(0.0001);
} }
} }
if(ServerGravityTree.getServerGravityTree(parent) != null && !ServerGravityTree.getServerGravityTree(parent).isActive()){
this.land();
}
frameCurrent++;
break; break;
case INACTIVE: case INACTIVE:
break; break;
} }
} }
/**
* Starts the fall tree
*/
public void start(){ public void start(){
state = FallState.ACTIVE; state = FallState.ACTIVE;
} }
/**
* Checks if the fall tree is active
* @return true if is active, false otherwise
*/
public boolean isFalling(){ public boolean isFalling(){
return state == FallState.ACTIVE; return state == FallState.ACTIVE;
} }