gd,refacto: added state chart addon and namespace cleanup
This commit is contained in:
@ -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 |
@ -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
|
47
godot_state_charts_examples/ant_hill/marker/marker.gd
Normal file
47
godot_state_charts_examples/ant_hill/marker/marker.gd
Normal 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 )
|
||||
|
@ -0,0 +1 @@
|
||||
uid://dikixfhsqssxf
|
20
godot_state_charts_examples/ant_hill/marker/marker.tscn
Normal file
20
godot_state_charts_examples/ant_hill/marker/marker.tscn
Normal 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")
|
Reference in New Issue
Block a user