mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-21 23:54:23 +00:00
Add summoning circle
This commit is contained in:
parent
4944333706
commit
cc08edca99
11 changed files with 206 additions and 16 deletions
16
behaviours/monster_type.gd
Normal file
16
behaviours/monster_type.gd
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
@icon("res://behaviours/edible.svg")
|
||||||
|
extends Node
|
||||||
|
class_name MonsterType
|
||||||
|
|
||||||
|
## Emits [signal eaten] when eaten by an [Eater] whose acceptable diets contain this node's [field diet].
|
||||||
|
##
|
||||||
|
## To add multiple possible [Edible] diets to an entity, add multiple [Edible] nodes to it.
|
||||||
|
|
||||||
|
signal sacrificed
|
||||||
|
|
||||||
|
|
||||||
|
@export var type: Enums.MonsterType = Enums.MonsterType.Sheep
|
||||||
|
|
||||||
|
|
||||||
|
func sarcifice():
|
||||||
|
sacrificed.emit()
|
6
behaviours/monster_type.tscn
Normal file
6
behaviours/monster_type.tscn
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://ccul07w0h36nu"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://behaviours/monster_type.gd" id="1_6jq3j"]
|
||||||
|
|
||||||
|
[node name="MonsterType" type="Node"]
|
||||||
|
script = ExtResource("1_6jq3j")
|
28
entities/sacrifice_stone.gd
Normal file
28
entities/sacrifice_stone.gd
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
extends Node2D
|
||||||
|
class_name SacrificeStone
|
||||||
|
|
||||||
|
signal sacrifice_changed(entity: Node2D, type: Enums.MonsterType)
|
||||||
|
|
||||||
|
var current_monster: Node2D
|
||||||
|
var current_type: Enums.MonsterType = Enums.MonsterType.None
|
||||||
|
|
||||||
|
func _on_tracked(body: Node2D):
|
||||||
|
if current_monster != null:
|
||||||
|
Log.w(self, "Captured two entities")
|
||||||
|
return
|
||||||
|
|
||||||
|
var types: Array = body.find_children("*", "MonsterType", false, false)
|
||||||
|
for type in types:
|
||||||
|
current_monster = body
|
||||||
|
current_type = type.type
|
||||||
|
sacrifice_changed.emit(current_monster, current_type)
|
||||||
|
break
|
||||||
|
|
||||||
|
if current_monster == null:
|
||||||
|
Log.w(self, "Captured entity with no MonsterType")
|
||||||
|
|
||||||
|
func _on_untracked(body: Node2D):
|
||||||
|
if body == current_monster:
|
||||||
|
current_monster = null
|
||||||
|
current_type = Enums.MonsterType.None
|
||||||
|
sacrifice_changed.emit(current_monster, current_type)
|
|
@ -1,5 +1,6 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://4xivigiybb1d"]
|
[gd_scene load_steps=6 format=3 uid="uid://4xivigiybb1d"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://entities/sacrifice_stone.gd" id="1_sgl1t"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dfdr3e32lohq" path="res://behaviours/edible.tscn" id="1_y58y4"]
|
[ext_resource type="PackedScene" uid="uid://dfdr3e32lohq" path="res://behaviours/edible.tscn" id="1_y58y4"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="2_6m7pn"]
|
[ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="2_6m7pn"]
|
||||||
[ext_resource type="Texture2D" uid="uid://d3pn6wuykchoa" path="res://entities/sacrifice_stone.png" id="2_rbklw"]
|
[ext_resource type="Texture2D" uid="uid://d3pn6wuykchoa" path="res://entities/sacrifice_stone.png" id="2_rbklw"]
|
||||||
|
@ -7,26 +8,31 @@
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_yv6hf"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_yv6hf"]
|
||||||
radius = 0.01
|
radius = 0.01
|
||||||
|
|
||||||
[node name="SacrificeStone" type="Area2D"]
|
[node name="SacrificeStone" type="Node2D"]
|
||||||
position = Vector2(50, 50)
|
script = ExtResource("1_sgl1t")
|
||||||
|
|
||||||
|
[node name="StoneArea" type="Area2D" parent="."]
|
||||||
collision_layer = 8
|
collision_layer = 8
|
||||||
collision_mask = 24
|
collision_mask = 24
|
||||||
monitoring = false
|
monitoring = false
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="Shape" type="CollisionShape2D" parent="StoneArea"]
|
||||||
shape = SubResource("CircleShape2D_yv6hf")
|
shape = SubResource("CircleShape2D_yv6hf")
|
||||||
one_way_collision_margin = 27.5
|
one_way_collision_margin = 27.5
|
||||||
|
|
||||||
[node name="Edible" parent="." instance=ExtResource("1_y58y4")]
|
[node name="Edible" parent="StoneArea" instance=ExtResource("1_y58y4")]
|
||||||
diet = &"Trap"
|
diet = &"Trap"
|
||||||
|
|
||||||
[node name="SacrStone" parent="." instance=ExtResource("2_6m7pn")]
|
[node name="SacrificeTracker" parent="StoneArea" instance=ExtResource("2_6m7pn")]
|
||||||
collision_mask = 56
|
collision_mask = 56
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="SacrStone"]
|
[node name="Sprite" type="Sprite2D" parent="StoneArea/SacrificeTracker"]
|
||||||
position = Vector2(0, 22)
|
position = Vector2(0, 22)
|
||||||
texture = ExtResource("2_rbklw")
|
texture = ExtResource("2_rbklw")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="SacrStone"]
|
[node name="Shape" type="CollisionShape2D" parent="StoneArea/SacrificeTracker"]
|
||||||
shape = SubResource("CircleShape2D_yv6hf")
|
shape = SubResource("CircleShape2D_yv6hf")
|
||||||
one_way_collision_margin = 27.5
|
one_way_collision_margin = 27.5
|
||||||
|
|
||||||
|
[connection signal="tracked" from="StoneArea/SacrificeTracker" to="." method="_on_tracked"]
|
||||||
|
[connection signal="untracked" from="StoneArea/SacrificeTracker" to="." method="_on_untracked"]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=29 format=3 uid="uid://bc2bm8lbol18w"]
|
[gd_scene load_steps=30 format=3 uid="uid://bc2bm8lbol18w"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://entities/sheep.gd" id="1_4dmll"]
|
[ext_resource type="Script" path="res://entities/sheep.gd" id="1_4dmll"]
|
||||||
[ext_resource type="Texture2D" uid="uid://iljp5yn3ehfk" path="res://entities/sheep_left.png" id="2_t13f5"]
|
[ext_resource type="Texture2D" uid="uid://iljp5yn3ehfk" path="res://entities/sheep_left.png" id="2_t13f5"]
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://cfduc7cdorasr" path="res://entities/sheep_drag_left.png" id="5_gh6h6"]
|
[ext_resource type="Texture2D" uid="uid://cfduc7cdorasr" path="res://entities/sheep_drag_left.png" id="5_gh6h6"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dfdr3e32lohq" path="res://behaviours/edible.tscn" id="6_3odsh"]
|
[ext_resource type="PackedScene" uid="uid://dfdr3e32lohq" path="res://behaviours/edible.tscn" id="6_3odsh"]
|
||||||
[ext_resource type="Texture2D" uid="uid://m5bebwb06kqe" path="res://entities/sheep_drag_right.png" id="6_x4fsj"]
|
[ext_resource type="Texture2D" uid="uid://m5bebwb06kqe" path="res://entities/sheep_drag_right.png" id="6_x4fsj"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ccul07w0h36nu" path="res://behaviours/monster_type.tscn" id="8_poavy"]
|
||||||
[ext_resource type="PackedScene" uid="uid://djcwis8ycrq85" path="res://behaviours/sampler_priority.tscn" id="9_s5lod"]
|
[ext_resource type="PackedScene" uid="uid://djcwis8ycrq85" path="res://behaviours/sampler_priority.tscn" id="9_s5lod"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dk1ipq7dhkhf3" path="res://behaviours/move_straight.tscn" id="10_05kcd"]
|
[ext_resource type="PackedScene" uid="uid://dk1ipq7dhkhf3" path="res://behaviours/move_straight.tscn" id="10_05kcd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cm67ko1k6kn4u" path="res://behaviours/priority.tscn" id="11_0jlmk"]
|
[ext_resource type="PackedScene" uid="uid://cm67ko1k6kn4u" path="res://behaviours/priority.tscn" id="11_0jlmk"]
|
||||||
|
@ -227,6 +228,8 @@ blend_times = [&"drag_start", &"drag_loop", 0.5]
|
||||||
[node name="Edible" parent="." instance=ExtResource("6_3odsh")]
|
[node name="Edible" parent="." instance=ExtResource("6_3odsh")]
|
||||||
diet = &"Meat"
|
diet = &"Meat"
|
||||||
|
|
||||||
|
[node name="MonsterType" parent="." instance=ExtResource("8_poavy")]
|
||||||
|
|
||||||
[node name="MovementSampler" parent="." instance=ExtResource("9_s5lod")]
|
[node name="MovementSampler" parent="." instance=ExtResource("9_s5lod")]
|
||||||
|
|
||||||
[node name="MovementIdle" parent="." instance=ExtResource("10_05kcd")]
|
[node name="MovementIdle" parent="." instance=ExtResource("10_05kcd")]
|
||||||
|
@ -286,7 +289,7 @@ debug_color = Color(1, 1, 0, 0)
|
||||||
tracker = NodePath("..")
|
tracker = NodePath("..")
|
||||||
|
|
||||||
[node name="MovementTrap" parent="." instance=ExtResource("12_x2g3x")]
|
[node name="MovementTrap" parent="." instance=ExtResource("12_x2g3x")]
|
||||||
speed = 140.0
|
speed = 600.0
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[node name="TrapPriority" parent="MovementTrap" instance=ExtResource("11_0jlmk")]
|
[node name="TrapPriority" parent="MovementTrap" instance=ExtResource("11_0jlmk")]
|
||||||
|
|
48
entities/summoning_circle.gd
Normal file
48
entities/summoning_circle.gd
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
extends Node2D
|
||||||
|
class_name SacrificeCircle
|
||||||
|
|
||||||
|
@onready var spawner: Spawner = $"Spawner"
|
||||||
|
|
||||||
|
## The scene to spawn.
|
||||||
|
@export var scene_imp: PackedScene
|
||||||
|
|
||||||
|
|
||||||
|
var stones: Array[SacrificeStone]
|
||||||
|
var sacrifices: Array[Enums.MonsterType]
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
stones = []
|
||||||
|
sacrifices = []
|
||||||
|
stones.assign(find_children("*", "SacrificeStone", true, false))
|
||||||
|
|
||||||
|
for stone in stones:
|
||||||
|
sacrifices.append(stone.current_type)
|
||||||
|
|
||||||
|
func refresh_sacrifices() -> void:
|
||||||
|
for i in len(stones):
|
||||||
|
sacrifices[i] = stones[i].current_type
|
||||||
|
|
||||||
|
func try_sacrifice() -> void:
|
||||||
|
var first_monster = sacrifices[0]
|
||||||
|
var all_same = true
|
||||||
|
for m in sacrifices:
|
||||||
|
if m != first_monster:
|
||||||
|
all_same = false
|
||||||
|
break
|
||||||
|
if not all_same:
|
||||||
|
return
|
||||||
|
|
||||||
|
if first_monster == Enums.MonsterType.Sheep:
|
||||||
|
spawn(scene_imp)
|
||||||
|
|
||||||
|
func spawn(type: PackedScene) -> void:
|
||||||
|
spawner.scene = type
|
||||||
|
spawner.spawn()
|
||||||
|
|
||||||
|
for s in stones:
|
||||||
|
s.current_monster.queue_free()
|
||||||
|
|
||||||
|
func _on_sacrifice_changed(_entity: Node2D, _type: Enums.MonsterType):
|
||||||
|
refresh_sacrifices()
|
||||||
|
try_sacrifice()
|
BIN
entities/summoning_circle.png
(Stored with Git LFS)
Normal file
BIN
entities/summoning_circle.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
entities/summoning_circle.png.import
Normal file
34
entities/summoning_circle.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://n0wj20mduwy8"
|
||||||
|
path="res://.godot/imported/summoning_circle.png-a9e8e58bff05ee4e15de5d48253b8a5d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://entities/summoning_circle.png"
|
||||||
|
dest_files=["res://.godot/imported/summoning_circle.png-a9e8e58bff05ee4e15de5d48253b8a5d.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
|
39
entities/summoning_circle.tscn
Normal file
39
entities/summoning_circle.tscn
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
[gd_scene load_steps=6 format=3 uid="uid://uoopwyh1ea7t"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n0wj20mduwy8" path="res://entities/summoning_circle.png" id="1_c6jmb"]
|
||||||
|
[ext_resource type="Script" path="res://entities/summoning_circle.gd" id="1_x3bxd"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://4d3ksr3171x4" path="res://entities/imp.tscn" id="2_48rxv"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://4xivigiybb1d" path="res://entities/sacrifice_stone.tscn" id="2_dwkfn"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://tx1qi6ahlxjp" path="res://behaviours/spawner.tscn" id="3_p6s0q"]
|
||||||
|
|
||||||
|
[node name="SummoningCircle" type="Node2D"]
|
||||||
|
script = ExtResource("1_x3bxd")
|
||||||
|
scene_imp = ExtResource("2_48rxv")
|
||||||
|
|
||||||
|
[node name="Demoncircle" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(2, 4)
|
||||||
|
scale = Vector2(2, 2)
|
||||||
|
texture = ExtResource("1_c6jmb")
|
||||||
|
|
||||||
|
[node name="Spawner" parent="." instance=ExtResource("3_p6s0q")]
|
||||||
|
|
||||||
|
[node name="S1" parent="." instance=ExtResource("2_dwkfn")]
|
||||||
|
position = Vector2(-79, -45)
|
||||||
|
|
||||||
|
[node name="S2" parent="." instance=ExtResource("2_dwkfn")]
|
||||||
|
position = Vector2(0, -85)
|
||||||
|
|
||||||
|
[node name="S3" parent="." instance=ExtResource("2_dwkfn")]
|
||||||
|
position = Vector2(-77, 44)
|
||||||
|
|
||||||
|
[node name="S4" parent="." instance=ExtResource("2_dwkfn")]
|
||||||
|
position = Vector2(80, 44)
|
||||||
|
|
||||||
|
[node name="S5" parent="." instance=ExtResource("2_dwkfn")]
|
||||||
|
position = Vector2(77, -45)
|
||||||
|
|
||||||
|
[connection signal="sacrifice_changed" from="S1" to="." method="_on_sacrifice_changed"]
|
||||||
|
[connection signal="sacrifice_changed" from="S2" to="." method="_on_sacrifice_changed"]
|
||||||
|
[connection signal="sacrifice_changed" from="S3" to="." method="_on_sacrifice_changed"]
|
||||||
|
[connection signal="sacrifice_changed" from="S4" to="." method="_on_sacrifice_changed"]
|
||||||
|
[connection signal="sacrifice_changed" from="S5" to="." method="_on_sacrifice_changed"]
|
9
enums.gd
9
enums.gd
|
@ -8,3 +8,12 @@ enum ZIndex {
|
||||||
Props = 0,
|
Props = 0,
|
||||||
Terrain = -10,
|
Terrain = -10,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum MonsterType {
|
||||||
|
None = 0, # I hate this but in GDScript enums can't be nulls and there aren't any sum types like in rust so this is all we can do
|
||||||
|
Sheep,
|
||||||
|
Imp,
|
||||||
|
Chupacapra,
|
||||||
|
Watcher,
|
||||||
|
Chtulu,
|
||||||
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://cmemgijh6nfmk" path="res://entities/chupacabra.tscn" id="11_ixo4x"]
|
[ext_resource type="PackedScene" uid="uid://cmemgijh6nfmk" path="res://entities/chupacabra.tscn" id="11_ixo4x"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dnjtduk0hla3f" path="res://entities/watcher.tscn" id="14_8rumi"]
|
[ext_resource type="PackedScene" uid="uid://dnjtduk0hla3f" path="res://entities/watcher.tscn" id="14_8rumi"]
|
||||||
[ext_resource type="PackedScene" uid="uid://gl4umoff474y" path="res://entities/cthulhu.tscn" id="15_k41qf"]
|
[ext_resource type="PackedScene" uid="uid://gl4umoff474y" path="res://entities/cthulhu.tscn" id="15_k41qf"]
|
||||||
[ext_resource type="PackedScene" uid="uid://4xivigiybb1d" path="res://entities/sacrifice_stone.tscn" id="16_674vn"]
|
[ext_resource type="PackedScene" uid="uid://uoopwyh1ea7t" path="res://entities/summoning_circle.tscn" id="16_v1vce"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_058kb"]
|
||||||
texture = ExtResource("2_o7bg5")
|
texture = ExtResource("2_o7bg5")
|
||||||
|
@ -937,17 +937,15 @@ position = Vector2(-211, 241)
|
||||||
position = Vector2(-491, 137)
|
position = Vector2(-491, 137)
|
||||||
|
|
||||||
[node name="Sheep7" parent="." instance=ExtResource("9_qrqqu")]
|
[node name="Sheep7" parent="." instance=ExtResource("9_qrqqu")]
|
||||||
position = Vector2(87, 40)
|
position = Vector2(63, -115)
|
||||||
|
|
||||||
[node name="Chupacabra" parent="." instance=ExtResource("11_ixo4x")]
|
[node name="Chupacabra" parent="." instance=ExtResource("11_ixo4x")]
|
||||||
position = Vector2(6, -210)
|
position = Vector2(6, -210)
|
||||||
|
|
||||||
[node name="Watcher" parent="." instance=ExtResource("14_8rumi")]
|
[node name="Watcher" parent="." instance=ExtResource("14_8rumi")]
|
||||||
position = Vector2(189, 171)
|
position = Vector2(316, 224)
|
||||||
|
|
||||||
[node name="Cthulhu" parent="." instance=ExtResource("15_k41qf")]
|
[node name="Cthulhu" parent="." instance=ExtResource("15_k41qf")]
|
||||||
position = Vector2(226, -137)
|
position = Vector2(226, -137)
|
||||||
|
|
||||||
[node name="SacrificeStone" parent="." instance=ExtResource("16_674vn")]
|
[node name="SummoningCircle" parent="." instance=ExtResource("16_v1vce")]
|
||||||
|
|
||||||
[editable path="SacrificeStone"]
|
|
||||||
|
|
Loading…
Reference in a new issue