fix door tree physics
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
147cad77d7
commit
4c6c30db0f
@ -1579,6 +1579,9 @@ Area selection utility
|
|||||||
RoomTool item
|
RoomTool item
|
||||||
Grid alignment actually aligns entity to grid
|
Grid alignment actually aligns entity to grid
|
||||||
|
|
||||||
|
(04/29/2025)
|
||||||
|
Fix door tree physics
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -677,4 +677,13 @@ public class PhysicsEntityUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the physics template for the entity
|
||||||
|
* @param entity The entity
|
||||||
|
* @return The template
|
||||||
|
*/
|
||||||
|
public static CollidableTemplate getPhysicsTemplate(Entity entity){
|
||||||
|
return (CollidableTemplate)entity.getData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,19 @@
|
|||||||
package electrosphere.entity.state.furniture;
|
package electrosphere.entity.state.furniture;
|
||||||
|
|
||||||
|
|
||||||
|
import org.joml.Quaterniond;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
import electrosphere.collision.PhysicsEntityUtils;
|
import electrosphere.collision.PhysicsEntityUtils;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
|
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.btree.BehaviorTree;
|
import electrosphere.entity.btree.BehaviorTree;
|
||||||
import electrosphere.entity.btree.StateTransitionUtil;
|
import electrosphere.entity.btree.StateTransitionUtil;
|
||||||
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
|
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
|
||||||
|
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||||
import electrosphere.game.data.furniture.DoorData;
|
import electrosphere.game.data.furniture.DoorData;
|
||||||
import electrosphere.net.synchronization.annotation.SyncedField;
|
import electrosphere.net.synchronization.annotation.SyncedField;
|
||||||
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
|
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
|
||||||
@ -87,7 +92,7 @@ public class ClientDoorState implements BehaviorTree {
|
|||||||
doorData.getOpening(),
|
doorData.getOpening(),
|
||||||
() -> {
|
() -> {
|
||||||
this.setState(DoorState.OPEN);
|
this.setState(DoorState.OPEN);
|
||||||
PhysicsEntityUtils.disableBody(Globals.clientSceneWrapper.getCollisionEngine(), this.parent);
|
Globals.clientSceneWrapper.getCollisionEngine().destroyPhysics(this.parent);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
StateTransitionUtilItem.create(
|
StateTransitionUtilItem.create(
|
||||||
@ -100,7 +105,10 @@ public class ClientDoorState implements BehaviorTree {
|
|||||||
doorData.getClosing(),
|
doorData.getClosing(),
|
||||||
() -> {
|
() -> {
|
||||||
this.setState(DoorState.CLOSED);
|
this.setState(DoorState.CLOSED);
|
||||||
PhysicsEntityUtils.enableBody(Globals.clientSceneWrapper.getCollisionEngine(), this.parent);
|
Vector3d pos = EntityUtils.getPosition(this.parent);
|
||||||
|
Quaterniond rot = EntityUtils.getRotation(this.parent);
|
||||||
|
PhysicsEntityUtils.clientAttachCollidableTemplate(this.parent, PhysicsEntityUtils.getPhysicsTemplate(this.parent));
|
||||||
|
CollisionObjUtils.clientPositionCharacter(this.parent, pos, rot);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,9 +1,13 @@
|
|||||||
package electrosphere.entity.state.furniture;
|
package electrosphere.entity.state.furniture;
|
||||||
|
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
import electrosphere.collision.PhysicsEntityUtils;
|
import electrosphere.collision.PhysicsEntityUtils;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.ServerEntityUtils;
|
||||||
import electrosphere.net.synchronization.enums.FieldIdEnums;
|
import electrosphere.net.synchronization.enums.FieldIdEnums;
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
||||||
@ -67,7 +71,7 @@ public class ServerDoorState implements BehaviorTree {
|
|||||||
() -> {
|
() -> {
|
||||||
this.setState(DoorState.OPEN);
|
this.setState(DoorState.OPEN);
|
||||||
Realm parentRealm = Globals.realmManager.getEntityRealm(this.parent);
|
Realm parentRealm = Globals.realmManager.getEntityRealm(this.parent);
|
||||||
PhysicsEntityUtils.disableBody(parentRealm.getCollisionEngine(), this.parent);
|
parentRealm.getCollisionEngine().destroyPhysics(this.parent);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
StateTransitionUtilItem.create(
|
StateTransitionUtilItem.create(
|
||||||
@ -81,7 +85,9 @@ public class ServerDoorState implements BehaviorTree {
|
|||||||
() -> {
|
() -> {
|
||||||
this.setState(DoorState.CLOSED);
|
this.setState(DoorState.CLOSED);
|
||||||
Realm parentRealm = Globals.realmManager.getEntityRealm(this.parent);
|
Realm parentRealm = Globals.realmManager.getEntityRealm(this.parent);
|
||||||
PhysicsEntityUtils.enableBody(parentRealm.getCollisionEngine(), this.parent);
|
Vector3d pos = EntityUtils.getPosition(this.parent);
|
||||||
|
PhysicsEntityUtils.serverAttachCollidableTemplate(parentRealm, this.parent, PhysicsEntityUtils.getPhysicsTemplate(this.parent));
|
||||||
|
ServerEntityUtils.repositionEntity(this.parent, pos);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user