Skip to content

Commit fbb8782

Browse files
committed
Breaking change - Entites become SKEntities
1 parent 5c4804d commit fbb8782

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+139
-146
lines changed

scripts/ai/Modules/default_threat_response.gd

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var pull_out_of_thread = false
4848

4949
func _initialize() -> void:
5050
_npc.perception_transition.connect(_handle_perception_info.bind())
51-
_npc.hit_by.connect(func(who): _aggress(EntityManager.instance.get_entity(who)))
51+
_npc.hit_by.connect(func(who): _aggress(SKEntityManager.instance.get_entity(who)))
5252

5353

5454
func _handle_perception_info(what:StringName, transition:String, fsm:PerceptionFSM_Machine) -> void:
@@ -73,7 +73,7 @@ func _handle_perception_info(what:StringName, transition:String, fsm:PerceptionF
7373
if below_attack_threshold: # if attack threshold or frenzied
7474
if not _npc.in_combat:
7575
_npc.printe("start vigilance")
76-
var e = EntityManager.instance.get_entity(what)
76+
var e = SKEntityManager.instance.get_entity(what)
7777

7878
# attack immediately if frenzied
7979
if aggression == 3:
@@ -103,7 +103,7 @@ func _handle_perception_info(what:StringName, transition:String, fsm:PerceptionF
103103

104104

105105
## Will keep watch until the entity is out of range. TODO: Visibility?
106-
func _stay_vigilant(e:Entity) -> void:
106+
func _stay_vigilant(e:SKEntity) -> void:
107107
# may need to change the order of this, im not sure where to put it yet
108108
if _npc.in_combat: # don't react if already in combat
109109
_add_enemy(e)
@@ -150,7 +150,7 @@ func _stay_vigilant(e:Entity) -> void:
150150
return
151151

152152

153-
func _begin_attack(e:Entity) -> void:
153+
func _begin_attack(e:SKEntity) -> void:
154154
# figure out response to confrontation
155155
print("beginning attack")
156156
match aggression:
@@ -168,7 +168,7 @@ func _begin_attack(e:Entity) -> void:
168168
# This will begin combat, because NPCs have a recurring goal where all enemies must be dead
169169

170170

171-
func _add_enemy(e:Entity) -> void:
171+
func _add_enemy(e:SKEntity) -> void:
172172
if _npc.goap_memory.has("enemies"):
173173
if not _npc.goap_memory["enemies"].has(e.name):
174174
print("Adding enemy %s" % e.name)
@@ -179,7 +179,7 @@ func _add_enemy(e:Entity) -> void:
179179
_npc._goap_component.interrupt() # interrupt current task if entering combat
180180

181181

182-
func _warn(e:Entity) -> void:
182+
func _warn(e:SKEntity) -> void:
183183
# Issue warning to entity
184184
print("warning!")
185185
_npc.warning.emit(e.name)
@@ -196,15 +196,15 @@ func _enter_vigilant_stance() -> void:
196196
print("enter vigilant stance")
197197

198198

199-
func _flee(e:Entity) -> void:
199+
func _flee(e:SKEntity) -> void:
200200
# tell GOAP to flee from enemies
201201
print("flee")
202202
_npc.add_objective({"flee_from_enemies" : true}, true, 10)
203203
_npc.flee.emit(e.name)
204204

205205

206206
## Response to being hit.
207-
func _aggress(e:Entity) -> void:
207+
func _aggress(e:SKEntity) -> void:
208208
# "Coward", "Cautious", "Average", "Brave", "Foolhardy"
209209
# TODO: Friendly fire
210210
var threat = _determine_threat(e)
@@ -244,7 +244,7 @@ func _aggress(e:Entity) -> void:
244244
## 1: Stronger [br]
245245
## 2: Significantly stronger [br]
246246
## See [constant THREAT_LEVEL_WEAKER_INTERVAL], [constant THREAT_LEVEL_GREATER_INTERVAL], [constant THREAT_LEVEL_MUCH_GREATER_INTERVAL]
247-
func _determine_threat(e:Entity) -> int:
247+
func _determine_threat(e:SKEntity) -> int:
248248
var e_sc = e.get_component("SkillsComponent")
249249
# if no skills component associated with the entity, default is 0
250250
if not e_sc.some():

scripts/ai/PerceptionFSM/state_aware_visible.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extends FSMState
44

55

66
var _npc:NPCComponent
7-
var e:Entity
7+
var e:SKEntity
88

99

1010
func _get_state_name() -> String:
@@ -23,4 +23,4 @@ func update(delta:float) -> void:
2323

2424

2525
func enter(msg:Dictionary = {}) -> void:
26-
e = EntityManager.instance.get_entity((state_machine as PerceptionFSM_Machine).tracked)
26+
e = SKEntityManager.instance.get_entity((state_machine as PerceptionFSM_Machine).tracked)

scripts/ai/PerceptionFSM/state_unaware.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ func update(delta:float) -> void:
2828

2929
func enter(message:Dictionary) -> void:
3030
# if we are tracking an item, skip right to aware visible
31-
if EntityManager.instance.get_entity((state_machine as PerceptionFSM_Machine).tracked).get_component("ItemComponent"):
31+
if SKEntityManager.instance.get_entity((state_machine as PerceptionFSM_Machine).tracked).get_component("ItemComponent"):
3232
state_machine.transition("AwareVisible")

scripts/ai/goap_action.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var running:bool:
2424
var parent_goap:GOAPComponent:
2525
get:
2626
return goap_behavior.parent_goap
27-
var entity:Entity:
27+
var entity:SKEntity:
2828
get:
2929
return goap_behavior.entity
3030

scripts/ai/goap_behavior.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extends Resource
1010
## Whether this objective is actively being worked on
1111
var running:bool = false
1212
var parent_goap:GOAPComponent
13-
var entity:Entity
13+
var entity:SKEntity
1414

1515

1616
func is_achievable_given(state:Dictionary) -> bool:

scripts/ai/perception_ears.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class_name PerceptionEars
22
extends CollisionShape3D
33
## Add to something to make it be able to hear.
4-
## Isn't an [EntityComponent], so can be added to anything.
4+
## Isn't an [SKEntityComponent], so can be added to anything.
55
## Be sure to add a shape.
66

77

scripts/ai/perception_eyes.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func get_thing_under_sight(pt:NavPoint) -> PerceptionData:
8989

9090
## Looks for a specific entity, and returns with the data. Null if not found.
9191
func look_for_entity(refID:StringName) -> PerceptionData:
92-
var entity = EntityManager.instance.get_entity(refID)
92+
var entity = SKEntityManager.instance.get_entity(refID)
9393
if entity:
9494
var pt = NavPoint.new(entity.world, entity.position)
9595
var res = await get_thing_under_sight(pt)
@@ -133,8 +133,8 @@ func try_perception() -> void:
133133
func _find_ref_id(n:Node) -> String:
134134
var check:Node = n.get_parent()
135135
while check.get_parent():
136-
if check is Entity:
137-
return (check as Entity).name
136+
if check is SKEntity:
137+
return (check as SKEntity).name
138138
check = check.get_parent()
139139
return ""
140140

scripts/barter/barter.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ func accept_barter(selling_modifier:float, buying_modifier:float, currency: Stri
8787
#? Could optimize
8888
for item in current_transaction.selling:
8989
# Move from customer to vendor.
90-
EntityManager.instance\
90+
SKEntityManager.instance\
9191
.get_entity(item)\
9292
.get_component("ItemComponent")\
9393
.move_to_inventory(current_transaction.vendor.parent_entity.name)
9494
for item in current_transaction.buying:
9595
# Move from vendor to customer.
96-
EntityManager.instance\
96+
SKEntityManager.instance\
9797
.get_entity(item)\
9898
.get_component("ItemComponent")\
9999
.move_to_inventory(current_transaction.customer.parent_entity.name)
@@ -106,7 +106,7 @@ func accept_barter(selling_modifier:float, buying_modifier:float, currency: Stri
106106

107107
## Determine whether a shop will accept an item or not.
108108
func shop_will_accept_iten(shop:ShopInstance, item:StringName) -> bool:
109-
var ic:ItemComponent = EntityManager.instance.get_entity(item).get_component("ItemComponent")
109+
var ic:ItemComponent = SKEntityManager.instance.get_entity(item).get_component("ItemComponent")
110110

111111
if not shop.whitelist.is_empty():
112112
if not ic.data.tags.any(func(tag): return shop.whitelist.has(tag)): # if no tags in whitelist

scripts/barter/transaction.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func total_transaction(selling_modifier:float, buying_modifier:float) -> int:
2626
# Total selling amount and add
2727
total += selling.reduce(
2828
func(accum: int, item:String):
29-
return accum + roundi(( EntityManager.instance.get_entity(item)\
29+
return accum + roundi(( SKEntityManager.instance.get_entity(item)\
3030
.get_component("ItemComponent")\
3131
as ItemComponent)\
3232
.data\
@@ -36,7 +36,7 @@ func total_transaction(selling_modifier:float, buying_modifier:float) -> int:
3636
# Total selling amount and subtract
3737
total -= buying.reduce(
3838
func(accum: int, item:String):
39-
return accum + roundi(( EntityManager.instance.get_entity(item)\
39+
return accum + roundi(( SKEntityManager.instance.get_entity(item)\
4040
.get_component("ItemComponent")\
4141
as ItemComponent)\
4242
.data\

scripts/components/attributes_component.gd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class_name AttributesComponent
2-
extends EntityComponent
3-
## Holds the attributes of an Entity, such as the D&D abilities - Charisma, Dexterity, etc.
2+
extends SKEntityComponent
3+
## Holds the attributes of an SKEntity, such as the D&D abilities - Charisma, Dexterity, etc.
44

55

6-
## The attributes of this Entity.
6+
## The attributes of this SKEntity.
77
## It is in a dictionary so you can add, remove, and customize at will.
8-
## On startup, it will clone the list in the [member EntityManager.config] singleton.
9-
@onready var attributes:Dictionary = EntityManager.instance.config.attributes.duplicate():
8+
## On startup, it will clone the list in the [member SKEntityManager.config] singleton.
9+
@onready var attributes:Dictionary = SKEntityManager.instance.config.attributes.duplicate():
1010
get:
1111
return attributes
1212
set(val):

0 commit comments

Comments
 (0)