From fbb8782ba409d828de4ee85a26f48fa3cc63e1ed Mon Sep 17 00:00:00 2001 From: Slashscreen Date: Tue, 7 May 2024 13:11:13 -0700 Subject: [PATCH] Breaking change - Entites become SKEntities --- scripts/ai/Modules/default_threat_response.gd | 18 ++++++------ .../ai/PerceptionFSM/state_aware_visible.gd | 4 +-- scripts/ai/PerceptionFSM/state_unaware.gd | 2 +- scripts/ai/goap_action.gd | 2 +- scripts/ai/goap_behavior.gd | 2 +- scripts/ai/perception_ears.gd | 2 +- scripts/ai/perception_eyes.gd | 6 ++-- scripts/barter/barter.gd | 6 ++-- scripts/barter/transaction.gd | 4 +-- scripts/components/attributes_component.gd | 10 +++---- scripts/components/chest_component.gd | 6 ++-- scripts/components/covens_component.gd | 4 +-- scripts/components/damageable_component.gd | 2 +- scripts/components/effects_component.gd | 2 +- scripts/components/equipment_component.gd | 4 +-- scripts/components/goap_component.gd | 2 +- scripts/components/interactive_component.gd | 2 +- scripts/components/inventory_component.gd | 6 ++-- scripts/components/item_component.gd | 17 +++++------ scripts/components/marker_component.gd | 2 +- scripts/components/navigator_component.gd | 2 +- scripts/components/npc_component.gd | 11 ++++---- scripts/components/player_component.gd | 2 +- .../components/puppet_spawner_component.gd | 4 +-- scripts/components/script_component.gd | 4 +-- scripts/components/skills_component.gd | 12 ++++---- scripts/components/spell_target_component.gd | 2 +- scripts/components/teleport_component.gd | 2 +- .../components/view_direction_component.gd | 2 +- scripts/components/vitals_component.gd | 2 +- scripts/covens/coven.gd | 2 +- scripts/crime/crime_master.gd | 2 +- scripts/entities/entity.gd | 28 +++++++++---------- scripts/entities/entity_component.gd | 12 ++++---- scripts/entities/entity_manager.gd | 20 ++++++------- scripts/instance_data/chest_instance.gd | 2 +- scripts/instance_data/instance_data.gd | 2 +- scripts/instance_data/item_instance.gd | 4 +-- scripts/instance_data/marker_instance.gd | 2 +- scripts/instance_data/npc_instance.gd | 4 +-- scripts/misc/skconfig.gd | 2 +- scripts/points/spawn_point.gd | 6 ++-- scripts/puppets/item_puppet.gd | 6 ++-- scripts/puppets/npc_puppet.gd | 2 +- scripts/schedules/sandbox_schedule.gd | 2 +- scripts/schedules/schedule_event.gd | 2 +- scripts/sk_global.gd | 6 ++-- scripts/spell_casting/spell_hand.gd | 4 +-- scripts/system/dialogue_hooks.gd | 10 +++---- scripts/system/game_info.gd | 7 ----- scripts/system/save_system.gd | 6 ++-- scripts/world_objects/chest.gd | 2 +- scripts/world_objects/door.gd | 2 +- scripts/world_objects/world_item.gd | 2 +- scripts/world_objects/world_npc.gd | 2 +- 55 files changed, 139 insertions(+), 146 deletions(-) diff --git a/scripts/ai/Modules/default_threat_response.gd b/scripts/ai/Modules/default_threat_response.gd index b8eaaec..02aebe1 100644 --- a/scripts/ai/Modules/default_threat_response.gd +++ b/scripts/ai/Modules/default_threat_response.gd @@ -48,7 +48,7 @@ var pull_out_of_thread = false func _initialize() -> void: _npc.perception_transition.connect(_handle_perception_info.bind()) - _npc.hit_by.connect(func(who): _aggress(EntityManager.instance.get_entity(who))) + _npc.hit_by.connect(func(who): _aggress(SKEntityManager.instance.get_entity(who))) 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 if below_attack_threshold: # if attack threshold or frenzied if not _npc.in_combat: _npc.printe("start vigilance") - var e = EntityManager.instance.get_entity(what) + var e = SKEntityManager.instance.get_entity(what) # attack immediately if frenzied if aggression == 3: @@ -103,7 +103,7 @@ func _handle_perception_info(what:StringName, transition:String, fsm:PerceptionF ## Will keep watch until the entity is out of range. TODO: Visibility? -func _stay_vigilant(e:Entity) -> void: +func _stay_vigilant(e:SKEntity) -> void: # may need to change the order of this, im not sure where to put it yet if _npc.in_combat: # don't react if already in combat _add_enemy(e) @@ -150,7 +150,7 @@ func _stay_vigilant(e:Entity) -> void: return -func _begin_attack(e:Entity) -> void: +func _begin_attack(e:SKEntity) -> void: # figure out response to confrontation print("beginning attack") match aggression: @@ -168,7 +168,7 @@ func _begin_attack(e:Entity) -> void: # This will begin combat, because NPCs have a recurring goal where all enemies must be dead -func _add_enemy(e:Entity) -> void: +func _add_enemy(e:SKEntity) -> void: if _npc.goap_memory.has("enemies"): if not _npc.goap_memory["enemies"].has(e.name): print("Adding enemy %s" % e.name) @@ -179,7 +179,7 @@ func _add_enemy(e:Entity) -> void: _npc._goap_component.interrupt() # interrupt current task if entering combat -func _warn(e:Entity) -> void: +func _warn(e:SKEntity) -> void: # Issue warning to entity print("warning!") _npc.warning.emit(e.name) @@ -196,7 +196,7 @@ func _enter_vigilant_stance() -> void: print("enter vigilant stance") -func _flee(e:Entity) -> void: +func _flee(e:SKEntity) -> void: # tell GOAP to flee from enemies print("flee") _npc.add_objective({"flee_from_enemies" : true}, true, 10) @@ -204,7 +204,7 @@ func _flee(e:Entity) -> void: ## Response to being hit. -func _aggress(e:Entity) -> void: +func _aggress(e:SKEntity) -> void: # "Coward", "Cautious", "Average", "Brave", "Foolhardy" # TODO: Friendly fire var threat = _determine_threat(e) @@ -244,7 +244,7 @@ func _aggress(e:Entity) -> void: ## 1: Stronger [br] ## 2: Significantly stronger [br] ## See [constant THREAT_LEVEL_WEAKER_INTERVAL], [constant THREAT_LEVEL_GREATER_INTERVAL], [constant THREAT_LEVEL_MUCH_GREATER_INTERVAL] -func _determine_threat(e:Entity) -> int: +func _determine_threat(e:SKEntity) -> int: var e_sc = e.get_component("SkillsComponent") # if no skills component associated with the entity, default is 0 if not e_sc.some(): diff --git a/scripts/ai/PerceptionFSM/state_aware_visible.gd b/scripts/ai/PerceptionFSM/state_aware_visible.gd index 6a06a0e..ffb1f90 100644 --- a/scripts/ai/PerceptionFSM/state_aware_visible.gd +++ b/scripts/ai/PerceptionFSM/state_aware_visible.gd @@ -4,7 +4,7 @@ extends FSMState var _npc:NPCComponent -var e:Entity +var e:SKEntity func _get_state_name() -> String: @@ -23,4 +23,4 @@ func update(delta:float) -> void: func enter(msg:Dictionary = {}) -> void: - e = EntityManager.instance.get_entity((state_machine as PerceptionFSM_Machine).tracked) + e = SKEntityManager.instance.get_entity((state_machine as PerceptionFSM_Machine).tracked) diff --git a/scripts/ai/PerceptionFSM/state_unaware.gd b/scripts/ai/PerceptionFSM/state_unaware.gd index db034ad..52ba1bf 100644 --- a/scripts/ai/PerceptionFSM/state_unaware.gd +++ b/scripts/ai/PerceptionFSM/state_unaware.gd @@ -28,5 +28,5 @@ func update(delta:float) -> void: func enter(message:Dictionary) -> void: # if we are tracking an item, skip right to aware visible - if EntityManager.instance.get_entity((state_machine as PerceptionFSM_Machine).tracked).get_component("ItemComponent"): + if SKEntityManager.instance.get_entity((state_machine as PerceptionFSM_Machine).tracked).get_component("ItemComponent"): state_machine.transition("AwareVisible") diff --git a/scripts/ai/goap_action.gd b/scripts/ai/goap_action.gd index a08d5d9..c81c9ee 100644 --- a/scripts/ai/goap_action.gd +++ b/scripts/ai/goap_action.gd @@ -24,7 +24,7 @@ var running:bool: var parent_goap:GOAPComponent: get: return goap_behavior.parent_goap -var entity:Entity: +var entity:SKEntity: get: return goap_behavior.entity diff --git a/scripts/ai/goap_behavior.gd b/scripts/ai/goap_behavior.gd index 27f322d..130a73b 100644 --- a/scripts/ai/goap_behavior.gd +++ b/scripts/ai/goap_behavior.gd @@ -10,7 +10,7 @@ extends Resource ## Whether this objective is actively being worked on var running:bool = false var parent_goap:GOAPComponent -var entity:Entity +var entity:SKEntity func is_achievable_given(state:Dictionary) -> bool: diff --git a/scripts/ai/perception_ears.gd b/scripts/ai/perception_ears.gd index f2ef218..b2ff6f7 100644 --- a/scripts/ai/perception_ears.gd +++ b/scripts/ai/perception_ears.gd @@ -1,7 +1,7 @@ class_name PerceptionEars extends CollisionShape3D ## Add to something to make it be able to hear. -## Isn't an [EntityComponent], so can be added to anything. +## Isn't an [SKEntityComponent], so can be added to anything. ## Be sure to add a shape. diff --git a/scripts/ai/perception_eyes.gd b/scripts/ai/perception_eyes.gd index 3c2e842..1e2a3e5 100644 --- a/scripts/ai/perception_eyes.gd +++ b/scripts/ai/perception_eyes.gd @@ -89,7 +89,7 @@ func get_thing_under_sight(pt:NavPoint) -> PerceptionData: ## Looks for a specific entity, and returns with the data. Null if not found. func look_for_entity(refID:StringName) -> PerceptionData: - var entity = EntityManager.instance.get_entity(refID) + var entity = SKEntityManager.instance.get_entity(refID) if entity: var pt = NavPoint.new(entity.world, entity.position) var res = await get_thing_under_sight(pt) @@ -133,8 +133,8 @@ func try_perception() -> void: func _find_ref_id(n:Node) -> String: var check:Node = n.get_parent() while check.get_parent(): - if check is Entity: - return (check as Entity).name + if check is SKEntity: + return (check as SKEntity).name check = check.get_parent() return "" diff --git a/scripts/barter/barter.gd b/scripts/barter/barter.gd index 9f058ce..7c6c9e3 100644 --- a/scripts/barter/barter.gd +++ b/scripts/barter/barter.gd @@ -87,13 +87,13 @@ func accept_barter(selling_modifier:float, buying_modifier:float, currency: Stri #? Could optimize for item in current_transaction.selling: # Move from customer to vendor. - EntityManager.instance\ + SKEntityManager.instance\ .get_entity(item)\ .get_component("ItemComponent")\ .move_to_inventory(current_transaction.vendor.parent_entity.name) for item in current_transaction.buying: # Move from vendor to customer. - EntityManager.instance\ + SKEntityManager.instance\ .get_entity(item)\ .get_component("ItemComponent")\ .move_to_inventory(current_transaction.customer.parent_entity.name) @@ -106,7 +106,7 @@ func accept_barter(selling_modifier:float, buying_modifier:float, currency: Stri ## Determine whether a shop will accept an item or not. func shop_will_accept_iten(shop:ShopInstance, item:StringName) -> bool: - var ic:ItemComponent = EntityManager.instance.get_entity(item).get_component("ItemComponent") + var ic:ItemComponent = SKEntityManager.instance.get_entity(item).get_component("ItemComponent") if not shop.whitelist.is_empty(): if not ic.data.tags.any(func(tag): return shop.whitelist.has(tag)): # if no tags in whitelist diff --git a/scripts/barter/transaction.gd b/scripts/barter/transaction.gd index 01c00f6..b774d5d 100644 --- a/scripts/barter/transaction.gd +++ b/scripts/barter/transaction.gd @@ -26,7 +26,7 @@ func total_transaction(selling_modifier:float, buying_modifier:float) -> int: # Total selling amount and add total += selling.reduce( func(accum: int, item:String): - return accum + roundi(( EntityManager.instance.get_entity(item)\ + return accum + roundi(( SKEntityManager.instance.get_entity(item)\ .get_component("ItemComponent")\ as ItemComponent)\ .data\ @@ -36,7 +36,7 @@ func total_transaction(selling_modifier:float, buying_modifier:float) -> int: # Total selling amount and subtract total -= buying.reduce( func(accum: int, item:String): - return accum + roundi(( EntityManager.instance.get_entity(item)\ + return accum + roundi(( SKEntityManager.instance.get_entity(item)\ .get_component("ItemComponent")\ as ItemComponent)\ .data\ diff --git a/scripts/components/attributes_component.gd b/scripts/components/attributes_component.gd index 095569e..ca90373 100644 --- a/scripts/components/attributes_component.gd +++ b/scripts/components/attributes_component.gd @@ -1,12 +1,12 @@ class_name AttributesComponent -extends EntityComponent -## Holds the attributes of an Entity, such as the D&D abilities - Charisma, Dexterity, etc. +extends SKEntityComponent +## Holds the attributes of an SKEntity, such as the D&D abilities - Charisma, Dexterity, etc. -## The attributes of this Entity. +## The attributes of this SKEntity. ## It is in a dictionary so you can add, remove, and customize at will. -## On startup, it will clone the list in the [member EntityManager.config] singleton. -@onready var attributes:Dictionary = EntityManager.instance.config.attributes.duplicate(): +## On startup, it will clone the list in the [member SKEntityManager.config] singleton. +@onready var attributes:Dictionary = SKEntityManager.instance.config.attributes.duplicate(): get: return attributes set(val): diff --git a/scripts/components/chest_component.gd b/scripts/components/chest_component.gd index 1ea6c56..f5fca31 100644 --- a/scripts/components/chest_component.gd +++ b/scripts/components/chest_component.gd @@ -1,5 +1,5 @@ class_name ChestComponent -extends EntityComponent +extends SKEntityComponent ## Optionally refreshing inventories. @@ -35,7 +35,7 @@ func _check_should_restore() -> void: func clear() -> void: var ic:InventoryComponent = parent_entity.get_component("InventoryComponent") for i:StringName in ic.inventory: - EntityManager.instance.remove_entity(i) + SKEntityManager.instance.remove_entity(i) ic.inventory.clear() # Doing this instead of the remove item function since looping and removing stuff is bad and I don't need the signal ic.currencies.clear() @@ -51,7 +51,7 @@ func reroll() -> void: item.item_owner = owner_id item.ref_id = preload("res://addons/skelerealms/scripts/vendor/uuid.gd").v4() - var e:Entity = EntityManager.instance.add_entity(item) + var e:SKEntity = SKEntityManager.instance.add_entity(item) ic.add_to_inventory(e.name) ic.currencies = res.currencies diff --git a/scripts/components/covens_component.gd b/scripts/components/covens_component.gd index 77cb50c..2d8654d 100644 --- a/scripts/components/covens_component.gd +++ b/scripts/components/covens_component.gd @@ -1,6 +1,6 @@ class_name CovensComponent -extends EntityComponent -## Allows an Entity to be part of a [Coven]. +extends SKEntityComponent +## Allows an SKEntity to be part of a [Coven]. ## Covens in this context are analagous to Bethesda games' Factions- groups of NPCs that behave in a similar way. ## Coven membership is also reflected in groups that the entity is in. diff --git a/scripts/components/damageable_component.gd b/scripts/components/damageable_component.gd index 962acc5..0d7260d 100644 --- a/scripts/components/damageable_component.gd +++ b/scripts/components/damageable_component.gd @@ -1,5 +1,5 @@ class_name DamageableComponent -extends EntityComponent +extends SKEntityComponent ## Allows an entity to be damaged. diff --git a/scripts/components/effects_component.gd b/scripts/components/effects_component.gd index c49762a..28335a0 100644 --- a/scripts/components/effects_component.gd +++ b/scripts/components/effects_component.gd @@ -1,5 +1,5 @@ class_name EffectsComponent -extends EntityComponent +extends SKEntityComponent ## This component governs active effects on this entity. diff --git a/scripts/components/equipment_component.gd b/scripts/components/equipment_component.gd index f8275bc..576933a 100644 --- a/scripts/components/equipment_component.gd +++ b/scripts/components/equipment_component.gd @@ -1,5 +1,5 @@ class_name EquipmentComponent -extends EntityComponent +extends SKEntityComponent var equipment_slot:Dictionary @@ -18,7 +18,7 @@ func _ready() -> void: func equip(item:StringName, slot:EquipmentSlots.Slots, silent:bool = false) -> bool: # Get component - var e = EntityManager.instance.get_entity(item) + var e = SKEntityManager.instance.get_entity(item) if not e: return false # Get item component diff --git a/scripts/components/goap_component.gd b/scripts/components/goap_component.gd index 0d55392..748d081 100644 --- a/scripts/components/goap_component.gd +++ b/scripts/components/goap_component.gd @@ -1,5 +1,5 @@ class_name GOAPComponent -extends EntityComponent +extends SKEntityComponent ## Planner for [GOAPAction]s that creates action sequences to complete a set of [Objective]s. diff --git a/scripts/components/interactive_component.gd b/scripts/components/interactive_component.gd index f784d63..d993f3f 100644 --- a/scripts/components/interactive_component.gd +++ b/scripts/components/interactive_component.gd @@ -1,5 +1,5 @@ class_name InteractiveComponent -extends EntityComponent +extends SKEntityComponent ## Handles interactions on an entity ## Emitted when this entity is interacted with. diff --git a/scripts/components/inventory_component.gd b/scripts/components/inventory_component.gd index eb57583..f0c6fa1 100644 --- a/scripts/components/inventory_component.gd +++ b/scripts/components/inventory_component.gd @@ -1,5 +1,5 @@ class_name InventoryComponent -extends EntityComponent +extends SKEntityComponent ## Keeps track of an inventory. ## The RefIDs of the items in the inventory. @@ -28,7 +28,7 @@ func _ready() -> void: ## Add an item to the inventory. func add_to_inventory(id:String): - var e = EntityManager.instance.get_entity(id) + var e = SKEntityManager.instance.get_entity(id) if e: var ic = e.get_component("ItemComponent") if ic: @@ -74,7 +74,7 @@ func _clamp_money(currency:StringName): func count_item_by_data(data_id:String) -> int: var amount: int = 0 for i in inventory: - var ic:ItemComponent = EntityManager.instance.get_entity(i).get_component("ItemComponent") + var ic:ItemComponent = SKEntityManager.instance.get_entity(i).get_component("ItemComponent") if ic.data.id == data_id: amount += 1 return amount diff --git a/scripts/components/item_component.gd b/scripts/components/item_component.gd index e2082bb..006696a 100644 --- a/scripts/components/item_component.gd +++ b/scripts/components/item_component.gd @@ -1,5 +1,5 @@ class_name ItemComponent -extends EntityComponent +extends SKEntityComponent ## Keeps track of item data @@ -36,11 +36,12 @@ var item_owner:StringName = NONE: # TODO: Determine using worth and owner relationships $"../InteractiveComponent".interact_verb = "STEAL" var stolen:bool ## If this has been stolen or not. +var durability:float ## This item's durability, if your game has condition/durability mechanics like Fallout or Morrowind. ## Shorthand to get an item component for an entity by ID. static func get_item_component(id:StringName) -> ItemComponent: - var eop = EntityManager.instance.get_entity(id) + var eop = SKEntityManager.instance.get_entity(id) if not eop: return null var icop = eop.get_component("ItemComponent") @@ -89,15 +90,15 @@ func _despawn(): func _process(delta): if in_inventory: - parent_entity.position = EntityManager.instance.get_entity(contained_inventory).position - parent_entity.world = EntityManager.instance.get_entity(contained_inventory).world + parent_entity.position = SKEntityManager.instance.get_entity(contained_inventory).position + parent_entity.world = SKEntityManager.instance.get_entity(contained_inventory).world ## Move this to another inventory. Adds and removes the item from the inventories. func move_to_inventory(refID:StringName): # remove from inventory if we are in one if in_inventory: - EntityManager.instance\ + SKEntityManager.instance\ .get_entity(contained_inventory)\ .get_component("InventoryComponent")\ .remove_from_inventory(parent_entity.name) @@ -108,7 +109,7 @@ func move_to_inventory(refID:StringName): return # add to new inventory - EntityManager.instance\ + SKEntityManager.instance\ .get_entity(refID)\ .get_component("InventoryComponent")\ .add_to_inventory(parent_entity.name) @@ -121,12 +122,12 @@ func move_to_inventory(refID:StringName): ## Drop this on the ground. func drop(): - var e:Entity = EntityManager.instance.get_entity(contained_inventory) + var e:SKEntity = SKEntityManager.instance.get_entity(contained_inventory) var drop_dir:Quaternion = e.rotation print(drop_dir.get_euler().normalized() * DROP_DISTANCE) # This whole bit is genericizing dropping the item in front of the player. It's meant to be used with the player, it should work with anything with a puppet. if in_inventory: - EntityManager.instance.get_entity(contained_inventory)\ + SKEntityManager.instance.get_entity(contained_inventory)\ .get_component(&"InventoryComponent")\ .remove_from_inventory(parent_entity.name) diff --git a/scripts/components/marker_component.gd b/scripts/components/marker_component.gd index d938f40..fe2423e 100644 --- a/scripts/components/marker_component.gd +++ b/scripts/components/marker_component.gd @@ -1,5 +1,5 @@ class_name MarkerComponent -extends EntityComponent +extends SKEntityComponent ## Component tag for [WorldMarker]s. diff --git a/scripts/components/navigator_component.gd b/scripts/components/navigator_component.gd index db2c22b..bf2c0b7 100644 --- a/scripts/components/navigator_component.gd +++ b/scripts/components/navigator_component.gd @@ -1,5 +1,5 @@ class_name NavigatorComponent -extends EntityComponent +extends SKEntityComponent ## Handles finding paths through the granular navigation system. See [NavigationMaster]. diff --git a/scripts/components/npc_component.gd b/scripts/components/npc_component.gd index d806ca4..6b21884 100644 --- a/scripts/components/npc_component.gd +++ b/scripts/components/npc_component.gd @@ -1,5 +1,5 @@ class_name NPCComponent -extends EntityComponent +extends SKEntityComponent ## The brain for an NPC. Handles AI behavior, scheduling, combat, dialogue interactions. ## The component itself is a blank slate, being comprised largely of state trackers and utility functions, and will likely do nothing without an [AIModule] to determine its behavior. ## It also has aobut a million signals that AI modules, the GOAP system, animation controllers, dialogue systems, etc. can hook into. Think of them as an API. @@ -132,7 +132,7 @@ signal puppet_request_lower_weapons(puppet:NPCPuppet) ## Shorthand to get an npc component for an entity by ID. static func get_npc_component(id:StringName) -> NPCComponent: - var eop = EntityManager.instance.get_entity(id) + var eop = SKEntityManager.instance.get_entity(id) if not eop: return null var icop = eop.get_component("NPCComponent") @@ -170,7 +170,6 @@ func _ready(): n.link(self) n._initialize() ai_modules.append(n) - print(ai_modules) # FIXME: Parent entity can be instantiated called BEFORE this. @@ -392,9 +391,9 @@ func perception_forget(who:String) -> void: func get_remembered_items() -> Array[String]: return _perception_memory.keys()\ .filter(func(p:String): - var e = EntityManager.instance.get_entity(p) + var e = SKEntityManager.instance.get_entity(p) if e.some(): - return not (e.unwrap as Entity).get_component("ItemComponent") == null + return not (e.unwrap as SKEntity).get_component("ItemComponent") == null return false ) @@ -470,7 +469,7 @@ func get_relationship_with(ref_id:String) -> Option: ## Determines the opinion of some entity. See the tutorial in the class docs for a more in-depth look at NPC opinions. func determine_opinion_of(id:StringName) -> float: - var e:Entity = EntityManager.instance.get_entity(id) + var e:SKEntity = SKEntityManager.instance.get_entity(id) if not THREATENING_ENTITY_TYPES.any(func(x:String): return not e.get_component(x) == null): # if it doesn't have any components that are marked as threatening, return neutral. return 0 diff --git a/scripts/components/player_component.gd b/scripts/components/player_component.gd index 7dfe14f..c43aa9e 100644 --- a/scripts/components/player_component.gd +++ b/scripts/components/player_component.gd @@ -1,5 +1,5 @@ class_name PlayerComponent -extends EntityComponent +extends SKEntityComponent ## Player component. diff --git a/scripts/components/puppet_spawner_component.gd b/scripts/components/puppet_spawner_component.gd index 185686d..3981d3a 100644 --- a/scripts/components/puppet_spawner_component.gd +++ b/scripts/components/puppet_spawner_component.gd @@ -1,5 +1,5 @@ class_name PuppetSpawnerComponent -extends EntityComponent +extends SKEntityComponent ## Manages spawning and despawning of puppets. ## The puppet node. @@ -23,9 +23,9 @@ func _ready(): ## Spawn a new puppet. func spawn(data:PackedScene): var n = data.instantiate() + add_child(n) (n as Node3D).set_position(parent_entity.position) puppet = n - add_child(n) spawned_puppet.emit(puppet) printe("spawned at %s : %s" % [parent_entity.world, parent_entity.position]) diff --git a/scripts/components/script_component.gd b/scripts/components/script_component.gd index c8c3046..69478c9 100644 --- a/scripts/components/script_component.gd +++ b/scripts/components/script_component.gd @@ -1,12 +1,12 @@ class_name ScriptComponent -extends EntityComponent +extends SKEntityComponent ## This class can be bound to any entity and acts as a way to make ad-hoc components, to fill the role Papyrus plays in Creation Kit. ## To create a script for this, simply extend this class, and add it to the [RefData] or [InstanceData] of the appropriate object. ## If you want to add a custom script to a world object instead, you can.... write a normal script... ## Stores references to all components of this entity, save for this one. -## Dictionary layout is "ComponentType" : EntityComponent. +## Dictionary layout is "ComponentType" : SKEntityComponent. ## This is declared in _ready(), so be careful when overriding. var _components:Dictionary = {} diff --git a/scripts/components/skills_component.gd b/scripts/components/skills_component.gd index cc3c16b..b0d436d 100644 --- a/scripts/components/skills_component.gd +++ b/scripts/components/skills_component.gd @@ -1,12 +1,12 @@ class_name SkillsComponent -extends EntityComponent +extends SKEntityComponent ## Component holding the skills of this entity. ## Examples in Skyrim would be Destruction, Sneak, Alteration, Smithing. -## The skills of this Entity. +## The skills of this SKEntity. ## It is in a dictionary so you can add, remove, and customize at will. -@onready var skills:Dictionary = EntityManager.instance.config.skills.duplicate(): +@onready var skills:Dictionary = SKEntityManager.instance.config.skills.duplicate(): get: return skills set(val): @@ -53,10 +53,10 @@ func gather_debug_info() -> String: func add_skill_xp(skill:StringName, amount:int) -> void: if not skills.has(skill): - push_warning("Entity %s has no skill %s." % [parent_entity.name, skill]) + push_warning("SKEntity %s has no skill %s." % [parent_entity.name, skill]) return skill_xp[skill] += amount - var target:int = EntityManager.instance.config.compute_skill(skills[skill]) + var target:int = SKEntityManager.instance.config.compute_skill(skills[skill]) if target == -1: return if skill_xp[skill] >= target: @@ -66,7 +66,7 @@ func add_skill_xp(skill:StringName, amount:int) -> void: func add_character_xp(amount:int) -> void: character_xp += amount - var target:int = EntityManager.instance.config.compute_character(level) + var target:int = SKEntityManager.instance.config.compute_character(level) if target == -1: return if character_xp >= amount: diff --git a/scripts/components/spell_target_component.gd b/scripts/components/spell_target_component.gd index e20d637..b7607fb 100644 --- a/scripts/components/spell_target_component.gd +++ b/scripts/components/spell_target_component.gd @@ -1,5 +1,5 @@ class_name SpellTargetComponent -extends EntityComponent +extends SKEntityComponent ## Allows entities to be hit with spells, and keeps track of any applied spell effects. diff --git a/scripts/components/teleport_component.gd b/scripts/components/teleport_component.gd index c24c8c6..0644461 100644 --- a/scripts/components/teleport_component.gd +++ b/scripts/components/teleport_component.gd @@ -1,5 +1,5 @@ class_name TeleportComponent -extends EntityComponent +extends SKEntityComponent ## Allows an entity to warp. diff --git a/scripts/components/view_direction_component.gd b/scripts/components/view_direction_component.gd index 3affd2c..3bb1e51 100644 --- a/scripts/components/view_direction_component.gd +++ b/scripts/components/view_direction_component.gd @@ -1,5 +1,5 @@ class_name ViewDirectionComponent -extends EntityComponent +extends SKEntityComponent var view_rot:Vector3 = Vector3.FORWARD diff --git a/scripts/components/vitals_component.gd b/scripts/components/vitals_component.gd index 0f7fee7..83ff52f 100644 --- a/scripts/components/vitals_component.gd +++ b/scripts/components/vitals_component.gd @@ -1,5 +1,5 @@ class_name VitalsComponent -extends EntityComponent +extends SKEntityComponent ## Component keeping check of the main 3 attributes of an entity - health, stamina, and magica. # TODO: This is for player only, make a generalized one diff --git a/scripts/covens/coven.gd b/scripts/covens/coven.gd index e58596d..785a5a6 100644 --- a/scripts/covens/coven.gd +++ b/scripts/covens/coven.gd @@ -3,7 +3,7 @@ extends Resource ## Analagous to a Faction in creation kit games, where a Coven is a group of Entities that behave a certain way. ## Entities must have a [CovensComponent] to be a part of a coven. ## Entities are automatically added to a group with the coven's ID when they are a part of a coven, so to get all entities part of a coven, you can get all of group. -## Unlike Creation Kit, Entties are assigned to a coven on the Entity side- the Coven just holds information. +## Unlike Creation Kit, Entties are assigned to a coven on the SKEntity side- the Coven just holds information. ## To give them a default response to the player, create a "Player" coven, and give them a default reaction to that. diff --git a/scripts/crime/crime_master.gd b/scripts/crime/crime_master.gd index 67c02ed..9c91af7 100644 --- a/scripts/crime/crime_master.gd +++ b/scripts/crime/crime_master.gd @@ -56,7 +56,7 @@ func _process_crime_queue() -> void: if crime.victim == "": continue # add crime to covens - var cc = EntityManager.instance.get_entity(crime.victim).get_component("CovensComponent") + var cc = SKEntityManager.instance.get_entity(crime.victim).get_component("CovensComponent") if cc: for coven in (cc as CovensComponent).covens: ## Skip if doesn't track crime diff --git a/scripts/entities/entity.gd b/scripts/entities/entity.gd index 6afd4c5..413ef0c 100644 --- a/scripts/entities/entity.gd +++ b/scripts/entities/entity.gd @@ -1,6 +1,6 @@ -class_name Entity +class_name SKEntity extends Node -## An entity for the pseudo-ecs. Contains [EntityComponent]s. +## An entity for the pseudo-ecs. Contains [SKEntityComponent]s. ## These allow constructs such as NPCs and Items to persist even when not in the scene. @@ -11,7 +11,7 @@ extends Node ## Rotation of this Enitiy. @export var rotation:Quaternion = Quaternion.IDENTITY ## An internal timer of how long this entity has gone without being modified or referenced. -## One it's beyond a certain point, the [EntityManager] will mark it for cleanup after a save. +## One it's beyond a certain point, the [SKEntityManager] will mark it for cleanup after a save. var stale_timer:float ## This is used to prevent items from spawning, even if they are supposed to be in scene. ## For example, items in invcentories should not spawn despite technically being "in the scene". @@ -34,7 +34,7 @@ var in_scene: bool: signal left_scene ## Emitted when an entity leaves a scene. signal entered_scene -## This signal is emitted when all components have been added once [EntityManager.add_entity] is called. +## This signal is emitted when all components have been added once [SKEntityManager.add_entity] is called. ## Await this when you want to connect with other nodes. signal instantiated @@ -56,7 +56,7 @@ func _init(res:InstanceData = null) -> void: for n in new_nodes: # add all components to entity add_child(n) n.owner = self - (n as EntityComponent).parent_entity = self + (n as SKEntityComponent).parent_entity = self # call entity ready instantiated.emit() @@ -106,7 +106,7 @@ func _on_set_rotation(q:Quaternion) -> void: ## Example: [codeblock] ## (e.get_component("NPCComponent") as NPCComponent).kill() ## [/codeblock] -func get_component(type:String) -> EntityComponent: +func get_component(type:String) -> SKEntityComponent: var n = get_node_or_null(type) return n @@ -117,7 +117,7 @@ func has_component(type:String) -> bool: return not x == null -func add_component(c:EntityComponent) -> void: +func add_component(c:SKEntityComponent) -> void: add_child(c) @@ -129,8 +129,8 @@ func save() -> Dictionary: # TODO: Determine if instance is saved to disk. If no "generated" = generated } } - for c in get_children().filter(func(x:EntityComponent): return x.dirty): # filter to get dirty acomponents - data["components"][c.name] = ((c as EntityComponent).save()) + for c in get_children().filter(func(x:SKEntityComponent): return x.dirty): # filter to get dirty acomponents + data["components"][c.name] = ((c as SKEntityComponent).save()) return data @@ -141,13 +141,13 @@ func load_data(data:Dictionary) -> void: # loop through all saved components and call load for d in data["components"]: - (get_node(d) as EntityComponent).load_data(data[d]) + (get_node(d) as SKEntityComponent).load_data(data[d]) pass func reset_data() -> void: # TODO: Figure out how to reset entities that are generated at runtime. oh boy that's gonna be fun. - var i = EntityManager.instance.get_disk_data_for_entity(name) + var i = SKEntityManager.instance.get_disk_data_for_entity(name) if i: _init(i) @@ -170,8 +170,8 @@ func dialogue_command(command:String, args:Array) -> void: func gather_debug_info() -> Array[String]: var info: Array[String] = [] info.push_back(""" -[b]Entity[/b] - Entity RefID: %s +[b]SKEntity[/b] + SKEntity RefID: %s World: %s Position: x%s y%s z%s Rotation: x%s y%s z%s w%s @@ -190,7 +190,7 @@ func gather_debug_info() -> Array[String]: ]) for c in get_children(): - var i:String = (c as EntityComponent).gather_debug_info() + var i:String = (c as SKEntityComponent).gather_debug_info() if not i.is_empty(): info.push_back(i) diff --git a/scripts/entities/entity_component.gd b/scripts/entities/entity_component.gd index 48dc53a..9b04930 100644 --- a/scripts/entities/entity_component.gd +++ b/scripts/entities/entity_component.gd @@ -1,18 +1,18 @@ -class_name EntityComponent +class_name SKEntityComponent extends Node -## A component that is within an [Entity]. +## A component that is within an [SKEntity]. ## Extend these to add functionality to an entity. ## When inheriting, make sure to call super._ready() if overriding. ## Parent entity of this component. -@onready var parent_entity:Entity = get_parent() as Entity +@onready var parent_entity:SKEntity = get_parent() as SKEntity ## Whether this component should be saved. var dirty:bool = false # Called when the node enters the scene tree for the first time. func _ready(): - parent_entity = get_parent() as Entity + parent_entity = get_parent() as SKEntity if not parent_entity.left_scene.is_connected(_on_exit_scene.bind()): parent_entity.left_scene.connect(_on_exit_scene.bind()) if not parent_entity.entered_scene.is_connected(_on_enter_scene.bind()): @@ -23,12 +23,12 @@ func _entity_ready() -> void: pass -## Called when the parent entity enters a scene. See [signal Entity.entered_scene]. +## Called when the parent entity enters a scene. See [signal SKEntity.entered_scene]. func _on_enter_scene(): pass -## Called when the parent entity exits a scene. See [signal Entity.left_scene]. +## Called when the parent entity exits a scene. See [signal SKEntity.left_scene]. func _on_exit_scene(): pass diff --git a/scripts/entities/entity_manager.gd b/scripts/entities/entity_manager.gd index 28b6550..47cdea4 100644 --- a/scripts/entities/entity_manager.gd +++ b/scripts/entities/entity_manager.gd @@ -1,9 +1,9 @@ -class_name EntityManager +class_name SKEntityManager extends Node ## Manages entities in the game. ## The instance of the entity manager. -static var instance: EntityManager +static var instance: SKEntityManager var entities: Dictionary = {} var disk_assets: Dictionary = {} # TODO: Figure out an alternative that isn't so memory heavy @@ -31,22 +31,22 @@ func _ready(): ## 2. Scans its children entities to see if it missed any (this step may be removed in the future) [br] ## 3. Attempts to load the entity from disk. [br] ## Failing all of these, it will return [code]none[/code]. -func get_entity(id: StringName) -> Entity: +func get_entity(id: StringName) -> SKEntity: # stage 1: attempt find in cache if entities.has(id): - (entities[id] as Entity).reset_stale_timer() # FIXME: If another entity is carrying a reference to this entity, then we might break stuff by cleaning it up in this way? + (entities[id] as SKEntity).reset_stale_timer() # FIXME: If another entity is carrying a reference to this entity, then we might break stuff by cleaning it up in this way? return entities[id] # stage 2: Check in save file var potential_data = SaveSystem.entity_in_save(id) # chedk the save system if potential_data.some(): # if found: add_entity(ResourceLoader.load(disk_assets[id], "InstanceData")) # load default from disk entities[id].load_data(potential_data.unwrap()) # and then load using the data blob we got from the save file - (entities[id] as Entity).reset_stale_timer() + (entities[id] as SKEntity).reset_stale_timer() return entities[id] # stage 3: check on disk if disk_assets.has(id): add_entity(load(disk_assets[id])) - (entities[id] as Entity).reset_stale_timer() + (entities[id] as SKEntity).reset_stale_timer() return entities[id] # we added the entity in #add_entity # Other than that, we've failed. Attempt to find the entity in the child count as a failsave, then return none. @@ -82,15 +82,15 @@ func _cache_entities(path: String): ## add a new entity. -func add_entity(res: InstanceData) -> Entity: - var new_entity = Entity.new(res) # make a new entity +func add_entity(res: InstanceData) -> SKEntity: + var new_entity = SKEntity.new(res) # make a new entity # add new entity to self, and the dictionary entities[res.ref_id] = new_entity add_child(new_entity) return new_entity -func _add_entity_raw(e: Entity) -> Entity: +func _add_entity_raw(e: SKEntity) -> SKEntity: entities[e.name] = e add_child(e) return e @@ -101,7 +101,7 @@ func _cleanup_stale_entities(): # Get all children for c in get_children(): if ( - (c as Entity).stale_timer + (c as SKEntity).stale_timer >= ProjectSettings.get_setting("skelerealms/entity_cleanup_timer") ): # If stale timer is beyond threshold remove_entity(c.name) # remove diff --git a/scripts/instance_data/chest_instance.gd b/scripts/instance_data/chest_instance.gd index b497bc8..575a708 100644 --- a/scripts/instance_data/chest_instance.gd +++ b/scripts/instance_data/chest_instance.gd @@ -9,7 +9,7 @@ extends InstanceData var current_inventory:Array[String] -func get_archetype_components() -> Array[EntityComponent]: +func get_archetype_components() -> Array[SKEntityComponent]: return [ InventoryComponent.new(), ChestComponent.new(owner_id, loot_table, reset_time_minutes) diff --git a/scripts/instance_data/instance_data.gd b/scripts/instance_data/instance_data.gd index 5451f7a..1552935 100644 --- a/scripts/instance_data/instance_data.gd +++ b/scripts/instance_data/instance_data.gd @@ -12,7 +12,7 @@ extends Resource ## Get all of the entitiy components associated with this type of entity. ## Override this and create the components this needs. ## Example: An item instance should have, say, [ItemComponent], [InteractiveComponent], [PuppetComponent]. -func get_archetype_components() -> Array[EntityComponent]: +func get_archetype_components() -> Array[SKEntityComponent]: return [] diff --git a/scripts/instance_data/item_instance.gd b/scripts/instance_data/item_instance.gd index 868d05a..18d3e60 100644 --- a/scripts/instance_data/item_instance.gd +++ b/scripts/instance_data/item_instance.gd @@ -10,8 +10,8 @@ extends InstanceData @export var quest_item:bool = false -func get_archetype_components() -> Array[EntityComponent]: - var components:Array[EntityComponent] = [] +func get_archetype_components() -> Array[SKEntityComponent]: + var components:Array[SKEntityComponent] = [] # set up item component var item_component = ItemComponent.new() item_component.data = item_data diff --git a/scripts/instance_data/marker_instance.gd b/scripts/instance_data/marker_instance.gd index 8790330..e968b86 100644 --- a/scripts/instance_data/marker_instance.gd +++ b/scripts/instance_data/marker_instance.gd @@ -5,5 +5,5 @@ extends InstanceData @export var rotation:Quaternion -func get_archetype_components() -> Array[EntityComponent]: +func get_archetype_components() -> Array[SKEntityComponent]: return [MarkerComponent.new(rotation)] diff --git a/scripts/instance_data/npc_instance.gd b/scripts/instance_data/npc_instance.gd index 4326e20..0aceae9 100644 --- a/scripts/instance_data/npc_instance.gd +++ b/scripts/instance_data/npc_instance.gd @@ -8,8 +8,8 @@ extends InstanceData @export var unique_items: Array[ItemInstance] = [] -func get_archetype_components() -> Array[EntityComponent]: - var components:Array[EntityComponent] = [] +func get_archetype_components() -> Array[SKEntityComponent]: + var components:Array[SKEntityComponent] = [] # Add new components components.append(NPCComponent.new(npc_data)) components.append(InteractiveComponent.new()) diff --git a/scripts/misc/skconfig.gd b/scripts/misc/skconfig.gd index ef53977..9f69046 100644 --- a/scripts/misc/skconfig.gd +++ b/scripts/misc/skconfig.gd @@ -3,7 +3,7 @@ extends Resource ## This resource is needed to configure some Skelerealms behavior without changing code in the addon scripts itself. -## This should be given to an [class EntityManager] to be used. +## This should be given to an [class SKEntityManager] to be used. ## Default skills for [class SkillsComponent]s. diff --git a/scripts/points/spawn_point.gd b/scripts/points/spawn_point.gd index 110bd72..0f4c79a 100644 --- a/scripts/points/spawn_point.gd +++ b/scripts/points/spawn_point.gd @@ -42,16 +42,16 @@ func spawn() -> void: # add that shiz spawn_tracker[generate_id()] = true - var e = EntityManager.instance.add_entity(npci) + var e = SKEntityManager.instance.add_entity(npci) e.rotation = quaternion e.generated = true if despawn_when_exit_scene: - e.left_scene.connect(func() -> void: EntityManager.instance.remove_entity(e.name)) + e.left_scene.connect(func() -> void: SKEntityManager.instance.remove_entity(e.name)) # resolve loot table if t.loot_table: for i in t.loot_table.resolve_table_to_instances(): - var ie = EntityManager.instance.add_entity(i) # Add entity + var ie = SKEntityManager.instance.add_entity(i) # Add entity (e.get_component("ItemComponent") as ItemComponent).contained_inventory = e.name # set contained inventory diff --git a/scripts/puppets/item_puppet.gd b/scripts/puppets/item_puppet.gd index 64b85af..5604eba 100644 --- a/scripts/puppets/item_puppet.gd +++ b/scripts/puppets/item_puppet.gd @@ -20,13 +20,13 @@ signal change_rotation(Quaternion) func _ready(): - if not $"../../" is Entity: # TODO: Less brute force method + if not $"../../" is SKEntity: # TODO: Less brute force method inactive = true return puppeteer = $"../../".get_component("PuppetSpawnerComponent") - change_position.connect((get_parent().get_parent() as Entity)._on_set_position.bind()) - change_rotation.connect((get_parent().get_parent() as Entity)._on_set_rotation.bind()) + change_position.connect((get_parent().get_parent() as SKEntity)._on_set_position.bind()) + change_rotation.connect((get_parent().get_parent() as SKEntity)._on_set_rotation.bind()) func _process(delta): diff --git a/scripts/puppets/npc_puppet.gd b/scripts/puppets/npc_puppet.gd index e0647ef..62994a4 100644 --- a/scripts/puppets/npc_puppet.gd +++ b/scripts/puppets/npc_puppet.gd @@ -25,7 +25,7 @@ var movement_paused:bool = false func _ready() -> void: call_deferred("_actor_setup") add_to_group("perception_target") - change_position.connect((get_parent().get_parent() as Entity)._on_set_position.bind()) + change_position.connect((get_parent().get_parent() as SKEntity)._on_set_position.bind()) eyes = $EyesPerception puppeteer = $"../../".get_component("PuppetSpawnerComponent") npc_component = $"../../".get_component("NPCComponent") diff --git a/scripts/schedules/sandbox_schedule.gd b/scripts/schedules/sandbox_schedule.gd index 9496c6a..6898127 100644 --- a/scripts/schedules/sandbox_schedule.gd +++ b/scripts/schedules/sandbox_schedule.gd @@ -26,7 +26,7 @@ func get_event_location() -> NavPoint: return NavPoint.new(location_world, location_position) -func satisfied_at_location(e:Entity) -> bool: +func satisfied_at_location(e:SKEntity) -> bool: # if we dont need to be at location, return true by default if not be_at_location: return true diff --git a/scripts/schedules/schedule_event.gd b/scripts/schedules/schedule_event.gd index 137aca9..7e054ea 100644 --- a/scripts/schedules/schedule_event.gd +++ b/scripts/schedules/schedule_event.gd @@ -16,7 +16,7 @@ func get_event_location() -> NavPoint: return null -func satisfied_at_location(e:Entity) -> bool: +func satisfied_at_location(e:SKEntity) -> bool: return true func on_event_started() -> void: diff --git a/scripts/sk_global.gd b/scripts/sk_global.gd index b7ca084..c8459bd 100644 --- a/scripts/sk_global.gd +++ b/scripts/sk_global.gd @@ -10,17 +10,17 @@ var world_states:Dictionary ## Status effects registered in the game. var status_effects:Dictionary = {} -## Called when the [EntityManager] has finished loading. +## Called when the [SKEntityManager] has finished loading. signal entity_manager_loaded ## When a chest (or other inventory) is opened. signal inventory_opened(id:StringName) ## Attempts to find an entity in the tree above a node. Returns null if none found. Automatically takes account of reparented puppets. -func get_entity_in_tree(child:Node) -> Entity: +func get_entity_in_tree(child:Node) -> SKEntity: var checking = child while not checking.get_parent() == null: - if checking is Entity: + if checking is SKEntity: return checking # Check if puppet and getting puppeteer diff --git a/scripts/spell_casting/spell_hand.gd b/scripts/spell_casting/spell_hand.gd index 4194939..e2ff086 100644 --- a/scripts/spell_casting/spell_hand.gd +++ b/scripts/spell_casting/spell_hand.gd @@ -6,8 +6,8 @@ extends Node3D ## What spell is active right now. var _active_spell:Spell -## The Entity this hand is attached to. -var entity:Entity +## The SKEntity this hand is attached to. +var entity:SKEntity func cast_spell(): diff --git a/scripts/system/dialogue_hooks.gd b/scripts/system/dialogue_hooks.gd index 8527cbe..4e41d4a 100644 --- a/scripts/system/dialogue_hooks.gd +++ b/scripts/system/dialogue_hooks.gd @@ -40,13 +40,13 @@ signal participant_removed(who:StringName) func _ready() -> void: # bind the npc adding and removing methods to this signal as well. participant_added.connect(func(who:StringName): - Option.wrap(EntityManager.instance.get_entity(who))\ - .bind(func(e:Entity): return Option.wrap(e.get_component("NPCComponent")))\ + Option.wrap(SKEntityManager.instance.get_entity(who))\ + .bind(func(e:SKEntity): return Option.wrap(e.get_component("NPCComponent")))\ .bind(func(npc:NPCComponent): npc.add_to_conversation()) ) participant_removed.connect(func(who:StringName): - Option.wrap(EntityManager.instance.get_entity(who))\ - .bind(func(e:Entity): return Option.wrap(e.get_component("NPCComponent")))\ + Option.wrap(SKEntityManager.instance.get_entity(who))\ + .bind(func(e:SKEntity): return Option.wrap(e.get_component("NPCComponent")))\ .bind(func(npc:NPCComponent): npc.remove_from_conversation()) ) @@ -118,6 +118,6 @@ func update_dialogue_cache(dialogue_node:String = "", participants:Array[StringN ## Send a command to an entity without having to do monkey business trying to find it. func send_command_to_entity(ref_id:StringName, command:String, args:Array) -> void: - var e = EntityManager.instance.get_entity(ref_id) + var e = SKEntityManager.instance.get_entity(ref_id) if e: e.dialogue_command(command, args) diff --git a/scripts/system/game_info.gd b/scripts/system/game_info.gd index e9ef5c6..d88e4a9 100644 --- a/scripts/system/game_info.gd +++ b/scripts/system/game_info.gd @@ -147,13 +147,6 @@ func toggle_console_freeze() -> void: console_freeze() -func _input(event): - if Input.is_action_just_pressed("ui_cancel"): - toggle_pause() - #if Input.is_action_just_pressed("gdshell_toggle_ui"): - # toggle_console_freeze() - - func toggle_pause(): if not is_game_started: return diff --git a/scripts/system/save_system.gd b/scripts/system/save_system.gd index 9f95a75..5c2b812 100644 --- a/scripts/system/save_system.gd +++ b/scripts/system/save_system.gd @@ -63,12 +63,12 @@ func load_game(path:String): var save_data:Dictionary = _deserialize(data_blob) # parse data # Reset to default state if it doesn't have an entry in the save data - for e in EntityManager.instance.entities: + for e in SKEntityManager.instance.entities: if not save_data["entity_data"].has(e): - EntityManager.instance.entities[e].reset_data() + SKEntityManager.instance.entities[e].reset_data() # load entity data - loop through all data, get entity (spawning it if it isn't there), call load for data in save_data["entity_data"]: - EntityManager.instance.get_entity(data).load_data(save_data["entity_data"][data]) + SKEntityManager.instance.get_entity(data).load_data(save_data["entity_data"][data]) # load game info data for si in get_tree().get_nodes_in_group("savegame_gameinfo"): diff --git a/scripts/world_objects/chest.gd b/scripts/world_objects/chest.gd index c5aa2b0..9a5310a 100644 --- a/scripts/world_objects/chest.gd +++ b/scripts/world_objects/chest.gd @@ -10,7 +10,7 @@ signal opened_inventory func _ready(): - EntityManager.instance.get_entity(instance.ref_id) # bring the chest instance into the world + SKEntityManager.instance.get_entity(instance.ref_id) # bring the chest instance into the world on_interact.connect(func(_id): try_open_inventory()) diff --git a/scripts/world_objects/door.gd b/scripts/world_objects/door.gd index b15654c..d5ba337 100644 --- a/scripts/world_objects/door.gd +++ b/scripts/world_objects/door.gd @@ -21,7 +21,7 @@ func _ready(): # You could also override #interact, instead of binding to signal. func _handle_teleport_request(id:String): print("teleporting %s to world %s at position %s" % [id, dest_world, dest_pos]) - var teleportee = EntityManager.instance.get_entity(id) # get an entity + var teleportee = SKEntityManager.instance.get_entity(id) # get an entity if teleportee: # if there is a valid object var tc = teleportee.get_component("TeleportComponent") # Try to get a teleport component if tc: diff --git a/scripts/world_objects/world_item.gd b/scripts/world_objects/world_item.gd index 6757f0f..637fc62 100644 --- a/scripts/world_objects/world_item.gd +++ b/scripts/world_objects/world_item.gd @@ -8,5 +8,5 @@ extends InteractiveObject func _ready(): - var _e = EntityManager.instance.get_entity(instance.ref_id) # calling get_entity will cause the enity manager to start tracking this instance, if it isn't already. + var _e = SKEntityManager.instance.get_entity(instance.ref_id) # calling get_entity will cause the enity manager to start tracking this instance, if it isn't already. queue_free() diff --git a/scripts/world_objects/world_npc.gd b/scripts/world_objects/world_npc.gd index 1320e0b..41b486f 100644 --- a/scripts/world_objects/world_npc.gd +++ b/scripts/world_objects/world_npc.gd @@ -15,5 +15,5 @@ func _ready(): func _spawn(): - var e = EntityManager.instance.get_entity(instance.ref_id) # calling get_entity will cause the enity manager to start tracking this instance, if it isn't already. + var e = SKEntityManager.instance.get_entity(instance.ref_id) # calling get_entity will cause the enity manager to start tracking this instance, if it isn't already. queue_free()