1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-24 17:14:23 +00:00

Create Priority and SamplerPriority

This commit is contained in:
Steffo 2024-04-17 00:55:17 +02:00
parent 54076eea57
commit 3c0439b2a0
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
8 changed files with 207 additions and 1 deletions

10
behaviours/priority.gd Normal file
View file

@ -0,0 +1,10 @@
@icon("res://behaviours/priority.svg")
extends Node
class_name Priority
@export var priority: int = 0
func get_ref() -> Node:
return get_parent()

39
behaviours/priority.svg Normal file
View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 575.99539 575.99537"
version="1.1"
id="svg1"
sodipodi:docname="priority.svg"
width="16"
height="16"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="1.6464844"
inkscape:cx="287.88612"
inkscape:cy="248.71174"
inkscape:window-width="1920"
inkscape:window-height="1020"
inkscape:window-x="1280"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<!--! Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc. -->
<path
d="m 316.72587,49.969031 c -5.3,-11 -16.5,-18 -28.8,-18 -12.3,0 -23.4,7 -28.8,18 l -64.3,132.299999 -143.600005,21.2 c -12,1.8 -22,10.2 -25.7,21.7 -3.7,11.5 -0.7,24.2 7.9,32.7 l 104.200005,103.1 -24.6,145.7 c -2,12 3,24.2 12.9,31.3 9.9,7.1 23,8 33.8,2.3 l 128.3,-68.5 128.3,68.5 c 10.8,5.7 23.9,4.9 33.8,-2.3 9.9,-7.2 14.9,-19.3 12.9,-31.3 l -24.7,-145.7 104.2,-103.1 c 8.6,-8.5 11.7,-21.2 7.9,-32.7 -3.8,-11.5 -13.7,-19.9 -25.7,-21.7 l -143.7,-21.2 z"
id="path1"
style="fill:#e0e0e0" />
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ctc4lx571jksr"
path="res://.godot/imported/priority.svg-d16c10b6303969bc43c2b8feaccb77ae.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://behaviours/priority.svg"
dest_files=["res://.godot/imported/priority.svg-d16c10b6303969bc43c2b8feaccb77ae.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

6
behaviours/priority.tscn Normal file
View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cm67ko1k6kn4u"]
[ext_resource type="Script" path="res://behaviours/priority.gd" id="1_8u7ji"]
[node name="Priority" type="Node"]
script = ExtResource("1_8u7ji")

View file

@ -1,3 +1,4 @@
@icon("res://behaviours/sampler.svg")
extends Node
class_name Sampler

59
behaviours/sampler.svg Normal file
View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 512 512"
version="1.1"
id="svg1"
sodipodi:docname="sampler.svg"
width="16"
height="16"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="13.171875"
inkscape:cx="16.778173"
inkscape:cy="17.651246"
inkscape:window-width="1920"
inkscape:window-height="1020"
inkscape:window-x="3200"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<!--! Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc. -->
<path
d="m 48,368 a 48,48 0 1 1 0,96 48,48 0 1 1 0,-96 z"
id="path6"
style="fill:#e0e0e0" />
<path
d="m 160,416 c 0,-17.7 14.3,-32 32,-32 h 288 c 17.7,0 32,14.3 32,32 0,17.7 -14.3,32 -32,32 H 192 c -17.7,0 -32,-14.3 -32,-32 z"
id="path5"
style="fill:#e0e0e0" />
<path
d="m 160,256 c 0,-17.7 14.3,-32 32,-32 h 288 c 17.7,0 32,14.3 32,32 0,17.7 -14.3,32 -32,32 H 192 c -17.7,0 -32,-14.3 -32,-32 z"
id="path5-7"
style="fill:#e0e0e0" />
<path
d="m 224,96 c 0,-17.7 14.3,-32 32,-32 h 224 c 17.7,0 32,14.3 32,32 0,17.7 -14.3,32 -32,32 H 256 c -17.7,0 -32,-14.3 -32,-32 z"
id="path3"
style="fill:#e0e0e0" />
<path
d="m 152.1,38.2 c 9.9,8.9 10.7,24 1.8,33.9 l -72,80 c -4.4,4.9 -10.6,7.8 -17.2,7.9 -6.6,0.1 -12.9,-2.4 -17.6,-7 L 7,113 c -9.3,-9.4 -9.3,-24.6 0,-34 9.3,-9.4 24.6,-9.4 33.9,0 L 63,101.1 118.1,39.9 C 127,30 142.1,29.2 152,38.1 Z"
id="path1"
style="fill:#8eef97" />
<path
d="M 96,256 A 48,48 0 1 0 5e-7,256 48,48 0 1 0 96,256 Z"
id="path6-5"
style="fill:#e0e0e0" />
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cv32pf38ugoh1"
path="res://.godot/imported/sampler.svg-3634a55299eb9a683092cba4e7d215f9.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://behaviours/sampler.svg"
dest_files=["res://.godot/imported/sampler.svg-3634a55299eb9a683092cba4e7d215f9.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

@ -5,4 +5,21 @@ class_name SamplerPriority
## Always sample the object with the highest priority in the queue.
## TODO
@export var possibilities: Array[Priority] = []
## Get a reference.
func sample() -> Priority:
if len(possibilities) == 0:
return null
# FIXME: Change this to something more efficient when needed
var highest_possibility: Priority = null
for possibility in possibilities:
if possibility.priority > highest_possibility.priority:
highest_possibility = possibility
if highest_possibility == null:
return null
return highest_possibility.get_ref()