@tool class_name BugMarker extends Node3D @export_group("Marker", "marker_") enum BugStatus { NEUTRAL, UNRESOLVED, IN_PROGRESS, RESOLVED } @export var marker_status : BugStatus = BugStatus.NEUTRAL : set = __set_marker_status @export var marker_material_neutral : BugMarkerMaterialPack @export var marker_material_unresolved : BugMarkerMaterialPack @export var marker_material_in_progress : BugMarkerMaterialPack @export var marker_material_resolved : BugMarkerMaterialPack @export_group("") @export var enable_info : bool = true : set = set_info_enabled const UNRESOLVED_TINT : Color = Color(0.1,0.0,0.0) const IN_PROGRESS_TINT : Color = Color(0.5,0.5,0.0) const RESOLVED_TINT : Color = Color(0.0,1.0,0.0) var bug_info : BugbotBugData : set = set_bug_info, get = get_bug_info var __arrow : MeshInstance3D var __billboard : MeshInstance3D var __info_collider : BugInfoCollider func _enter_tree() -> void: __arrow = $Arrow as MeshInstance3D __billboard = $Billboard as MeshInstance3D __info_collider = $Billboard/Info as BugInfoCollider set_info_enabled(enable_info) __set_marker_status(marker_status) func set_rotation_to_normal(_normal:Vector3) -> void: global_transform.basis.y = _normal global_transform.basis.x = global_transform.basis.z.cross(_normal) global_transform.basis = global_transform.basis.orthonormalized() func set_info_enabled(_enable:bool) -> void: if __info_collider: __info_collider.collision_layer = 0xFFFFFFFF if _enable else 0x00000000 enable_info = _enable func set_bug_info(bug_info:BugbotBugData) -> void: __info_collider.bug_info = bug_info func get_bug_info() -> BugbotBugData: return __info_collider.bug_info func __set_marker_status(_status:BugStatus) -> void: match _status: BugStatus.NEUTRAL: __arrow.set_surface_override_material(0, marker_material_neutral.arrow) __billboard.set_surface_override_material(0, marker_material_neutral.icon) BugStatus.UNRESOLVED: __arrow.set_surface_override_material(0, marker_material_unresolved.arrow) __billboard.set_surface_override_material(0, marker_material_unresolved.icon) BugStatus.IN_PROGRESS: __arrow.set_surface_override_material(0, marker_material_in_progress.arrow) __billboard.set_surface_override_material(0, marker_material_in_progress.icon) BugStatus.RESOLVED: __arrow.set_surface_override_material(0, marker_material_resolved.arrow) __billboard.set_surface_override_material(0, marker_material_resolved.icon) marker_status = _status