Skip to content

Commit

Permalink
Add hint to some properties
Browse files Browse the repository at this point in the history
  • Loading branch information
indubitablement2 committed Apr 19, 2024
1 parent 8e1b698 commit 40608e2
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 29 deletions.
4 changes: 2 additions & 2 deletions godot_custom/hull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ void HullData::_bind_methods() {

SET_GET_BIND(armor_cells_max, PackedByteArray, HullData);
ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "armor_cells_max"), "set_armor_cells_max", "get_armor_cells_max");
DATA_PROP_BIND(armor_max, "");
DATA_PROP_BIND(hull_max, "");
DATA_PROP_BIND(armor_max, "0,2000,or_greater");
DATA_PROP_BIND(hull_max, "0,20000,or_greater");

SET_GET_BIND(num_turrets, i32, HullData);
ADD_PROPERTY(PropertyInfo(Variant::INT, "num_turrets"), "set_num_turrets", "get_num_turrets");
Expand Down
61 changes: 61 additions & 0 deletions simulation/hull.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[gd_scene load_steps=6 format=3 uid="uid://bc4c821vpohyq"]

[ext_resource type="Texture2D" uid="uid://cf0c435cfcy25" path="res://icon.svg" id="1_80qki"]

[sub_resource type="HullData" id="HullData_313hc"]
angular_acceleration = 6.283
angular_velocity_max = 6.283

[sub_resource type="GDScript" id="GDScript_c0lu0"]
script/source = "extends Hull

@export var agent : NavigationAgent2D

func _physics_process(_delta: float) -> void:
if agent.is_navigation_finished():
agent.target_position = Vector2(randf_range(50, 1000), randf_range(50, 600)) - position
print(agent.target_position)
return

wish_linear_velocity = agent.get_next_path_position()
wish_linear_velocity_type = Hull.WISH_LINEAR_VELOCITY_TYPE_POSITION_OVERSHOOT
#agent.velocity



queue_redraw()
#print(linear_velocity, linear_velocity.length(), \" | \", angular_velocity, \" | \", sleeping)

func _draw() -> void:
draw_line(Vector2.ZERO, agent.target_position, Color.RED)
"

[sub_resource type="CircleShape2D" id="CircleShape2D_1bc72"]
radius = 20.0

[sub_resource type="CircleShape2D" id="CircleShape2D_e0ugl"]
radius = 32.0

[node name="Hull" type="Hull" node_paths=PackedStringArray("agent")]
data = SubResource("HullData_313hc")
script = SubResource("GDScript_c0lu0")
agent = NodePath("NavigationAgent2D")

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_1bc72")

[node name="Icon2" type="Sprite2D" parent="."]
position = Vector2(0, -21.005)
scale = Vector2(0.1, 0.345)
texture = ExtResource("1_80qki")

[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
avoidance_enabled = true
radius = 30.0
neighbor_distance = 100.0

[node name="ReserverSpace" type="Area2D" parent="."]
position = Vector2(0, -66)

[node name="CollisionShape2D" type="CollisionShape2D" parent="ReserverSpace"]
shape = SubResource("CircleShape2D_e0ugl")
41 changes: 14 additions & 27 deletions simulation/node_2d.tscn
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
[gd_scene load_steps=5 format=3 uid="uid://bggv8q6revg4i"]
[gd_scene load_steps=4 format=3 uid="uid://bggv8q6revg4i"]

[ext_resource type="Texture2D" uid="uid://cf0c435cfcy25" path="res://icon.svg" id="1_mb1ly"]

[sub_resource type="HullData" id="HullData_313hc"]
angular_acceleration = 6.283
angular_velocity_max = 6.283
[sub_resource type="GDScript" id="GDScript_ijgrm"]
script/source = "extends Node2D

[sub_resource type="GDScript" id="GDScript_c0lu0"]
script/source = "extends Hull

#func _ready() -> void:
#set_physics_process(true)

func _physics_process(delta: float) -> void:
print(linear_velocity, linear_velocity.length(), \" | \", angular_velocity, \" | \", sleeping)
func _ready() -> void:
for i in 1:
var h := preload(\"res://hull.tscn\").instantiate()
h.position = Vector2(randf(), randf()) * 600.0
add_child(h)
"
[sub_resource type="RectangleShape2D" id="RectangleShape2D_frvfn"]
[sub_resource type="NavigationPolygon" id="NavigationPolygon_sk4dl"]
vertices = PackedVector2Array(536, 484, 347, 459, 427, 365)
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2)])
[node name="Node2D" type="Node2D"]
script = SubResource("GDScript_ijgrm")
[node name="Hull" type="Hull" parent="."]
position = Vector2(57, 68)
data = SubResource("HullData_313hc")
wish_linear_velocity_type = 1
wish_linear_velocity = Vector2(100, 0)
wish_angular_velocity = Vector2(600, 300)
script = SubResource("GDScript_c0lu0")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hull"]
shape = SubResource("RectangleShape2D_frvfn")
[node name="Icon2" type="Sprite2D" parent="Hull"]
position = Vector2(0, -21.005)
scale = Vector2(0.1, 0.345)
texture = ExtResource("1_mb1ly")
[node name="NavigationRegion2D" type="NavigationRegion2D" parent="."]
navigation_polygon = SubResource("NavigationPolygon_sk4dl")
[node name="Icon" type="Sprite2D" parent="."]
modulate = Color(1, 1, 1, 0.384314)
Expand Down

0 comments on commit 40608e2

Please sign in to comment.