gd,refacto: added state chart addon and namespace cleanup

This commit is contained in:
2025-06-05 14:47:51 +02:00
parent 8818e77d23
commit 5c36765a36
239 changed files with 10430 additions and 115 deletions

View File

@ -0,0 +1,276 @@
extends CharacterBody2D
signal clicked(node:Node2D)
@export var marker_scene:PackedScene
## The navigation agent we use.
@onready var navigation_agent:NavigationAgent2D = $NavigationAgent2D
## The state chart
@onready var state_chart:StateChart = $StateChart
## Set of close food markers
var food_markers:Dictionary = {}
## Set of close nest markers
var nest_markers:Dictionary = {}
## Set of food nearby
var food:Dictionary = {}
## The nest, if nearby
var nest:Node2D = null
## The currently carried food
var carried_food:Node = null
const SEGMENT_LENGTH = 150
func _ready():
# start the state chart
state_chart.send_event.call_deferred("initialized")
## Called when we are seeking for food and need a new target.
func _on_idle_seeking_food():
var current_position := get_global_position()
# if we have food nearby grab it
if food.size() > 0:
state_chart.send_event("food_detected")
return
var target_position := Vector2()
# if we have food markers nearby travel into the general direction of the closest one points
if food_markers.size() > 0:
var closest_food_marker := _find_closest(food_markers.keys(), current_position)
var direction = Vector2.RIGHT.rotated(closest_food_marker.get_rotation())
target_position = current_position + (direction * SEGMENT_LENGTH)
# otherwise or if we couldn't reach the last target position, pick a random
# direction
if food_markers.size() == 0 or not navigation_agent.is_target_reachable():
# otherwise pick a random position in a radius of SEGMENT_LENGTH pixels
# first calculate a random angle in radians
var random_angle := randf() * 2 * PI
# then calculate the x and y components of the vector
var random_x := cos(random_angle) * SEGMENT_LENGTH
var random_y := sin(random_angle) * SEGMENT_LENGTH
# add the random vector to the current position
target_position = current_position + Vector2(random_x, random_y)
navigation_agent.set_target_position(target_position)
state_chart.set_expression_property("target_position", target_position)
state_chart.send_event("destination_set")
## Called when we have found food nearby and want to go to it
func _on_food_detected():
# set the target position to the closest food
var closest_food_position = _find_closest(food.keys(), get_global_position()).global_position
navigation_agent.set_target_position(closest_food_position)
## Called when we arrived at the food and want to pick it up
func _on_food_reached():
var closest_food = _find_closest(food.keys(), get_global_position())
if not is_instance_valid(closest_food):
# some other ant must have picked it up
state_chart.send_event("food_vanished")
return
closest_food.get_parent().remove_child(closest_food)
carried_food = closest_food
# remove it from the food set
food.erase(closest_food)
# it's collected, so remove it from the food group
closest_food.remove_from_group("food")
# add it to our ant so it moves with us
add_child(closest_food)
closest_food.position = Vector2.ZERO
closest_food.scale = Vector2(0.5, 0.5)
# place a marker pointing to the food (0 means point into the current direction)
var marker = _place_marker(Marker.MarkerType.FOOD, global_position, 0)
food_markers[marker] = true
# notify the state chart that we picked up food
state_chart.send_event("food_picked_up")
## Called when we are returning home and need a new target.
func _on_idle_returning_home():
var current_position := get_global_position()
# if the nest is nearby, drop off the food
if nest != null:
state_chart.send_event("nest_detected")
return
var target_position := Vector2()
# if we have nest markers nearby travel into the general direction of the closest one points
if nest_markers.size() > 0:
# refresh them
for marker in nest_markers.keys():
marker.refresh()
var closest_nest_marker := _find_closest(nest_markers.keys(), current_position)
var direction = Vector2.RIGHT.rotated(closest_nest_marker.get_rotation())
target_position = current_position + (direction * SEGMENT_LENGTH)
# if we have no nest markers or the navigation agent couldn't reach
# the position of the last target pick a random direction
if nest_markers.size() == 0 or not navigation_agent.is_target_reachable():
var random_angle := randf() * 2 * PI
# then calculate the x and y components of the vector
var random_x := cos(random_angle) * SEGMENT_LENGTH
var random_y := sin(random_angle) * SEGMENT_LENGTH
# add the random vector to the current position
target_position = current_position + Vector2(random_x, random_y)
navigation_agent.set_target_position(target_position)
state_chart.set_expression_property("target_position", target_position)
state_chart.send_event("destination_set")
return
## Called when we are returning home and detected the nest
func _on_nest_detected():
# travel to the nest
navigation_agent.set_target_position(nest.global_position)
state_chart.set_expression_property("target_position", nest.global_position)
## Called when we have arrived at the nest and want to drop off the food
func _on_nest_reached():
# drop off the food
carried_food.get_parent().remove_child(carried_food)
carried_food.queue_free()
carried_food = null
# notify the state chart that we dropped off the food
state_chart.send_event("food_dropped")
## Called while travelling to a destination
func _on_travelling_state_physics_processing(_delta):
# get the next position on the path
var path_position = navigation_agent.get_next_path_position()
# and move towards it
velocity = (path_position - get_global_position()).normalized() * navigation_agent.max_speed
look_at(path_position)
move_and_slide()
func _on_input_event(_viewport, event, _shape_idx):
# if the left mouse button is up emit the clicked signal
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed() == false:
# print("clicked")
clicked.emit(self)
## Called when the ant is sensing something nearby.
func _on_sensor_area_area_entered(area:Area2D):
var node = area
if area.has_meta("owner"):
node = area.get_node(area.get_meta("owner"))
if node.is_in_group("marker"):
# it's a marker
if node.is_in_group("food"):
food_markers[node] = true
elif node.is_in_group("nest"):
nest_markers[node] = true
elif node.is_in_group("food"):
# it's food
food[node] = true
elif node.is_in_group("nest"):
# it's the nest
nest = node
state_chart.set_expression_property("nest_markers", nest_markers.size())
state_chart.set_expression_property("food_markers", food_markers.size())
func _on_sensor_area_area_exited(area:Area2D):
var node = area
if area.has_meta("owner"):
node = area.get_node(area.get_meta("owner"))
if node.is_in_group("marker"):
# it's a marker
if node.is_in_group("food"):
food_markers.erase(node)
elif node.is_in_group("nest"):
nest_markers.erase(node)
elif node.is_in_group("food"):
# it's food
food.erase(node)
elif node.is_in_group("nest"):
# it's the nest
nest = null
state_chart.set_expression_property("nest_markers", nest_markers.size())
state_chart.set_expression_property("food_markers", nest_markers.size())
## Finds the closest position to the given position from the given list of nodes.
func _find_closest(targets:Array, from:Vector2) -> Node2D:
var shortest_distance := 99999999.00
var result = null
for target in targets:
var distance := from.distance_squared_to(target.get_global_position())
if distance < shortest_distance:
shortest_distance = distance
result = target
return result
## Places a marker of the given type at the given position
func _place_marker(type:Marker.MarkerType, target_position:Vector2, offset:float = PI) -> Marker:
var marker = marker_scene.instantiate()
marker.initialize(type)
# add to the tree on our parent
get_parent().add_child.call_deferred(marker)
# set the position to our current position
marker.set_global_position(target_position)
# set the marker rotation to look opposite to the direction we are facing
marker.set_rotation(get_rotation() + offset)
return marker
func _place_nest_marker():
# if there are already nest markers around, just refresh them
if nest_markers.size() > 0:
for marker in nest_markers:
marker.refresh()
else:
# otherwise place a new one
_place_marker(Marker.MarkerType.NEST, global_position)
func _place_food_marker():
_place_marker(Marker.MarkerType.FOOD, global_position)
func _maintenance(_delta):
# remove all markers which are no longer valid
for marker in food_markers.keys():
if not is_instance_valid(marker):
food_markers.erase(marker)
for marker in nest_markers.keys():
if not is_instance_valid(marker):
nest_markers.erase(marker)

View File

@ -0,0 +1 @@
uid://d4ld8mlrjp04a

View File

@ -0,0 +1,5 @@
shader_type canvas_item;
void fragment() {
COLOR = COLOR + vec4(.3,.3,.1,.0);
}

View File

@ -0,0 +1 @@
uid://bx4vu24rcr0m5

View File

@ -0,0 +1,686 @@
[gd_scene load_steps=75 format=3 uid="uid://dy43c80qlfftx"]
[ext_resource type="Shader" path="res://godot_state_charts_examples/ant_hill/ant/ant.gdshader" id="1_01qat"]
[ext_resource type="Texture2D" uid="uid://bqgc7cft671q0" path="res://godot_state_charts_examples/ant_hill/ant/walk.png" id="1_7ajse"]
[ext_resource type="Script" path="res://godot_state_charts_examples/ant_hill/ant/ant.gd" id="1_i761n"]
[ext_resource type="PackedScene" uid="uid://dy5xrmjffewnk" path="res://godot_state_charts_examples/ant_hill/marker/marker.tscn" id="2_lqnr1"]
[ext_resource type="Script" path="res://addons/godot_state_charts/state_chart.gd" id="3_lard5"]
[ext_resource type="Script" path="res://addons/godot_state_charts/compound_state.gd" id="4_ejp2e"]
[ext_resource type="Script" path="res://addons/godot_state_charts/atomic_state.gd" id="5_21sgy"]
[ext_resource type="Script" path="res://addons/godot_state_charts/transition.gd" id="7_qj278"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_bjtx1"]
shader = ExtResource("1_01qat")
[sub_resource type="AtlasTexture" id="AtlasTexture_p0h5v"]
atlas = ExtResource("1_7ajse")
region = Rect2(0, 0, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_mubvl"]
atlas = ExtResource("1_7ajse")
region = Rect2(202, 0, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_nj3h7"]
atlas = ExtResource("1_7ajse")
region = Rect2(404, 0, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_fij1g"]
atlas = ExtResource("1_7ajse")
region = Rect2(606, 0, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_i21td"]
atlas = ExtResource("1_7ajse")
region = Rect2(808, 0, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_a0fxu"]
atlas = ExtResource("1_7ajse")
region = Rect2(1010, 0, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_bwhdr"]
atlas = ExtResource("1_7ajse")
region = Rect2(1212, 0, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_hm8dw"]
atlas = ExtResource("1_7ajse")
region = Rect2(1414, 0, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_lfnfv"]
atlas = ExtResource("1_7ajse")
region = Rect2(0, 248, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_kljff"]
atlas = ExtResource("1_7ajse")
region = Rect2(202, 248, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_t8fco"]
atlas = ExtResource("1_7ajse")
region = Rect2(404, 248, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_blb68"]
atlas = ExtResource("1_7ajse")
region = Rect2(606, 248, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_2k7ie"]
atlas = ExtResource("1_7ajse")
region = Rect2(808, 248, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_vpjgq"]
atlas = ExtResource("1_7ajse")
region = Rect2(1010, 248, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_ykqrl"]
atlas = ExtResource("1_7ajse")
region = Rect2(1212, 248, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_yq06r"]
atlas = ExtResource("1_7ajse")
region = Rect2(1414, 248, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_m8wtm"]
atlas = ExtResource("1_7ajse")
region = Rect2(0, 496, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_ytxlu"]
atlas = ExtResource("1_7ajse")
region = Rect2(202, 496, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_jiy2o"]
atlas = ExtResource("1_7ajse")
region = Rect2(404, 496, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_vfiyg"]
atlas = ExtResource("1_7ajse")
region = Rect2(606, 496, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_sl3a2"]
atlas = ExtResource("1_7ajse")
region = Rect2(808, 496, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_nmj2f"]
atlas = ExtResource("1_7ajse")
region = Rect2(1010, 496, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_sngog"]
atlas = ExtResource("1_7ajse")
region = Rect2(1212, 496, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_71qgv"]
atlas = ExtResource("1_7ajse")
region = Rect2(1414, 496, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_88uru"]
atlas = ExtResource("1_7ajse")
region = Rect2(0, 744, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_kqc1k"]
atlas = ExtResource("1_7ajse")
region = Rect2(202, 744, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_ar5xr"]
atlas = ExtResource("1_7ajse")
region = Rect2(404, 744, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_xs12g"]
atlas = ExtResource("1_7ajse")
region = Rect2(606, 744, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_6mpdc"]
atlas = ExtResource("1_7ajse")
region = Rect2(808, 744, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_lqwgf"]
atlas = ExtResource("1_7ajse")
region = Rect2(1010, 744, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_xrg7o"]
atlas = ExtResource("1_7ajse")
region = Rect2(1212, 744, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_kmp2k"]
atlas = ExtResource("1_7ajse")
region = Rect2(1414, 744, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_hpmfd"]
atlas = ExtResource("1_7ajse")
region = Rect2(0, 992, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_3osu6"]
atlas = ExtResource("1_7ajse")
region = Rect2(202, 992, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_gdwlg"]
atlas = ExtResource("1_7ajse")
region = Rect2(404, 992, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_hau5u"]
atlas = ExtResource("1_7ajse")
region = Rect2(606, 992, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_2uawa"]
atlas = ExtResource("1_7ajse")
region = Rect2(808, 992, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_aj6m3"]
atlas = ExtResource("1_7ajse")
region = Rect2(1010, 992, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_lnduy"]
atlas = ExtResource("1_7ajse")
region = Rect2(1212, 992, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_bqt77"]
atlas = ExtResource("1_7ajse")
region = Rect2(1414, 992, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_plrtj"]
atlas = ExtResource("1_7ajse")
region = Rect2(0, 1240, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_ggvde"]
atlas = ExtResource("1_7ajse")
region = Rect2(202, 1240, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_xavhi"]
atlas = ExtResource("1_7ajse")
region = Rect2(404, 1240, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_ev8ji"]
atlas = ExtResource("1_7ajse")
region = Rect2(606, 1240, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_65x5e"]
atlas = ExtResource("1_7ajse")
region = Rect2(808, 1240, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_yi6fp"]
atlas = ExtResource("1_7ajse")
region = Rect2(1010, 1240, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_eseb1"]
atlas = ExtResource("1_7ajse")
region = Rect2(1212, 1240, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_ux63t"]
atlas = ExtResource("1_7ajse")
region = Rect2(1414, 1240, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_ocabh"]
atlas = ExtResource("1_7ajse")
region = Rect2(0, 1488, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_8sepc"]
atlas = ExtResource("1_7ajse")
region = Rect2(202, 1488, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_4d7on"]
atlas = ExtResource("1_7ajse")
region = Rect2(404, 1488, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_jsu7m"]
atlas = ExtResource("1_7ajse")
region = Rect2(606, 1488, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_vhyb2"]
atlas = ExtResource("1_7ajse")
region = Rect2(808, 1488, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_t2dka"]
atlas = ExtResource("1_7ajse")
region = Rect2(1010, 1488, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_e6l64"]
atlas = ExtResource("1_7ajse")
region = Rect2(1212, 1488, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_mdp8v"]
atlas = ExtResource("1_7ajse")
region = Rect2(1414, 1488, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_ywpdo"]
atlas = ExtResource("1_7ajse")
region = Rect2(0, 1736, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_1d2bj"]
atlas = ExtResource("1_7ajse")
region = Rect2(202, 1736, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_80asc"]
atlas = ExtResource("1_7ajse")
region = Rect2(404, 1736, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_m5ngl"]
atlas = ExtResource("1_7ajse")
region = Rect2(606, 1736, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_r7ql0"]
atlas = ExtResource("1_7ajse")
region = Rect2(808, 1736, 202, 248)
[sub_resource type="AtlasTexture" id="AtlasTexture_w0vp4"]
atlas = ExtResource("1_7ajse")
region = Rect2(1010, 1736, 202, 248)
[sub_resource type="SpriteFrames" id="SpriteFrames_kcoy1"]
animations = [{
"frames": [],
"loop": true,
"name": &"default",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_p0h5v")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_mubvl")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nj3h7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fij1g")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_i21td")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_a0fxu")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bwhdr")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hm8dw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lfnfv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kljff")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_t8fco")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_blb68")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2k7ie")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vpjgq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ykqrl")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_yq06r")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m8wtm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ytxlu")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jiy2o")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vfiyg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_sl3a2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nmj2f")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_sngog")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_71qgv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_88uru")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kqc1k")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ar5xr")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xs12g")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6mpdc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lqwgf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xrg7o")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kmp2k")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hpmfd")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3osu6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gdwlg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hau5u")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2uawa")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aj6m3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lnduy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bqt77")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_plrtj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ggvde")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xavhi")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ev8ji")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_65x5e")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_yi6fp")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_eseb1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ux63t")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ocabh")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8sepc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_4d7on")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jsu7m")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vhyb2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_t2dka")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e6l64")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_mdp8v")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ywpdo")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1d2bj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_80asc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m5ngl")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_r7ql0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_w0vp4")
}],
"loop": true,
"name": &"walk",
"speed": 64.0
}]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_1lk3q"]
radius = 4.0
height = 12.0
[sub_resource type="CircleShape2D" id="CircleShape2D_htg24"]
radius = 80.0
[node name="Ant" type="CharacterBody2D"]
z_index = 2048
z_as_relative = false
collision_layer = 16
input_pickable = true
motion_mode = 1
platform_on_leave = 2
safe_margin = 2.615
script = ExtResource("1_i761n")
marker_scene = ExtResource("2_lqnr1")
[node name="Sprite2D" type="AnimatedSprite2D" parent="."]
material = SubResource("ShaderMaterial_bjtx1")
rotation = 1.5708
scale = Vector2(0.05, 0.05)
sprite_frames = SubResource("SpriteFrames_kcoy1")
animation = &"walk"
frame_progress = 0.938219
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
editor_description = "This navigation agent sends the \"navigation_finished\" event to the state chart whenever the navigation is done."
avoidance_enabled = true
radius = 40.0
max_speed = 50.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 1)
shape = SubResource("CapsuleShape2D_1lk3q")
[node name="SensorArea" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="SensorArea"]
shape = SubResource("CircleShape2D_htg24")
[node name="StateChart" type="Node" parent="."]
script = ExtResource("3_lard5")
track_in_editor = true
[node name="Root" type="Node" parent="StateChart"]
script = ExtResource("4_ejp2e")
initial_state = NodePath("Initializing")
[node name="Initializing" type="Node" parent="StateChart/Root"]
editor_description = "This state is used for script initialization."
script = ExtResource("5_21sgy")
[node name="Transition" type="Node" parent="StateChart/Root/Initializing"]
script = ExtResource("7_qj278")
to = NodePath("../../Seeking Food")
event = &"initialized"
[node name="Seeking Food" type="Node" parent="StateChart/Root"]
editor_description = "In this state, the ant will look for food."
script = ExtResource("4_ejp2e")
initial_state = NodePath("Idle")
[node name="Idle" type="Node" parent="StateChart/Root/Seeking Food"]
editor_description = "This state is active when the ant currently has no target. It is connected to the script which will look for a new target."
script = ExtResource("5_21sgy")
[node name="On Next Destination" type="Node" parent="StateChart/Root/Seeking Food/Idle"]
script = ExtResource("7_qj278")
to = NodePath("../../Travelling/Place Marker")
event = &"destination_set"
[node name="On Food Detected" type="Node" parent="StateChart/Root/Seeking Food/Idle"]
script = ExtResource("7_qj278")
to = NodePath("../../../Picking up Food")
event = &"food_detected"
[node name="Travelling" type="Node" parent="StateChart/Root/Seeking Food"]
script = ExtResource("4_ejp2e")
initial_state = NodePath("Travel")
[node name="On Navigation Finish" type="Node" parent="StateChart/Root/Seeking Food/Travelling"]
editor_description = "When navigation is finished return to idle state."
script = ExtResource("7_qj278")
to = NodePath("../../Idle")
event = &"navigation_finished"
[node name="Travel" type="Node" parent="StateChart/Root/Seeking Food/Travelling"]
editor_description = "This state is active while the ant is travelling when searching for food. Periodically the state will be left for placing a marker."
script = ExtResource("5_21sgy")
[node name="Periodically Place Marker" type="Node" parent="StateChart/Root/Seeking Food/Travelling/Travel"]
editor_description = "While searching for food, periodically place a marker pointing towards the nest. This transition will move to the \"Place Marker\" state which will trigger the placement of the marker. The \"Place Marker\" state will immediately return back to the \"Travel\" state."
script = ExtResource("7_qj278")
to = NodePath("../../Place Marker")
delay_seconds = 0.75
[node name="Place Marker" type="Node" parent="StateChart/Root/Seeking Food/Travelling"]
editor_description = "This state is briefly activated when the ant wants to place a marker. It will immediately exit again to the \"Travel\" state."
script = ExtResource("5_21sgy")
[node name="Return travelling" type="Node" parent="StateChart/Root/Seeking Food/Travelling/Place Marker"]
script = ExtResource("7_qj278")
to = NodePath("../../Travel")
[node name="Picking up Food" type="Node" parent="StateChart/Root"]
editor_description = "This state is active when the ant has detected food and wants to pick it up."
script = ExtResource("4_ejp2e")
initial_state = NodePath("Travelling")
[node name="Travelling" type="Node" parent="StateChart/Root/Picking up Food"]
editor_description = "This state is active while the ant is moving towards the food."
script = ExtResource("5_21sgy")
[node name="On Navigation Finish" type="Node" parent="StateChart/Root/Picking up Food/Travelling"]
editor_description = "When navigation is finished we can pick up the food."
script = ExtResource("7_qj278")
to = NodePath("../../Picking Up")
event = &"navigation_finished"
[node name="Picking Up" type="Node" parent="StateChart/Root/Picking up Food"]
editor_description = "This state is active when the ant has reached the food and now picks it up."
script = ExtResource("5_21sgy")
[node name="On Picked Up" type="Node" parent="StateChart/Root/Picking up Food/Picking Up"]
editor_description = "When navigation is finished return to idle state."
script = ExtResource("7_qj278")
to = NodePath("../../../Returning Home")
event = &"food_picked_up"
[node name="On Food Vanished" type="Node" parent="StateChart/Root/Picking up Food/Picking Up"]
editor_description = "When navigation is finished return to idle state."
script = ExtResource("7_qj278")
to = NodePath("../../../Seeking Food")
event = &"food_vanished"
[node name="Returning Home" type="Node" parent="StateChart/Root"]
editor_description = "This state is active when the ant has found food and wants to return home."
script = ExtResource("4_ejp2e")
initial_state = NodePath("Idle")
[node name="Idle" type="Node" parent="StateChart/Root/Returning Home"]
editor_description = "This state is active when the ant currently has no destination. It calls back into the script which will setup a new destination."
script = ExtResource("5_21sgy")
[node name="On Next Destination" type="Node" parent="StateChart/Root/Returning Home/Idle"]
script = ExtResource("7_qj278")
to = NodePath("../../Travelling")
event = &"destination_set"
[node name="On Nest Detected" type="Node" parent="StateChart/Root/Returning Home/Idle"]
script = ExtResource("7_qj278")
to = NodePath("../../../Delivering Food")
event = &"nest_detected"
[node name="Travelling" type="Node" parent="StateChart/Root/Returning Home"]
editor_description = "This state is active when the ant has a destination and is currently travelling."
script = ExtResource("4_ejp2e")
initial_state = NodePath("Travel")
[node name="On Navigation Finish" type="Node" parent="StateChart/Root/Returning Home/Travelling"]
editor_description = "When navigation is finished return to idle state."
script = ExtResource("7_qj278")
to = NodePath("../../Idle")
event = &"navigation_finished"
[node name="Travel" type="Node" parent="StateChart/Root/Returning Home/Travelling"]
script = ExtResource("5_21sgy")
[node name="Periodically Place Marker" type="Node" parent="StateChart/Root/Returning Home/Travelling/Travel"]
script = ExtResource("7_qj278")
to = NodePath("../../Place Marker")
delay_seconds = 1.0
[node name="Place Marker" type="Node" parent="StateChart/Root/Returning Home/Travelling"]
editor_description = "This state is active when the ant has a destination and is moving towards it."
script = ExtResource("5_21sgy")
[node name="Return travelling" type="Node" parent="StateChart/Root/Returning Home/Travelling/Place Marker"]
script = ExtResource("7_qj278")
to = NodePath("../../Travel")
[node name="Delivering Food" type="Node" parent="StateChart/Root"]
editor_description = "This state is active when the ant has detected the nest and wants to bring food back."
script = ExtResource("4_ejp2e")
initial_state = NodePath("Travelling")
[node name="Travelling" type="Node" parent="StateChart/Root/Delivering Food"]
editor_description = "This state is active when the ant is moving towards the nest."
script = ExtResource("5_21sgy")
[node name="On Navigation Finish" type="Node" parent="StateChart/Root/Delivering Food/Travelling"]
editor_description = "When navigation is finished we can pick up the food."
script = ExtResource("7_qj278")
to = NodePath("../../Dropping")
event = &"navigation_finished"
[node name="Dropping" type="Node" parent="StateChart/Root/Delivering Food"]
editor_description = "This state is active when the ant is dropping the food off at the nest."
script = ExtResource("5_21sgy")
[node name="On Dropped" type="Node" parent="StateChart/Root/Delivering Food/Dropping"]
editor_description = "When navigation is finished return to idle state."
script = ExtResource("7_qj278")
to = NodePath("../../../Seeking Food")
event = &"food_dropped"
[connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="ready" from="Sprite2D" to="Sprite2D" method="play" binds= ["walk"]]
[connection signal="navigation_finished" from="NavigationAgent2D" to="StateChart" method="send_event" binds= [&"navigation_finished"]]
[connection signal="area_entered" from="SensorArea" to="." method="_on_sensor_area_area_entered"]
[connection signal="area_exited" from="SensorArea" to="." method="_on_sensor_area_area_exited"]
[connection signal="state_physics_processing" from="StateChart/Root" to="." method="_maintenance"]
[connection signal="state_entered" from="StateChart/Root/Seeking Food/Idle" to="." method="_on_idle_seeking_food"]
[connection signal="state_physics_processing" from="StateChart/Root/Seeking Food/Travelling" to="." method="_on_travelling_state_physics_processing"]
[connection signal="state_entered" from="StateChart/Root/Seeking Food/Travelling/Place Marker" to="." method="_place_nest_marker"]
[connection signal="state_entered" from="StateChart/Root/Picking up Food/Travelling" to="." method="_on_food_detected"]
[connection signal="state_physics_processing" from="StateChart/Root/Picking up Food/Travelling" to="." method="_on_travelling_state_physics_processing"]
[connection signal="state_entered" from="StateChart/Root/Picking up Food/Picking Up" to="." method="_on_food_reached"]
[connection signal="state_entered" from="StateChart/Root/Returning Home/Idle" to="." method="_on_idle_returning_home"]
[connection signal="state_physics_processing" from="StateChart/Root/Returning Home/Travelling" to="." method="_on_travelling_state_physics_processing"]
[connection signal="state_entered" from="StateChart/Root/Returning Home/Travelling/Place Marker" to="." method="_place_food_marker"]
[connection signal="state_entered" from="StateChart/Root/Delivering Food/Travelling" to="." method="_on_nest_detected"]
[connection signal="state_physics_processing" from="StateChart/Root/Delivering Food/Travelling" to="." method="_on_travelling_state_physics_processing"]
[connection signal="state_entered" from="StateChart/Root/Delivering Food/Dropping" to="." method="_on_nest_reached"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bqgc7cft671q0"
path="res://.godot/imported/walk.png-77b94883438df4792795bd4b6c922fa6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://godot_state_charts_examples/ant_hill/ant/walk.png"
dest_files=["res://.godot/imported/walk.png-77b94883438df4792795bd4b6c922fa6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -0,0 +1,9 @@
extends Node2D
func _ready():
# initialize the RNG
randomize()

View File

@ -0,0 +1 @@
uid://dyop2ixs375ks

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="M5.333,13.165C5.333,13.165 10.079,16.966 13.732,17.071C17.386,17.176 23.307,15.769 24.798,14.929C26.289,14.089 26.856,11.297 26.856,11.297L28.325,9.953L26.94,14.32L25.995,19.003C25.995,19.003 21.018,22.152 17.26,22.635C13.501,23.118 6.971,20.598 5.879,19.276C4.787,17.953 3.566,15.518 3.36,14.488C3.152,13.453 3.57,12.388 3.57,12.388L5.333,13.165Z" style="fill:url(#_Linear1);"/>
<path d="M3.302,13.48C3.302,13.48 7.692,16.731 9.344,17.659C10.751,18.449 12.374,18.937 13.984,19.045C15.871,19.171 18.789,18.922 20.661,18.415C22.32,17.965 26.478,14.446 26.478,14.446C26.478,14.446 24.209,18.586 22.719,19.171C21.078,19.815 17.813,20.71 16,20.724C14.407,20.737 12.122,20.406 10.625,19.864C8.997,19.274 6.156,17.773 5.06,16.828C4.245,16.125 3.302,13.48 3.302,13.48Z" style="fill:url(#_Radial2);"/>
<defs>
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-3.92912,9.49081,-9.49081,-3.92912,17.2441,14.2665)"><stop offset="0" style="stop-color:rgb(214,255,76);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(157,238,0);stop-opacity:1"/></linearGradient>
<radialGradient id="_Radial2" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.48819,-23.1229,23.1229,2.48819,12.1575,18.7297)"><stop offset="0" style="stop-color:black;stop-opacity:0.16"/><stop offset="0.38" style="stop-color:black;stop-opacity:0"/><stop offset="1" style="stop-color:black;stop-opacity:0"/></radialGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cqt6bgiwgqym7"
path="res://.godot/imported/banana.svg-e48dc3ddd49722cb94ca8f088061cec6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://godot_state_charts_examples/ant_hill/banana/banana.svg"
dest_files=["res://.godot/imported/banana.svg-e48dc3ddd49722cb94ca8f088061cec6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@ -0,0 +1,20 @@
[gd_scene load_steps=3 format=3 uid="uid://bqalfgp8jjady"]
[ext_resource type="Texture2D" uid="uid://cqt6bgiwgqym7" path="res://godot_state_charts_examples/ant_hill/banana/banana.svg" id="1_uoy0d"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_vo3bi"]
radius = 7.99901
height = 32.0275
[node name="banana" type="Node2D" groups=["food"]]
[node name="Sprite2D" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_uoy0d")
[node name="Area2D" type="Area2D" parent="."]
metadata/owner = NodePath("..")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
rotation = 1.5865
shape = SubResource("CapsuleShape2D_vo3bi")

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
<g transform="matrix(1.89907,0,0,1.89907,-11.2249,-10.4075)">
<circle cx="10.123" cy="9.693" r="4.213" style="fill:white;"/>
</g>
<path d="M8,1.533L13.596,6.688L8,6.824L8,13.638L8,6.824L2.394,6.688L8,1.533Z" style="fill:none;stroke:black;stroke-width:1px;"/>
</svg>

After

Width:  |  Height:  |  Size: 752 B

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b3k7i5rrn5hhl"
path="res://.godot/imported/circle_white.svg-63c895b75f0338e9c3ca264b87816990.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://godot_state_charts_examples/ant_hill/marker/circle_white.svg"
dest_files=["res://.godot/imported/circle_white.svg-63c895b75f0338e9c3ca264b87816990.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@ -0,0 +1,47 @@
class_name Marker
extends Node2D
## How long should the marker live for?
@export var lifetime_seconds:float = 30.0
var expired_time:float = 0
enum MarkerType {
## A marker guiding towards food.
FOOD,
## A marker guiding towards a nest.
NEST
}
func initialize(type:MarkerType):
add_to_group("marker")
match type:
MarkerType.FOOD:
modulate = Color.YELLOW
add_to_group("food")
MarkerType.NEST:
modulate = Color.CORNFLOWER_BLUE
add_to_group("nest")
lifetime_seconds *= 2
## Refreshes the marker, so it stays for another lifetime
func refresh():
expired_time = 0
## Updates the marker and destroys it if has evaporated.
func _process(delta):
expired_time += delta
# Fade out the marker as it expires.
modulate.a = max(0, 1 - (expired_time / lifetime_seconds))
if expired_time > lifetime_seconds:
queue_free()
## Some debug drawing currently disabled.
func __draw():
var offset = 0.0 if is_in_group("food") else PI
var start_angle = - PI / 2 + offset
var end_angle = PI / 2 + offset
draw_arc(Vector2.ZERO, 30, start_angle, end_angle, 10, modulate, 1, true )

View File

@ -0,0 +1 @@
uid://dikixfhsqssxf

View File

@ -0,0 +1,20 @@
[gd_scene load_steps=4 format=3 uid="uid://dy5xrmjffewnk"]
[ext_resource type="Texture2D" uid="uid://b3k7i5rrn5hhl" path="res://godot_state_charts_examples/ant_hill/marker/circle_white.svg" id="1_2vg4s"]
[ext_resource type="Script" path="res://godot_state_charts_examples/ant_hill/marker/marker.gd" id="2_2b6iy"]
[sub_resource type="CircleShape2D" id="CircleShape2D_0xsut"]
[node name="Node2D" type="Node2D"]
script = ExtResource("2_2b6iy")
[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
rotation = 1.5708
texture = ExtResource("1_2vg4s")
[node name="Area2D" type="Area2D" parent="."]
metadata/owner = NodePath("..")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_0xsut")

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
<path d="M2.751,26.163C2.751,26.163 9.264,27.569 14.887,28.036C21.176,28.559 29.249,27.192 29.249,27.192L28.619,18.541L24.672,14.026C24.672,14.026 21.585,13.858 20.367,11.108C19.15,8.357 17.071,7.853 15.349,7.496C13.627,7.139 10.457,9.869 9.68,10.079C8.903,10.289 9.722,11.717 8.063,14.278C6.404,16.84 7.307,18.667 5.921,19.864C4.535,21.06 2.751,26.163 2.751,26.163" style="fill:url(#_Linear1);"/>
<path d="M21.816,25.071C21.816,25.071 23.097,21.585 24.714,21.858C26.331,22.131 25.512,21.186 26.268,20.367" style="fill:none;stroke:rgb(174,159,25);stroke-width:1px;"/>
<g transform="matrix(1,0,0,0.592883,0,8.94162)">
<path d="M5.438,21.963C5.438,21.963 8.987,25.743 11.801,25.512C14.614,25.281 16.567,23.643 16.567,23.643" style="fill:none;stroke:url(#_Linear2);stroke-width:1.22px;"/>
</g>
<g transform="matrix(1,0,0,0.592883,3.65354,1.99149)">
<path d="M5.438,21.963C5.438,21.963 9.533,27.089 12.346,26.858C15.16,26.627 18.163,29.664 18.163,29.664" style="fill:none;stroke:url(#_Linear3);stroke-width:1.22px;"/>
</g>
<defs>
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.09974,-9.07087,9.07087,2.09974,12.6404,23.2021)"><stop offset="0" style="stop-color:rgb(73,64,28);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(140,131,94);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear2" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(11.1286,0,0,3.55873,5.43832,23.7426)"><stop offset="0" style="stop-color:rgb(30,100,0);stop-opacity:1"/><stop offset="0.54" style="stop-color:rgb(207,198,119);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(174,159,25);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear3" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(11.1286,0,0,3.55873,5.43832,23.7426)"><stop offset="0" style="stop-color:rgb(30,100,0);stop-opacity:1"/><stop offset="0.54" style="stop-color:rgb(207,198,119);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(174,159,25);stop-opacity:1"/></linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://xb5fialweqfw"
path="res://.godot/imported/nest.svg-4361abbd79cc59afa101f89034d762a6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://godot_state_charts_examples/ant_hill/nest/nest.svg"
dest_files=["res://.godot/imported/nest.svg-4361abbd79cc59afa101f89034d762a6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=3]
[ext_resource type="Texture2D" uid="uid://xb5fialweqfw" path="res://godot_state_charts_examples/ant_hill/nest/nest.svg" id="1_8slek"]
[sub_resource type="CircleShape2D" id="CircleShape2D_b8f1n"]
radius = 37.1214
[node name="Nest" type="Sprite2D" groups=["nest"]]
texture = ExtResource("1_8slek")
[node name="Area2D" type="Area2D" parent="."]
metadata/owner = NodePath("..")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(-1, -1)
shape = SubResource("CircleShape2D_b8f1n")

View File

@ -0,0 +1,10 @@
extends Node
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS
func _input(event):
if event is InputEventKey and event.is_pressed() and event.keycode == KEY_SPACE:
get_tree().paused = not get_tree().paused
print("Paused ", get_tree().paused)

View File

@ -0,0 +1 @@
uid://nonu8fobnml7