mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-10 08:42:11 +01:00
Update to the latest ess. (Spawning rework).
This commit is contained in:
parent
2e212083e1
commit
0f88eb8e80
2
HEADS
2
HEADS
@ -1 +1 @@
|
||||
{"engine": "739f583151ee5b66b2a3d60c8c206ccdba8fa7f9", "world_generator": "09372b146936fda509f5c23a522e998d12f38e13", "entity_spell_system": "26c638881bcb8f1d86360e22fa39f3c95af32429", "ui_extensions": "38acc650db260a831dc26ca96fe9d9a087230bdc", "voxelman": "db77530ec1b70861fb2e3783d3ea6ba75a4ac793", "texture_packer": "7bff901e4946b903a73b266d6a02c317f079ab33", "fastnoise": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e", "entity-spell-system-addons": "d60e746b158d3ebf9d2ea306af1dd24bcae49be5", "mesh_data_resource": "4bda19b12be2c2a79a6121de6d22e48f3934e726", "ess_data": "3bd637fdd3304b64a18287a49a6b7387acf2f5de", "prop_tool": "df438053ebc900966f8f842fc65f0264f1271d49", "procedural_animations": "9c287b9e54dc8d306668a6118a6d2c78415eb8de", "fast_quadratic_mesh_simplifier": "63d55b154967321212a6426e9b327c95e007785d"}
|
||||
{"engine": "c4daac279b8ec6f4893056ba6717624f701ab970", "world_generator": "09372b146936fda509f5c23a522e998d12f38e13", "entity_spell_system": "d33a499847da73afcb4c4ab490c157410137fefb", "ui_extensions": "38acc650db260a831dc26ca96fe9d9a087230bdc", "voxelman": "db77530ec1b70861fb2e3783d3ea6ba75a4ac793", "texture_packer": "7bff901e4946b903a73b266d6a02c317f079ab33", "fastnoise": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e", "entity-spell-system-addons": "d60e746b158d3ebf9d2ea306af1dd24bcae49be5", "mesh_data_resource": "4bda19b12be2c2a79a6121de6d22e48f3934e726", "ess_data": "3bd637fdd3304b64a18287a49a6b7387acf2f5de", "prop_tool": "df438053ebc900966f8f842fc65f0264f1271d49", "procedural_animations": "9c287b9e54dc8d306668a6118a6d2c78415eb8de", "fast_quadratic_mesh_simplifier": "63d55b154967321212a6426e9b327c95e007785d"}
|
@ -34,46 +34,41 @@ var _spawn_parent : Node = null
|
||||
|
||||
var _next_entity_guid : int = 0
|
||||
|
||||
var _players : Array
|
||||
var _mobs : Array
|
||||
|
||||
func _ready():
|
||||
_spawn_parent = get_node(spawn_parent_path)
|
||||
|
||||
ProfileManager.load()
|
||||
EntityDataManager.load_all()
|
||||
EntityDataManager.connect("on_entity_spawn_requested", self, "on_entity_spawn_requested")
|
||||
|
||||
_spawn_parent = get_node(spawn_parent_path)
|
||||
|
||||
# get_tree().connect("network_peer_connected", self, "_player_connected")
|
||||
# get_tree().connect("network_peer_disconnected", self, "_player_disconnected")
|
||||
# get_tree().connect("connected_to_server", self, "_connected_ok")
|
||||
# get_tree().connect("connection_failed", self, "_connected_fail")
|
||||
# get_tree().connect("server_disconnected", self, "_server_disconnected")
|
||||
pass
|
||||
|
||||
func spawn_for(player : Entity, target: Entity) -> void:
|
||||
# print("spawnfor " + target.name)
|
||||
Logger.info("spawnfor " + target.name)
|
||||
rpc_id(player.get_network_master(), "creceive_spawn_for", to_json(target.to_dict()), target.name, target.translation)
|
||||
|
||||
func despawn_for(player : Entity, target: Entity) -> void:
|
||||
# print("despawnfor " + target.name)
|
||||
Logger.info("despawnfor " + target.name)
|
||||
rpc_id(player.get_network_master(), "creceive_despawn_for", target.get_path())
|
||||
|
||||
remote func creceive_spawn_for(data: String, global_name : String, position: Vector3) -> void:
|
||||
# print("recspawnfor " + global_name)
|
||||
var entity : Entity = networked_player_scene.instance()
|
||||
remote func creceive_spawn_for(data: String, global_name : String, position: Vector3) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
|
||||
var spawn_parent = _spawn_parent.current_scene
|
||||
|
||||
spawn_parent.add_child(entity)
|
||||
entity.owner = spawn_parent
|
||||
entity.name = str(global_name)
|
||||
entity.from_dict(parse_json(data))
|
||||
|
||||
entity.translation = position
|
||||
|
||||
createinfo.player_name = name
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_NETWORKED
|
||||
createinfo.serialized_data = parse_json(data)
|
||||
createinfo.transform.origin = position
|
||||
|
||||
EntityDataManager.request_entity_spawn(createinfo)
|
||||
|
||||
Logger.info("Player spawned ")
|
||||
|
||||
_players.append(entity)
|
||||
return createinfo.created_entity
|
||||
|
||||
remote func creceive_despawn_for(path : NodePath) -> void:
|
||||
# print("recdespawnfor " + path)
|
||||
@ -82,236 +77,188 @@ remote func creceive_despawn_for(path : NodePath) -> void:
|
||||
if ent:
|
||||
ent.queue_free()
|
||||
|
||||
func spawn_networked_player_from_data(data : String, position : Vector3, network_owner : int) -> Entity:
|
||||
var entity : Entity = networked_player_scene.instance()
|
||||
puppet func spawn_owned_player(data : String, position : Vector3) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
|
||||
_next_entity_guid += 1
|
||||
createinfo.guid = multiplayer.get_network_unique_id()
|
||||
createinfo.player_name = name
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_PLAYER
|
||||
createinfo.serialized_data = parse_json(data)
|
||||
createinfo.transform.origin = position
|
||||
|
||||
var spawn_parent = _spawn_parent.current_scene
|
||||
|
||||
spawn_parent.add_child(entity)
|
||||
entity.owner = spawn_parent
|
||||
entity.name = str(network_owner)
|
||||
entity.from_dict(parse_json(data))
|
||||
EntityDataManager.request_entity_spawn(createinfo)
|
||||
|
||||
entity.set_network_master(network_owner)
|
||||
entity.translation = position
|
||||
|
||||
Logger.info("Player spawned ")
|
||||
|
||||
_players.append(entity)
|
||||
|
||||
rpc_id(network_owner, "spawn_owned_player", data, position)
|
||||
|
||||
return entity
|
||||
|
||||
puppet func spawn_owned_player(data : String, position : Vector3) -> void:
|
||||
var entity : Entity = player_scene.instance()
|
||||
|
||||
var spawn_parent = _spawn_parent.current_scene
|
||||
|
||||
spawn_parent.add_child(entity)
|
||||
entity.owner = spawn_parent
|
||||
|
||||
entity.from_dict(parse_json(data))
|
||||
entity.name = str(multiplayer.get_network_unique_id())
|
||||
entity.translation = position
|
||||
entity.set_network_master(multiplayer.get_network_unique_id())
|
||||
|
||||
Logger.info("Player spawned ")
|
||||
|
||||
return createinfo.created_entity
|
||||
|
||||
func load_player(file_name : String, position : Vector3, network_owner : int) -> Entity:
|
||||
# var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
#
|
||||
# var cls : EntityData = EntityDataManager.get_player_character_data(class_id)
|
||||
#
|
||||
# var class_profile : ClassProfile = Profiles.get_class_profile(class_id)
|
||||
#
|
||||
# createinfo.entity_data = cls
|
||||
# createinfo.player_name = name
|
||||
# createinfo.level = class_profile.level
|
||||
# createinfo.xp = class_profile.xp
|
||||
# createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
|
||||
var entity : Entity = player_scene.instance()
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
|
||||
createinfo.guid = _next_entity_guid
|
||||
_next_entity_guid += 1
|
||||
|
||||
var spawn_parent = _spawn_parent.current_scene
|
||||
|
||||
spawn_parent.add_child(entity)
|
||||
entity.owner = spawn_parent
|
||||
|
||||
entity.from_dict(load_file(file_name))
|
||||
|
||||
entity.get_node(entity.get_body_path()).translation = position
|
||||
# entity.initialize(createinfo)
|
||||
entity.set_network_master(network_owner)
|
||||
|
||||
createinfo.player_name = name
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_PLAYER
|
||||
createinfo.serialized_data = load_file(file_name)
|
||||
createinfo.transform.origin = position
|
||||
Logger.info("Player spawned ")
|
||||
EntityDataManager.request_entity_spawn(createinfo)
|
||||
|
||||
_players.append(entity)
|
||||
|
||||
return entity
|
||||
|
||||
func spawn_display_player(name : String) -> Entity:
|
||||
var entity : Entity = player_display_scene.instance() as Entity
|
||||
|
||||
entity.name = name
|
||||
|
||||
Logger.info("Player Display spawned")
|
||||
|
||||
return entity
|
||||
return createinfo.created_entity
|
||||
|
||||
func spawn_player_for_menu(class_id : int, name : String, parent : Node) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
var cls : EntityData = EntityDataManager.get_player_character_data(class_id)
|
||||
var class_profile : ClassProfile = ProfileManager.get_class_profile(class_id)
|
||||
|
||||
createinfo.entity_data = cls
|
||||
createinfo.player_name = name
|
||||
createinfo.level = 1
|
||||
createinfo.xp = class_profile.xp
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
|
||||
var entity : Entity = player_display_scene.instance() as Entity
|
||||
entity.initialize(createinfo)
|
||||
|
||||
var level : int = class_profile.level
|
||||
|
||||
|
||||
if default_level_override > 0:
|
||||
level = default_level_override
|
||||
|
||||
entity.slevelup(level - 1)
|
||||
createinfo.class_id = class_id
|
||||
createinfo.entity_data = cls
|
||||
createinfo.player_name = name
|
||||
createinfo.level = level
|
||||
createinfo.xp = class_profile.xp
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_DISPLAY
|
||||
createinfo.networked = false
|
||||
createinfo.parent_path = parent.get_path()
|
||||
|
||||
parent.add_child(entity)
|
||||
entity.owner = parent
|
||||
|
||||
return entity
|
||||
EntityDataManager.request_entity_spawn(createinfo)
|
||||
|
||||
Logger.info("Player spawned " + str(createinfo))
|
||||
|
||||
return createinfo.created_entity
|
||||
|
||||
func spawn_display_player(file_name : String, node_path : NodePath) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
|
||||
createinfo.guid = _next_entity_guid
|
||||
_next_entity_guid += 1
|
||||
createinfo.player_name = name
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_DISPLAY
|
||||
createinfo.serialized_data = load_file(file_name)
|
||||
createinfo.parent_path = node_path
|
||||
|
||||
Logger.info("Player spawned ")
|
||||
|
||||
EntityDataManager.request_entity_spawn(createinfo)
|
||||
|
||||
return createinfo.created_entity
|
||||
|
||||
func spawn_networked_player(class_id : int, position : Vector3, name : String, node_name : String, sid : int) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
|
||||
var cls : EntityData = Entities.get_entity_data(class_id)
|
||||
|
||||
var cls : EntityData = Entities.get_player_character_data(class_id)
|
||||
var class_profile : ClassProfile = ProfileManager.get_class_profile(class_id)
|
||||
|
||||
createinfo.entity_data = cls
|
||||
createinfo.player_name = name
|
||||
createinfo.level = 1
|
||||
createinfo.xp = class_profile.xp
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
|
||||
var entity : Entity = spawn(createinfo, true, position, node_name)
|
||||
|
||||
var level : int = class_profile.level
|
||||
|
||||
if default_level_override > 0:
|
||||
level = default_level_override
|
||||
|
||||
entity.slevelup(level - 1)
|
||||
|
||||
if get_tree().is_network_server():
|
||||
entity.set_network_master(sid)
|
||||
createinfo.class_id = class_id
|
||||
createinfo.entity_data = cls
|
||||
createinfo.player_name = name
|
||||
createinfo.level = level
|
||||
createinfo.xp = class_profile.xp
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_NETWORKED
|
||||
createinfo.network_owner = sid
|
||||
createinfo.transform.origin = position
|
||||
createinfo.networked = false
|
||||
createinfo.transform.origin = position
|
||||
|
||||
EntityDataManager.request_entity_spawn(createinfo)
|
||||
|
||||
Logger.info("Player spawned " + str(createinfo))
|
||||
|
||||
_players.append(entity)
|
||||
|
||||
return entity
|
||||
return createinfo.created_entity
|
||||
|
||||
func spawn_player(class_id : int, position : Vector3, name : String, node_name : String, network_owner : int) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
|
||||
var cls : EntityData = Entities.get_player_character_data(class_id)
|
||||
|
||||
var class_profile : ClassProfile = ProfileManager.get_class_profile(class_id)
|
||||
|
||||
createinfo.entity_data = cls
|
||||
createinfo.player_name = name
|
||||
createinfo.level = 1
|
||||
createinfo.xp = class_profile.xp
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
|
||||
var entity : Entity = spawn(createinfo, false, position, node_name)
|
||||
|
||||
var level : int = class_profile.level
|
||||
|
||||
if default_level_override > 0:
|
||||
level = default_level_override
|
||||
|
||||
entity.slevelup(level - 1)
|
||||
createinfo.class_id = class_id
|
||||
createinfo.entity_data = cls
|
||||
createinfo.player_name = name
|
||||
createinfo.level = level
|
||||
createinfo.xp = class_profile.xp
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_PLAYER
|
||||
createinfo.network_owner = network_owner
|
||||
createinfo.transform.origin = position
|
||||
createinfo.networked = false
|
||||
|
||||
EntityDataManager.request_entity_spawn(createinfo)
|
||||
|
||||
entity.set_network_master(network_owner)
|
||||
|
||||
Logger.info("Player spawned " + str(createinfo))
|
||||
|
||||
_players.append(entity)
|
||||
|
||||
return entity
|
||||
return createinfo.created_entity
|
||||
|
||||
|
||||
func spawn_mob(class_id : int, level : int, position : Vector3) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
|
||||
var cls : EntityData = EntityDataManager.get_entity_data(class_id)
|
||||
|
||||
if cls == null:
|
||||
print("clsnull")
|
||||
|
||||
createinfo.class_id = class_id
|
||||
createinfo.entity_data = cls
|
||||
createinfo.player_name = "Mob"
|
||||
createinfo.level = 1
|
||||
|
||||
createinfo.level = level
|
||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_AI
|
||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_AI
|
||||
createinfo.transform.origin = position
|
||||
|
||||
var entity : Entity = spawn(createinfo, false, position)
|
||||
|
||||
if default_level_override > 0:
|
||||
level = default_level_override
|
||||
|
||||
entity.slevelup(level - 1)
|
||||
EntityDataManager.request_entity_spawn(createinfo)
|
||||
|
||||
Logger.info("Mob spawned " + str(createinfo))
|
||||
|
||||
_mobs.append(entity)
|
||||
return createinfo.created_entity
|
||||
|
||||
|
||||
return entity
|
||||
|
||||
func spawn(createinfo : EntityCreateInfo, networked : bool, position : Vector3, node_name : String = "") -> Entity:
|
||||
func on_entity_spawn_requested(createinfo : EntityCreateInfo):
|
||||
var entity_node : Entity = null
|
||||
|
||||
if not networked:
|
||||
if createinfo.entity_controller == EntityEnums.ENITIY_CONTROLLER_PLAYER:
|
||||
entity_node = player_scene.instance()
|
||||
else:
|
||||
entity_node = mob_scene.instance()
|
||||
if createinfo.entity_player_type == EntityEnums.ENTITY_PLAYER_TYPE_DISPLAY:
|
||||
entity_node = player_display_scene.instance()
|
||||
else:
|
||||
entity_node = networked_player_scene.instance()
|
||||
if not createinfo.networked:
|
||||
if createinfo.entity_controller == EntityEnums.ENITIY_CONTROLLER_PLAYER:
|
||||
entity_node = player_scene.instance()
|
||||
else:
|
||||
entity_node = mob_scene.instance()
|
||||
else:
|
||||
entity_node = networked_player_scene.instance()
|
||||
|
||||
if entity_node == null:
|
||||
print("EntityManager: entity node is null")
|
||||
return null
|
||||
|
||||
if node_name == "":
|
||||
entity_node.name += "_" + str(_next_entity_guid)
|
||||
|
||||
entity_node.get_body().translation = createinfo.transform.origin
|
||||
|
||||
if (createinfo.parent_path == ""):
|
||||
if _spawn_parent.current_scene != null:
|
||||
var spawn_parent = _spawn_parent.current_scene
|
||||
|
||||
spawn_parent.add_child(entity_node)
|
||||
else:
|
||||
entity_node.name = node_name
|
||||
|
||||
_next_entity_guid += 1
|
||||
get_node(createinfo.parent_path).add_child(entity_node)
|
||||
|
||||
var spawn_parent = _spawn_parent.current_scene
|
||||
|
||||
spawn_parent.add_child(entity_node)
|
||||
entity_node.owner = spawn_parent
|
||||
|
||||
entity_node.get_body().translation = position
|
||||
|
||||
entity_node.initialize(createinfo)
|
||||
entity_node.setup(createinfo)
|
||||
|
||||
createinfo.created_entity = entity_node
|
||||
|
||||
return entity_node
|
||||
|
||||
|
||||
func _player_connected(id):
|
||||
pass # Will go unused; not useful here.
|
||||
|
||||
|
3
game/data/species/1_test.tres
Normal file
3
game/data/species/1_test.tres
Normal file
@ -0,0 +1,3 @@
|
||||
[gd_resource type="EntitySpeciesData" format=2]
|
||||
|
||||
[resource]
|
@ -24,30 +24,3 @@ class_name DisplayPlayerGD
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
func _setup():
|
||||
setup_actionbars()
|
||||
|
||||
|
||||
func _son_level_up(level: int) -> void:
|
||||
if sentity_data == null:
|
||||
return
|
||||
|
||||
var ecd : EntityClassData = sentity_data.entity_class_data
|
||||
|
||||
if ecd == null:
|
||||
return
|
||||
|
||||
sfree_spell_points += ecd.spell_points_per_level * level
|
||||
sfree_talent_points += level
|
||||
|
||||
for i in range(Stat.MAIN_STAT_ID_COUNT):
|
||||
var st : int = sentity_data.entity_class_data.get_stat_data().get_level_stat_data().get_stat_diff(i, slevel - level, slevel)
|
||||
|
||||
var statid : int = i + Stat.MAIN_STAT_ID_START
|
||||
|
||||
var stat : Stat = get_stat_int(statid)
|
||||
|
||||
var sm : StatModifier = stat.get_modifier(0)
|
||||
sm.base_mod += st
|
||||
|
||||
|
||||
|
@ -29,6 +29,7 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="character" parent="DisplayPlayer/Rotation_Helper/Model" instance=ExtResource( 2 )]
|
||||
refresh_in_editor = false
|
||||
use_threads = false
|
||||
mesh_instance_path = NodePath("../../../../DisplayPlayer/Rotation_Helper/Model/character/armature/Armature/Skeleton/MeshInstance")
|
||||
skeleton_path = NodePath("../../../../DisplayPlayer/Rotation_Helper/Model/character/armature/Armature/Skeleton")
|
||||
|
@ -34,8 +34,6 @@ const GRAVITY : float = -24.8
|
||||
const JUMP_SPEED : float = 3.8
|
||||
const MAX_SLOPE_ANGLE : float = 40.0
|
||||
|
||||
#var process_gravity : bool = true
|
||||
|
||||
var _on : bool = true
|
||||
|
||||
var y_rot : float = 0.0
|
||||
@ -66,7 +64,6 @@ func _ready() -> void:
|
||||
set_process(true)
|
||||
set_physics_process(true)
|
||||
|
||||
|
||||
func _process(delta : float) -> void:
|
||||
if dead:
|
||||
death_timer += delta
|
||||
@ -93,19 +90,6 @@ func _process(delta : float) -> void:
|
||||
else:
|
||||
if not get_body().visible:
|
||||
get_body().show()
|
||||
|
||||
#TODO check later if this gives a performance boost
|
||||
# var cam_facing : Vector3 = -camera.global_transform.basis.z
|
||||
# var d : float = cam_facing.dot(dstv)
|
||||
#
|
||||
# if d > 0:
|
||||
# if visible:
|
||||
# hide()
|
||||
# return
|
||||
# else:
|
||||
# if not visible:
|
||||
# show()
|
||||
|
||||
|
||||
func _physics_process(delta : float) -> void:
|
||||
if not _on:
|
||||
@ -285,8 +269,8 @@ func set_max_visible_distance(var value : float) -> void:
|
||||
|
||||
max_visible_distance = value
|
||||
|
||||
func _setup():
|
||||
sentity_name = sentity_data.text_name
|
||||
#func _setup():
|
||||
# sentity_name = sentity_data.text_name
|
||||
|
||||
func _son_xp_gained(value : int) -> void:
|
||||
if not EntityDataManager.get_xp_data().can_level_up(gets_level()):
|
||||
|
@ -36,3 +36,4 @@ transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 0, 0
|
||||
[node name="Model" type="Spatial" parent="Body/Rotation_Helper"]
|
||||
|
||||
[node name="character" parent="Body/Rotation_Helper/Model" instance=ExtResource( 1 )]
|
||||
refresh_in_editor = false
|
||||
|
@ -24,9 +24,6 @@ class_name NetworkedPlayerGD
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
#export (float) var MOUSE_SENSITIVITY : float = 0.05
|
||||
#export (String) var map_path : String
|
||||
|
||||
const ray_length = 1000
|
||||
const ACCEL : float = 100.0
|
||||
const DEACCEL : float = 100.0
|
||||
@ -35,16 +32,10 @@ const JUMP_SPEED : float = 3.8
|
||||
const MAX_SLOPE_ANGLE : float = 40.0
|
||||
const MOUSE_TARGET_MAX_OFFSET : int = 10
|
||||
|
||||
#var _on : bool = true
|
||||
|
||||
var y_rot : float = 0.0
|
||||
|
||||
#var vel : Vector3 = Vector3()
|
||||
#var dir : Vector3 = Vector3()
|
||||
|
||||
var animation_tree : AnimationTree
|
||||
var anim_node_state_machine : AnimationNodeStateMachinePlayback = null
|
||||
#var animation_run : bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
animation_tree = get_character_skeleton().get_animation_tree()
|
||||
@ -53,45 +44,6 @@ func _ready() -> void:
|
||||
anim_node_state_machine = animation_tree["parameters/playback"]
|
||||
|
||||
|
||||
#func _physics_process(delta : float) -> void:
|
||||
# if not _on:
|
||||
# return
|
||||
#
|
||||
#process_movement(delta)
|
||||
|
||||
#func process_movement(delta : float) -> void:
|
||||
# if input_dir.x > 0.1 or input_dir.y > 0.1 or input_dir.x < -0.1 or input_dir.y < -0.1:
|
||||
# var forward : Vector3 = Vector3(0, 0, 1).rotated(Vector3(0, 1, 0), deg2rad(y_rot))
|
||||
# var right : Vector3 = forward.cross(Vector3(0, 1, 0)) * -input_dir.x
|
||||
# forward *= input_dir.y #only potentially make it zero after getting the right vector
|
||||
#
|
||||
# dir = forward
|
||||
# dir += right
|
||||
#
|
||||
# if dir.length_squared() > 0.1:
|
||||
# dir = dir.normalized()
|
||||
# else:
|
||||
# dir = Vector3()
|
||||
#
|
||||
# vel.y += delta * GRAVITY
|
||||
#
|
||||
# var hvel : Vector3 = vel
|
||||
# hvel.y = 0
|
||||
#
|
||||
# var target : Vector3 = dir
|
||||
# target *= get_speed().ccurrent
|
||||
#
|
||||
# var accel
|
||||
# if dir.dot(hvel) > 0:
|
||||
# accel = ACCEL
|
||||
# else:
|
||||
# accel = DEACCEL
|
||||
#
|
||||
# hvel = hvel.linear_interpolate(target, accel * delta) as Vector3
|
||||
# vel.x = hvel.x
|
||||
# vel.z = hvel.z
|
||||
# vel = move_and_slide(vel, Vector3(0,1,0), false, 4, deg2rad(MAX_SLOPE_ANGLE))
|
||||
|
||||
func rotate_delta(x_delta : float) -> void:
|
||||
y_rot += x_delta
|
||||
|
||||
@ -102,23 +54,12 @@ func rotate_delta(x_delta : float) -> void:
|
||||
|
||||
get_body().rotation_degrees = Vector3(0.0, y_rot, 0.0)
|
||||
|
||||
#remote func set_position(position : Vector3, rot : Vector3) -> void:
|
||||
# translation = position
|
||||
# rotation = rot
|
||||
|
||||
remote func sset_position(position : Vector3, rotation : Vector3) -> void:
|
||||
|
||||
# if get_network_master() != 1:
|
||||
# print(str(get_network_master()) + "npsset")
|
||||
|
||||
if multiplayer.network_peer and multiplayer.is_network_server():
|
||||
cset_position(position, rotation)
|
||||
vrpc("cset_position", position, rotation)
|
||||
|
||||
remote func cset_position(position : Vector3, rotation : Vector3) -> void:
|
||||
# if get_network_master() != 1:
|
||||
# print(str(get_network_master()) + "npcset")
|
||||
|
||||
get_body().translation = position
|
||||
get_body().rotation = rotation
|
||||
|
||||
|
@ -33,8 +33,6 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.960532, 0 )
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.875205, 0 )
|
||||
|
||||
[node name="character" parent="Body/Rotation_Helper/Model" instance=ExtResource( 2 )]
|
||||
refresh_in_editor = false
|
||||
|
||||
[node name="NamePlate" parent="." instance=ExtResource( 3 )]
|
||||
name_label_path = NodePath("../../NetworkedPlayerNode/NamePlate/Name")
|
||||
health_bar_path = NodePath("../../NetworkedPlayerNode/NamePlate/MarginContainer/TextureProgress")
|
||||
health_bar_label_path = NodePath("../../NetworkedPlayerNode/NamePlate/MarginContainer/CenterContainer/Label")
|
||||
|
@ -88,8 +88,12 @@ func _ready() -> void:
|
||||
|
||||
if animation_tree != null:
|
||||
anim_node_state_machine = animation_tree["parameters/playback"]
|
||||
|
||||
set_physics_process(false)
|
||||
|
||||
func _enter_tree():
|
||||
world = get_node(world_path) as VoxelWorld
|
||||
set_physics_process(true)
|
||||
|
||||
func _physics_process(delta : float) -> void:
|
||||
if not _on:
|
||||
@ -380,23 +384,9 @@ remote func cset_position(position : Vector3, rotation : Vector3) -> void:
|
||||
get_body().translation = position
|
||||
get_body().rotation = rotation
|
||||
|
||||
func _moved() -> void:
|
||||
if sis_casting():
|
||||
sfail_cast()
|
||||
|
||||
func _setup():
|
||||
setup_actionbars()
|
||||
|
||||
func _con_target_changed(entity: Entity, old_target: Entity) -> void:
|
||||
if is_instance_valid(old_target):
|
||||
old_target.onc_untargeted()
|
||||
|
||||
if is_instance_valid(ctarget):
|
||||
ctarget.onc_targeted()
|
||||
|
||||
if canc_interact():
|
||||
crequest_interact()
|
||||
|
||||
#func _setup():
|
||||
# setup_actionbars()
|
||||
|
||||
func _con_cast_started(info):
|
||||
if anim_node_state_machine != null and not casting_anim:
|
||||
anim_node_state_machine.travel("casting-loop")
|
||||
@ -426,85 +416,6 @@ func _con_spell_cast_success(info):
|
||||
|
||||
if animation_run:
|
||||
anim_node_state_machine.travel("run-loop")
|
||||
|
||||
func _son_xp_gained(value : int) -> void:
|
||||
if not EntityDataManager.get_xp_data().can_level_up(gets_level()):
|
||||
return
|
||||
|
||||
var xpr : int = EntityDataManager.get_xp_data().get_xp(gets_level());
|
||||
|
||||
if xpr <= sxp:
|
||||
slevelup(1)
|
||||
sxp = 0
|
||||
|
||||
|
||||
func _son_level_up(level: int) -> void:
|
||||
if sentity_data == null:
|
||||
return
|
||||
|
||||
var ecd : EntityClassData = sentity_data.entity_class_data
|
||||
|
||||
if ecd == null:
|
||||
return
|
||||
|
||||
sfree_spell_points += ecd.spell_points_per_level * level
|
||||
sfree_talent_points += level
|
||||
|
||||
for i in range(Stat.MAIN_STAT_ID_COUNT):
|
||||
var st : int = sentity_data.entity_class_data.get_stat_data().get_level_stat_data().get_stat_diff(i, slevel - level, slevel)
|
||||
|
||||
var statid : int = i + Stat.MAIN_STAT_ID_START
|
||||
|
||||
var stat : Stat = get_stat_int(statid)
|
||||
|
||||
var sm : StatModifier = stat.get_modifier(0)
|
||||
sm.base_mod += st
|
||||
|
||||
|
||||
#func _con_xp_gained(value):
|
||||
# print(value)
|
||||
|
||||
func _scraft(id):
|
||||
if not hass_craft_recipe_id(id):
|
||||
return
|
||||
|
||||
var recipe : CraftRecipe = gets_craft_recipe_id(id)
|
||||
|
||||
if recipe == null:
|
||||
return
|
||||
|
||||
for i in range(recipe.required_tools_count):
|
||||
var mat : CraftRecipeHelper = recipe.get_required_tool(i)
|
||||
|
||||
if mat == null:
|
||||
continue
|
||||
|
||||
if not sbag.has_item(mat.item, mat.count):
|
||||
return
|
||||
|
||||
|
||||
for i in range(recipe.required_materials_count):
|
||||
var mat : CraftRecipeHelper = recipe.get_required_material(i)
|
||||
|
||||
if mat == null:
|
||||
continue
|
||||
|
||||
if not sbag.has_item(mat.item, mat.count):
|
||||
return
|
||||
|
||||
#ok, player has everything
|
||||
|
||||
for i in range(recipe.required_materials_count):
|
||||
var mat : CraftRecipeHelper = recipe.get_required_material(i)
|
||||
|
||||
if mat == null:
|
||||
continue
|
||||
|
||||
sbag.remove_items(mat.item, mat.count)
|
||||
|
||||
var item : ItemInstance = recipe.item.item.create_item_instance()
|
||||
|
||||
sbag.add_item(item)
|
||||
|
||||
func _from_dict(dict):
|
||||
._from_dict(dict)
|
||||
|
@ -47,6 +47,7 @@ transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 0, 0
|
||||
[node name="Model" type="Spatial" parent="Body/Rotation_Helper"]
|
||||
|
||||
[node name="character" parent="Body/Rotation_Helper/Model" instance=ExtResource( 1 )]
|
||||
refresh_in_editor = false
|
||||
|
||||
[node name="GUILayer" parent="." instance=ExtResource( 3 )]
|
||||
[connection signal="onc_open_loot_winow_request" from="." to="GUILayer" method="_on_Player_onc_open_loot_winow_request"]
|
||||
|
@ -269,6 +269,7 @@ data/craft_data_folder="res://data/crafting"
|
||||
data/item_template_folder="res://data/item_templates"
|
||||
data/mob_data_folder="res://data/mob_data"
|
||||
data/player_character_data_folder="res://data/player_character_data"
|
||||
data/entity_species_data_folder="res://data/species"
|
||||
|
||||
[importer_defaults]
|
||||
|
||||
|
@ -78,11 +78,11 @@ func refresh():
|
||||
Logger.error("Save corrupted! Not Dict! " + file_name)
|
||||
continue
|
||||
|
||||
var display : Entity = Entities.spawn_display_player(file_name)
|
||||
player_display_container_node.add_child(display)
|
||||
display.owner = player_display_container_node
|
||||
var display : Entity = Entities.spawn_display_player(file_name, player_display_container_node.get_path())
|
||||
#player_display_container_node.add_child(display)
|
||||
#display.owner = player_display_container_node
|
||||
|
||||
display.from_dict(p as Dictionary)
|
||||
#display.from_dict(p as Dictionary)
|
||||
|
||||
var centry : Button = character_entry.instance() as Button
|
||||
container.add_child(centry)
|
||||
@ -90,7 +90,6 @@ func refresh():
|
||||
centry.group = character_button_group
|
||||
centry.connect("pressed", self, "character_selection_changed")
|
||||
|
||||
#display.sentity_data.entity_class_data.entity_class_name
|
||||
centry.setup(file_name, display.sentity_name, "", display.slevel, display)
|
||||
|
||||
if first_entry == null:
|
||||
|
Loading…
Reference in New Issue
Block a user