ft: prey collision
This commit is contained in:
38
evolve-die-repeat/shared/npc/npc2D.gd
Normal file
38
evolve-die-repeat/shared/npc/npc2D.gd
Normal file
@@ -0,0 +1,38 @@
|
||||
extends CharacterBody2D
|
||||
class_name NPC2D
|
||||
|
||||
@export var maxHealth: int = 0
|
||||
var health: int = maxHealth
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
spawn()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func spawn() -> void:
|
||||
pass
|
||||
|
||||
func take_damage(dmg: int) -> void:
|
||||
self.health -= dmg;
|
||||
if self.health < 0:
|
||||
self.die()
|
||||
|
||||
# I think the move per npc is to model concrete behaviours in functions.
|
||||
# How the npc acts can be determined elsewhere, these functions just implement the behvaiour
|
||||
func flee(direction: Vector3) -> void:
|
||||
push_error("Function flee() not implemented.")
|
||||
|
||||
# Im envisioning we feed on "sustenance (to be classed)" only; when something dies it should spawn some sustenance
|
||||
func feed(source ) -> void:
|
||||
push_error("Function feed() not implemented.")
|
||||
|
||||
func die() -> void:
|
||||
queue_free()
|
||||
# TODO: should associate this class with a loot table (or equivalent), and can then implement logic for dying in parent class here.
|
||||
|
||||
func move(destination: Vector3) -> void:
|
||||
push_error("Function move() not implemented.")
|
||||
|
||||
1
evolve-die-repeat/shared/npc/npc2D.gd.uid
Normal file
1
evolve-die-repeat/shared/npc/npc2D.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://biu3sctw15ga
|
||||
8
evolve-die-repeat/shared/npc/npc2D.tscn
Normal file
8
evolve-die-repeat/shared/npc/npc2D.tscn
Normal file
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://biup0eej85fq2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://biu3sctw15ga" path="res://shared/npc/npc2D.gd" id="1_ucjfp"]
|
||||
|
||||
[node name="NPC" type="CharacterBody2D"]
|
||||
script = ExtResource("1_ucjfp")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
15
evolve-die-repeat/shared/npc/predator2D.gd
Normal file
15
evolve-die-repeat/shared/npc/predator2D.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
extends NPC2D
|
||||
class_name AbstractPredator2D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func attack(target) -> void:
|
||||
push_error("Function attack() not implemented.")
|
||||
1
evolve-die-repeat/shared/npc/predator2D.gd.uid
Normal file
1
evolve-die-repeat/shared/npc/predator2D.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dgfimmq53whll
|
||||
7
evolve-die-repeat/shared/npc/predator2D.tscn
Normal file
7
evolve-die-repeat/shared/npc/predator2D.tscn
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://b7wqd5owafn6g"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://biup0eej85fq2" path="res://shared/npc/npc2D.tscn" id="1_4llks"]
|
||||
[ext_resource type="Script" uid="uid://dgfimmq53whll" path="res://shared/npc/predator2D.gd" id="2_rj1ok"]
|
||||
|
||||
[node name="AbstractPredator" instance=ExtResource("1_4llks")]
|
||||
script = ExtResource("2_rj1ok")
|
||||
12
evolve-die-repeat/shared/npc/prey2D.gd
Normal file
12
evolve-die-repeat/shared/npc/prey2D.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends NPC2D
|
||||
class_name AbstractPrey2D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
1
evolve-die-repeat/shared/npc/prey2D.gd.uid
Normal file
1
evolve-die-repeat/shared/npc/prey2D.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://76jxpubyd8wp
|
||||
7
evolve-die-repeat/shared/npc/prey2D.tscn
Normal file
7
evolve-die-repeat/shared/npc/prey2D.tscn
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bvsdg1v3ksixy"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://biup0eej85fq2" path="res://shared/npc/npc2D.tscn" id="1_2m1le"]
|
||||
[ext_resource type="Script" uid="uid://76jxpubyd8wp" path="res://shared/npc/prey2D.gd" id="2_dny00"]
|
||||
|
||||
[node name="AbstractPrey" instance=ExtResource("1_2m1le")]
|
||||
script = ExtResource("2_dny00")
|
||||
Reference in New Issue
Block a user