Entities will now hide themselves when not on the screen. Also small tweaks.

This commit is contained in:
Relintai 2020-07-12 19:43:49 +02:00
parent 8a433873f5
commit df58cda377
5 changed files with 23 additions and 34 deletions

View File

@ -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

View File

@ -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"

View File

@ -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()

View File

@ -1,4 +1,4 @@
extends ItemVisual
extends SkeletonModelEntry
class_name ItemVisual2D
# Copyright (c) 2019 Péter Magyar

View File

@ -1,5 +1,5 @@
tool
extends ItemVisualEntry
extends SkeletonModelEntry
class_name ItemVisualEntry2D
# Copyright (c) 2019 Péter Magyar