Skip to content
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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

artism90
Copy link
Contributor

@artism90 artism90 commented Sep 2, 2023

No description provided.

@artism90 artism90 added map Relating to the map or world or terrain code Programming code and game logic labels Sep 2, 2023
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)
Copy link

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.

Comment on lines +7 to +8
for unit in _player_camera.selected_entities:
if unit.faction == _player_camera.player.faction:

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()

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 ?

Comment on lines +38 to +49
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

Copy link

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.

Comment on lines +68 to +73
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]
Copy link

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

Comment on lines +55 to +58
@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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Programming code and game logic map Relating to the map or world or terrain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants