diff --git a/game/player/Body.gd b/game/player/Body.gd index d3b0af6..a908a12 100644 --- a/game/player/Body.gd +++ b/game/player/Body.gd @@ -114,32 +114,19 @@ func _process(delta : float) -> void: visibility_update_timer = 0 -# var camera : Camera = get_tree().get_root().get_camera() as Camera -# -# if camera == null: -# return -# -# var cam_pos : Vector3 = camera.global_transform.xform(Vector3()) -# var dstv : Vector3 = cam_pos - translation -# dstv.y = 0 -# var dst : float = dstv.length_squared() -# -# if dst > max_visible_distance_squared: -# if visible: -# hide() -# return -# else: -## var lod_level : int = int(dst / max_visible_distance_squared * 3.0) -# -# if dst < 400: #20^2 -# character_skeleton.set_lod_level(0) -# elif dst > 400 and dst < 900: #20^2, 30^2 -# character_skeleton.set_lod_level(1) -# else: -# character_skeleton.set_lod_level(2) -# -# if not visible: -# show() + var vpos : Vector2 = -get_tree().root.canvas_transform.get_origin() + (get_tree().root.get_visible_rect().size / 2) - position + var l : float = vpos.length_squared() + var rs : float = get_tree().root.size.x * get_tree().root.size.x + rs *= 0.3 + + if l < rs: + if not visible: + show() + set_physics_process(true) + else: + if visible: + hide() + set_physics_process(false) func _physics_process(delta : float) -> void: @@ -427,18 +414,18 @@ func cmouseover(event): if last_mouse_over != null and last_mouse_over != mo: if is_instance_valid(last_mouse_over): - last_mouse_over.onc_mouse_exit() + last_mouse_over.notification_cmouse_exit() last_mouse_over = null if last_mouse_over == null: - mo.onc_mouse_enter() + mo.notification_cmouse_enter() last_mouse_over = mo return if last_mouse_over != null: - last_mouse_over.onc_mouse_exit() + last_mouse_over.notification_cmouse_exit() last_mouse_over = null diff --git a/game/project.godot b/game/project.godot index 9b18e73..603685c 100644 --- a/game/project.godot +++ b/game/project.godot @@ -214,12 +214,12 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://scripts/items/ItemTemplateGD.gd" }, { -"base": "ItemVisual", +"base": "SkeletonModelEntry", "class": "ItemVisual2D", "language": "GDScript", "path": "res://scripts/item_visuals/ItemVisual2D.gd" }, { -"base": "ItemVisualEntry", +"base": "SkeletonModelEntry", "class": "ItemVisualEntry2D", "language": "GDScript", "path": "res://scripts/item_visuals/ItemVisualEntry2D.gd" diff --git a/game/scenes/World.gd b/game/scenes/World.gd index 5d5527e..8deb6dc 100644 --- a/game/scenes/World.gd +++ b/game/scenes/World.gd @@ -22,6 +22,7 @@ extends Node2D export(PackedScene) var world_layer : PackedScene +export(bool) var spawn_mobs : bool = true export(bool) var editor_generate : bool = false setget set_editor_generate, get_editor_generate export(bool) var show_loading_screen : bool = true export(bool) var generate_on_ready : bool = false @@ -56,7 +57,8 @@ func load_character(file_name: String) -> void: Server.sset_seed(_player.sseed) - generate() + if spawn_mobs: + generate() diff --git a/game/scripts/item_visuals/ItemVisual2D.gd b/game/scripts/item_visuals/ItemVisual2D.gd index 1edf75c..8c79d0f 100644 --- a/game/scripts/item_visuals/ItemVisual2D.gd +++ b/game/scripts/item_visuals/ItemVisual2D.gd @@ -1,4 +1,4 @@ -extends ItemVisual +extends SkeletonModelEntry class_name ItemVisual2D # Copyright (c) 2019 Péter Magyar diff --git a/game/scripts/item_visuals/ItemVisualEntry2D.gd b/game/scripts/item_visuals/ItemVisualEntry2D.gd index 9ceca65..5c7af61 100644 --- a/game/scripts/item_visuals/ItemVisualEntry2D.gd +++ b/game/scripts/item_visuals/ItemVisualEntry2D.gd @@ -1,5 +1,5 @@ tool -extends ItemVisualEntry +extends SkeletonModelEntry class_name ItemVisualEntry2D # Copyright (c) 2019 Péter Magyar