move cursor entities
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
6d98af90ac
commit
a2b5de8863
@ -1808,6 +1808,7 @@ Move clientScene to clientState
|
||||
Move clientSceneWrapper to clientState
|
||||
Move clientConnection to clientState
|
||||
Move playerEntity to clientState
|
||||
Move global cursor entities into cursorState
|
||||
Move lots of global state to clientState
|
||||
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ public class ScriptClientAreaUtils {
|
||||
@Export
|
||||
public static void selectAreaRectangular(){
|
||||
// Vector3d blockCursorPos = Globals.cursorState.getBlockCursorPos();
|
||||
Vector3d cursorPos = new Vector3d(EntityUtils.getPosition(Globals.playerCursor));
|
||||
Vector3d cursorPos = new Vector3d(EntityUtils.getPosition(Globals.cursorState.playerCursor));
|
||||
Vector3i chunkPos = Globals.clientState.clientWorldData.convertRealToWorldSpace(cursorPos);
|
||||
Vector3i blockPos = Globals.clientState.clientWorldData.convertRealToBlockSpace(cursorPos);
|
||||
AreaSelection selection = AreaSelection.selectRectangularBlockCavity(chunkPos, blockPos, AreaSelection.DEFAULT_SELECTION_RADIUS);
|
||||
|
||||
@ -515,7 +515,7 @@ public class ControlCategoryMainGame {
|
||||
ClientToolbarState clientToolbarState = ClientToolbarState.getClientToolbarState(Globals.clientState.playerEntity);
|
||||
if(clientToolbarState.getCurrentPrimaryItem() != null){
|
||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(clientToolbarState.getCurrentPrimaryItem());
|
||||
if(Globals.playerCursor != null && Globals.playerBlockCursor != null){
|
||||
if(Globals.cursorState.playerCursor != null && Globals.cursorState.playerBlockCursor != null){
|
||||
if(itemData.getTokens().contains(CursorState.CURSOR_BLOCK_TOKEN)) {
|
||||
return;
|
||||
}
|
||||
@ -616,7 +616,7 @@ public class ControlCategoryMainGame {
|
||||
!Globals.controlCallback.getKey(GLFW.GLFW_KEY_LEFT_SHIFT)
|
||||
){
|
||||
//if the block cursor is visible, capture this input and instead modify block cursor
|
||||
if(Globals.clientState.clientScene.getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.playerBlockCursor)){
|
||||
if(Globals.clientState.clientScene.getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.cursorState.playerBlockCursor)){
|
||||
Globals.cursorState.updateCursorSize(scrollEvent);
|
||||
handled = true;
|
||||
}
|
||||
|
||||
@ -92,6 +92,21 @@ public class CursorState {
|
||||
*/
|
||||
private boolean clampToExistingBlock = false;
|
||||
|
||||
/**
|
||||
* Free point selection cursor
|
||||
*/
|
||||
public Entity playerCursor;
|
||||
|
||||
/**
|
||||
* Block cursor
|
||||
*/
|
||||
public Entity playerBlockCursor;
|
||||
|
||||
/**
|
||||
* Area cursor
|
||||
*/
|
||||
public Entity playerAreaCursor;
|
||||
|
||||
/**
|
||||
* The fab cursor
|
||||
*/
|
||||
@ -134,31 +149,31 @@ public class CursorState {
|
||||
*/
|
||||
public static void createCursorEntities(){
|
||||
//player's cursor
|
||||
Globals.playerCursor = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(Globals.playerCursor, AssetDataStrings.UNITSPHERE);
|
||||
Actor cursorActor = EntityUtils.getActor(Globals.playerCursor);
|
||||
Globals.cursorState.playerCursor = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(Globals.cursorState.playerCursor, AssetDataStrings.UNITSPHERE);
|
||||
Actor cursorActor = EntityUtils.getActor(Globals.cursorState.playerCursor);
|
||||
cursorActor.addTextureMask(new ActorTextureMask("sphere", Arrays.asList(new String[]{AssetDataStrings.TEXTURE_RED_TRANSPARENT})));
|
||||
DrawableUtils.makeEntityTransparent(Globals.playerCursor);
|
||||
EntityUtils.getScale(Globals.playerCursor).set(0.2f);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerCursor, EntityTags.DRAWABLE);
|
||||
DrawableUtils.makeEntityTransparent(Globals.cursorState.playerCursor);
|
||||
EntityUtils.getScale(Globals.cursorState.playerCursor).set(0.2f);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.cursorState.playerCursor, EntityTags.DRAWABLE);
|
||||
|
||||
//player's block cursor
|
||||
Globals.playerBlockCursor = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(Globals.playerBlockCursor, AssetDataStrings.UNITCUBE);
|
||||
Actor blockCursorActor = EntityUtils.getActor(Globals.playerBlockCursor);
|
||||
Globals.cursorState.playerBlockCursor = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(Globals.cursorState.playerBlockCursor, AssetDataStrings.UNITCUBE);
|
||||
Actor blockCursorActor = EntityUtils.getActor(Globals.cursorState.playerBlockCursor);
|
||||
blockCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{AssetDataStrings.TEXTURE_RED_TRANSPARENT})));
|
||||
DrawableUtils.makeEntityTransparent(Globals.playerBlockCursor);
|
||||
EntityUtils.getScale(Globals.playerBlockCursor).set(BLOCK_CURSOR_SCALE_MULTIPLIER);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
DrawableUtils.makeEntityTransparent(Globals.cursorState.playerBlockCursor);
|
||||
EntityUtils.getScale(Globals.cursorState.playerBlockCursor).set(BLOCK_CURSOR_SCALE_MULTIPLIER);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.cursorState.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
|
||||
//player's area cursor
|
||||
Globals.playerAreaCursor = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(Globals.playerAreaCursor, AssetDataStrings.UNITCUBE);
|
||||
Actor areaCursorActor = EntityUtils.getActor(Globals.playerAreaCursor);
|
||||
Globals.cursorState.playerAreaCursor = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(Globals.cursorState.playerAreaCursor, AssetDataStrings.UNITCUBE);
|
||||
Actor areaCursorActor = EntityUtils.getActor(Globals.cursorState.playerAreaCursor);
|
||||
areaCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{AssetDataStrings.TEXTURE_RED_TRANSPARENT})));
|
||||
DrawableUtils.makeEntityTransparent(Globals.playerAreaCursor);
|
||||
EntityUtils.getScale(Globals.playerAreaCursor).set(BLOCK_CURSOR_SCALE_MULTIPLIER);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerAreaCursor, EntityTags.DRAWABLE);
|
||||
DrawableUtils.makeEntityTransparent(Globals.cursorState.playerAreaCursor);
|
||||
EntityUtils.getScale(Globals.cursorState.playerAreaCursor).set(BLOCK_CURSOR_SCALE_MULTIPLIER);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.cursorState.playerAreaCursor, EntityTags.DRAWABLE);
|
||||
|
||||
//player's fab cursor
|
||||
playerFabCursor = EntityCreationUtils.createClientSpatialEntity();
|
||||
@ -186,7 +201,7 @@ public class CursorState {
|
||||
if(
|
||||
collisionEngine != null &&
|
||||
camera != null &&
|
||||
Globals.playerCursor != null
|
||||
Globals.cursorState.playerCursor != null
|
||||
){
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||
@ -194,14 +209,14 @@ public class CursorState {
|
||||
if(cursorPos == null){
|
||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||
}
|
||||
EntityUtils.getPosition(Globals.playerCursor).set(cursorPos);
|
||||
EntityUtils.getPosition(Globals.cursorState.playerCursor).set(cursorPos);
|
||||
|
||||
//clamp block cursor to nearest voxel
|
||||
if(clampToExistingBlock){
|
||||
cursorPos = cursorPos.add(new Vector3d(eyePos).normalize().mul(-BlockChunkData.BLOCK_SIZE_MULTIPLIER));
|
||||
}
|
||||
cursorPos.set(this.clampPositionToNearestBlock(cursorPos));
|
||||
EntityUtils.getPosition(Globals.playerBlockCursor).set(cursorPos);
|
||||
EntityUtils.getPosition(Globals.cursorState.playerBlockCursor).set(cursorPos);
|
||||
cursorPos.sub(BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0,BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0,BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0);
|
||||
EntityUtils.getPosition(CursorState.playerFabCursor).set(cursorPos);
|
||||
if(gridAlignmentData != null){
|
||||
@ -216,7 +231,7 @@ public class CursorState {
|
||||
*/
|
||||
public static void makeRealVisible(){
|
||||
CursorState.hide();
|
||||
Globals.clientState.clientSceneWrapper.getScene().registerEntityToTag(Globals.playerCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().registerEntityToTag(Globals.cursorState.playerCursor, EntityTags.DRAWABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,9 +239,9 @@ public class CursorState {
|
||||
*/
|
||||
public static void makeBlockVisible(String texture){
|
||||
CursorState.hide();
|
||||
Actor blockCursorActor = EntityUtils.getActor(Globals.playerBlockCursor);
|
||||
Actor blockCursorActor = EntityUtils.getActor(Globals.cursorState.playerBlockCursor);
|
||||
blockCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{texture})));
|
||||
Globals.clientState.clientSceneWrapper.getScene().registerEntityToTag(Globals.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().registerEntityToTag(Globals.cursorState.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -234,7 +249,7 @@ public class CursorState {
|
||||
*/
|
||||
public static void makeAreaVisible(){
|
||||
CursorState.hide();
|
||||
Globals.clientState.clientSceneWrapper.getScene().registerEntityToTag(Globals.playerAreaCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().registerEntityToTag(Globals.cursorState.playerAreaCursor, EntityTags.DRAWABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -262,9 +277,9 @@ public class CursorState {
|
||||
* Hides the cursor
|
||||
*/
|
||||
public static void hide(){
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerAreaCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.cursorState.playerCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.cursorState.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.cursorState.playerAreaCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(CursorState.playerFabCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(CursorState.playerGridAlignedCursor, EntityTags.DRAWABLE);
|
||||
}
|
||||
@ -277,11 +292,11 @@ public class CursorState {
|
||||
this.areaCursorSelection = selection;
|
||||
Vector3d center = new Vector3d(areaCursorSelection.getRectStart()).add(areaCursorSelection.getRectEnd()).mul(0.5f);
|
||||
Vector3d scale = new Vector3d(areaCursorSelection.getRectStart()).sub(areaCursorSelection.getRectEnd()).absolute();
|
||||
EntityCreationUtils.makeEntityDrawable(Globals.playerAreaCursor, AssetDataStrings.UNITCUBE);
|
||||
Actor areaCursorActor = EntityUtils.getActor(Globals.playerAreaCursor);
|
||||
EntityCreationUtils.makeEntityDrawable(Globals.cursorState.playerAreaCursor, AssetDataStrings.UNITCUBE);
|
||||
Actor areaCursorActor = EntityUtils.getActor(Globals.cursorState.playerAreaCursor);
|
||||
areaCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{"Textures/transparent_red.png"})));
|
||||
EntityUtils.getPosition(Globals.playerAreaCursor).set(center);
|
||||
EntityUtils.getScale(Globals.playerAreaCursor).set(scale);
|
||||
EntityUtils.getPosition(Globals.cursorState.playerAreaCursor).set(center);
|
||||
EntityUtils.getScale(Globals.cursorState.playerAreaCursor).set(scale);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -361,7 +376,7 @@ public class CursorState {
|
||||
*/
|
||||
public Vector3d getBlockCursorPos(){
|
||||
double sizeMult = BlockChunkData.BLOCK_SIZE_MULTIPLIER * blockSize;
|
||||
Vector3d posRaw = new Vector3d(EntityUtils.getPosition(Globals.playerBlockCursor)).sub(sizeMult/2.0,sizeMult/2.0,sizeMult/2.0);
|
||||
Vector3d posRaw = new Vector3d(EntityUtils.getPosition(Globals.cursorState.playerBlockCursor)).sub(sizeMult/2.0,sizeMult/2.0,sizeMult/2.0);
|
||||
return posRaw;
|
||||
}
|
||||
|
||||
@ -379,7 +394,7 @@ public class CursorState {
|
||||
this.blockSize = this.blockSize / 2;
|
||||
}
|
||||
}
|
||||
EntityUtils.getScale(Globals.playerBlockCursor).set(BLOCK_CURSOR_SCALE_MULTIPLIER * this.blockSize);
|
||||
EntityUtils.getScale(Globals.cursorState.playerBlockCursor).set(BLOCK_CURSOR_SCALE_MULTIPLIER * this.blockSize);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -531,7 +546,7 @@ public class CursorState {
|
||||
ClientToolbarState clientToolbarState = ClientToolbarState.getClientToolbarState(Globals.clientState.playerEntity);
|
||||
if(clientToolbarState.getCurrentPrimaryItem() != null){
|
||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(clientToolbarState.getCurrentPrimaryItem());
|
||||
if(Globals.playerCursor != null && Globals.playerBlockCursor != null){
|
||||
if(Globals.cursorState.playerCursor != null && Globals.cursorState.playerBlockCursor != null){
|
||||
if(itemData.getTokens().contains(CursorState.CURSOR_BLOCK_TOKEN)) {
|
||||
Globals.cursorState.setClampToExistingBlock(false);
|
||||
}
|
||||
@ -550,14 +565,14 @@ public class CursorState {
|
||||
boolean clearBlockCursor = true;
|
||||
if(clientToolbarState.getCurrentPrimaryItem() != null){
|
||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(clientToolbarState.getCurrentPrimaryItem());
|
||||
if(Globals.playerCursor != null && Globals.playerBlockCursor != null){
|
||||
if(Globals.cursorState.playerCursor != null && Globals.cursorState.playerBlockCursor != null){
|
||||
if(itemData.getTokens().contains(CursorState.CURSOR_BLOCK_TOKEN)) {
|
||||
clearBlockCursor = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(clearBlockCursor){
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.cursorState.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -568,8 +583,8 @@ public class CursorState {
|
||||
public void hintShowBlockCursor(){
|
||||
if(
|
||||
!Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(CursorState.playerFabCursor) &&
|
||||
!Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.playerAreaCursor) &&
|
||||
!Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.playerCursor)
|
||||
!Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.cursorState.playerAreaCursor) &&
|
||||
!Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.cursorState.playerCursor)
|
||||
){
|
||||
CursorState.makeBlockVisible(AssetDataStrings.TEXTURE_RED_TRANSPARENT);
|
||||
}
|
||||
@ -604,14 +619,14 @@ public class CursorState {
|
||||
* @return The position if a cursor is visible, null otherwise
|
||||
*/
|
||||
public Vector3d getCursorPosition(){
|
||||
if(Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.playerCursor)){
|
||||
return EntityUtils.getPosition(Globals.playerCursor);
|
||||
if(Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.cursorState.playerCursor)){
|
||||
return EntityUtils.getPosition(Globals.cursorState.playerCursor);
|
||||
}
|
||||
if(Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.playerBlockCursor)){
|
||||
return EntityUtils.getPosition(Globals.playerBlockCursor);
|
||||
if(Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.cursorState.playerBlockCursor)){
|
||||
return EntityUtils.getPosition(Globals.cursorState.playerBlockCursor);
|
||||
}
|
||||
if(Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.playerAreaCursor)){
|
||||
return EntityUtils.getPosition(Globals.playerAreaCursor);
|
||||
if(Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.cursorState.playerAreaCursor)){
|
||||
return EntityUtils.getPosition(Globals.cursorState.playerAreaCursor);
|
||||
}
|
||||
if(Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(CursorState.playerFabCursor)){
|
||||
return EntityUtils.getPosition(CursorState.playerFabCursor);
|
||||
|
||||
@ -353,11 +353,6 @@ public class Globals {
|
||||
//the player camera entity
|
||||
public static Entity playerCamera;
|
||||
|
||||
//the player in world cursor
|
||||
public static Entity playerCursor;
|
||||
public static Entity playerBlockCursor;
|
||||
public static Entity playerAreaCursor;
|
||||
|
||||
//the entity for the first person modal (view model)
|
||||
public static Entity firstPersonEntity;
|
||||
|
||||
|
||||
@ -185,7 +185,7 @@ public class ClientToolbarState implements BehaviorTree {
|
||||
//cursor logic
|
||||
if(targetPoint != null && parent == Globals.clientState.playerEntity){
|
||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(toEquip);
|
||||
if(Globals.playerCursor != null && Globals.playerBlockCursor != null){
|
||||
if(Globals.cursorState.playerCursor != null && Globals.cursorState.playerBlockCursor != null){
|
||||
CursorState.hide();
|
||||
Globals.cursorState.setClampToExistingBlock(false);
|
||||
if(itemData.getTokens().contains(CursorState.CURSOR_TOKEN)){
|
||||
@ -268,11 +268,11 @@ public class ClientToolbarState implements BehaviorTree {
|
||||
}
|
||||
}
|
||||
|
||||
if(Globals.playerCursor != null){
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerCursor, EntityTags.DRAWABLE);
|
||||
if(Globals.cursorState.playerCursor != null){
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.cursorState.playerCursor, EntityTags.DRAWABLE);
|
||||
}
|
||||
if(Globals.playerBlockCursor != null){
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
if(Globals.cursorState.playerBlockCursor != null){
|
||||
Globals.clientState.clientSceneWrapper.getScene().removeEntityFromTag(Globals.cursorState.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
}
|
||||
|
||||
//hide cursors
|
||||
|
||||
Loading…
Reference in New Issue
Block a user