Rewrote entity system

This commit is contained in:
2025-05-09 22:33:51 -05:00
parent a69ec56a2d
commit f465880044
29 changed files with 372 additions and 284 deletions

88
scripts/Entity/Entity.gd Normal file
View File

@@ -0,0 +1,88 @@
class_name Entity extends Node
# var meshInstance:MeshInstance3D;
# var underFootTile:int = -1;
# var underFootPosition:Vector3;
# var material:ShaderMaterial;
# func updateMaterial() -> bool:
# if !meshInstance:
# return false
# if !material:
# return false
# return true
# # Virtual Methods
# func updateMovement(delta) -> void:
# pass
# func updateOverworldLogic(delta) -> void:
# pass
func isPaused() -> bool:
var ps = PAUSE.getPauseState();
match ps:
PauseSystem.PauseType.NOT_PAUSED:
return false;
PauseSystem.PauseType.FULLY_PAUSED:
return true;
PauseSystem.PauseType.ENTITY_PAUSED:
if PAUSE.entities.find(self) != -1:
return true;
return false;
PauseSystem.PauseType.CUTSCENE_PAUSED:
if PAUSE.entities.find(self) != -1:
return false;
return true;
_:
assert(false, "Invalid pause state");
return false;
# Private methods
# func _updateTileData() -> void:
# # ray cast down
# var offset = Vector3(0, 0, 0.426);
# var query = PhysicsRayQueryParameters3D.create(
# position + offset,
# position + Vector3(0, -1, 0) + offset
# )
# query.collide_with_areas = true
# query.exclude = [self]
# var result = get_world_3d().direct_space_state.intersect_ray(query)
# if !result or !result.collider:
# return;
# var collider = result.collider;
# var colliderMesh = collider.get_node("../");
# if !colliderMesh or !(colliderMesh is ArrayMesh) or !colliderMesh.mesh or colliderMesh.mesh.get_surface_count() == 0:
# return;
# # Get the face index (triangle)
# var arrays = colliderMesh.mesh.surface_get_arrays(0);
# var indiceIdx = result.face_index * 3;
# # Get each indice of the triangle
# var index0 = arrays[Mesh.ARRAY_INDEX][indiceIdx+0];
# var index1 = arrays[Mesh.ARRAY_INDEX][indiceIdx+1];
# var index2 = arrays[Mesh.ARRAY_INDEX][indiceIdx+2];
# # Get each uv of each indice
# var uv0:Vector2 = arrays[Mesh.ARRAY_TEX_UV][index0];
# var uv1:Vector2 = arrays[Mesh.ARRAY_TEX_UV][index1];
# var uv2:Vector2 = arrays[Mesh.ARRAY_TEX_UV][index2];
# # Determine the lowest texture coordinate
# var min = Vector2(min(uv0.x, uv1.x, uv2.x), min(uv0.y, uv1.y, uv2.y));
# # Convert to column/row
# var w = 256;
# var h = w;
# var tw = 48;
# var th = tw;
# var column = int(roundf(min.x * w)) / tw;
# var row = int(roundf(min.y * h)) / th;
# var columns = 768 / tw;
# underFootPosition = result.position;
# underFootTile = column % columns + row * columns;