-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Refactor and apply fixes #117
base: develop
Are you sure you want to change the base?
Conversation
7910539
to
dca2966
Compare
unit.move_to(Utils.map_3_to_2(result.position)) | ||
func move_selected_units_to(position) -> void: | ||
#print_debug("Command: Move selected units {0} ".format([result])) | ||
print("Command: Move selected units to ", position) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
It is not recommanded to print things like that.
Maybe if you dislike print_debug you can be interested by OS.is_debug_build()
. It also returns true when you launch from editor.
for unit in _player_camera.selected_entities: | ||
if unit.faction == _player_camera.player.faction: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a strange behavior. How can I select at same time player units, other and want to move them ?
@export var selection_tolerance: int = 10 | ||
|
||
@onready var _parent := get_parent() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you do that ?
func _on_mouse_motion(target: Node, position: Vector2) -> void: | ||
# Hover new object | ||
if target != last_target: | ||
if target is WorldThing: | ||
target.set_hover(true) | ||
|
||
# Unhover old object | ||
if last_target is WorldThing: | ||
last_target.set_hover(false) | ||
|
||
last_target = target | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use only this func to hover object, only worldthing are impacted. So, you can use a physic mask instead of verify the type of the node.
if tile_map_start in all_points: | ||
start_id = all_points[tile_map_start] | ||
else: | ||
start_id = as_node.get_closest_point(start) | ||
if gm_end in all_points: | ||
end_id = all_points[gm_end] | ||
if tile_map_end in all_points: | ||
end_id = all_points[tile_map_end] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will better if it is not this func to verify if tile_map_start is in all_points or not.
Furthermore instead of dictionary with string keys, you can hash the vector2D like that
var index = vec.y * map.width + vec.x
This func can verify also if vec is in range of the map, so you do not need to verify later.
Plus is more efficient to hash like that then use an array instead of a dictionary to search in. Maybe you can think of multidimensional array, but is not easy in gdscript godotengine/godot-proposals#5148.
You can try the difference on this exercise on coding game https://www.codingame.com/training/hard/surface
@onready var world := get_node_or_null("/root/World") as Node3D | ||
|
||
@onready var _as_map := get_node_or_null("/root/World/AStarMap") as AStarMap | ||
@onready var _rotation_y := get_node_or_null("/root/World/PlayerCamera/RotationY") as Node3D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to do it like that, you should verify if the node is not null somewhere
No description provided.