mirror of
https://github.com/Relintai/broken_seals_2d.git
synced 2024-11-11 20:35:10 +01:00
Entities will now hide themselves when not on the screen. Also small tweaks.
This commit is contained in:
parent
8a433873f5
commit
df58cda377
@ -114,32 +114,19 @@ func _process(delta : float) -> void:
|
|||||||
|
|
||||||
visibility_update_timer = 0
|
visibility_update_timer = 0
|
||||||
|
|
||||||
# var camera : Camera = get_tree().get_root().get_camera() as Camera
|
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()
|
||||||
# if camera == null:
|
var rs : float = get_tree().root.size.x * get_tree().root.size.x
|
||||||
# return
|
rs *= 0.3
|
||||||
#
|
|
||||||
# var cam_pos : Vector3 = camera.global_transform.xform(Vector3())
|
if l < rs:
|
||||||
# var dstv : Vector3 = cam_pos - translation
|
if not visible:
|
||||||
# dstv.y = 0
|
show()
|
||||||
# var dst : float = dstv.length_squared()
|
set_physics_process(true)
|
||||||
#
|
else:
|
||||||
# if dst > max_visible_distance_squared:
|
if visible:
|
||||||
# if visible:
|
hide()
|
||||||
# hide()
|
set_physics_process(false)
|
||||||
# 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()
|
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta : float) -> void:
|
func _physics_process(delta : float) -> void:
|
||||||
@ -427,18 +414,18 @@ func cmouseover(event):
|
|||||||
|
|
||||||
if last_mouse_over != null and last_mouse_over != mo:
|
if last_mouse_over != null and last_mouse_over != mo:
|
||||||
if is_instance_valid(last_mouse_over):
|
if is_instance_valid(last_mouse_over):
|
||||||
last_mouse_over.onc_mouse_exit()
|
last_mouse_over.notification_cmouse_exit()
|
||||||
|
|
||||||
last_mouse_over = null
|
last_mouse_over = null
|
||||||
|
|
||||||
if last_mouse_over == null:
|
if last_mouse_over == null:
|
||||||
mo.onc_mouse_enter()
|
mo.notification_cmouse_enter()
|
||||||
last_mouse_over = mo
|
last_mouse_over = mo
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if last_mouse_over != null:
|
if last_mouse_over != null:
|
||||||
last_mouse_over.onc_mouse_exit()
|
last_mouse_over.notification_cmouse_exit()
|
||||||
last_mouse_over = null
|
last_mouse_over = null
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,12 +214,12 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://scripts/items/ItemTemplateGD.gd"
|
"path": "res://scripts/items/ItemTemplateGD.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ItemVisual",
|
"base": "SkeletonModelEntry",
|
||||||
"class": "ItemVisual2D",
|
"class": "ItemVisual2D",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://scripts/item_visuals/ItemVisual2D.gd"
|
"path": "res://scripts/item_visuals/ItemVisual2D.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ItemVisualEntry",
|
"base": "SkeletonModelEntry",
|
||||||
"class": "ItemVisualEntry2D",
|
"class": "ItemVisualEntry2D",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://scripts/item_visuals/ItemVisualEntry2D.gd"
|
"path": "res://scripts/item_visuals/ItemVisualEntry2D.gd"
|
||||||
|
@ -22,6 +22,7 @@ extends Node2D
|
|||||||
|
|
||||||
export(PackedScene) var world_layer : PackedScene
|
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 editor_generate : bool = false setget set_editor_generate, get_editor_generate
|
||||||
export(bool) var show_loading_screen : bool = true
|
export(bool) var show_loading_screen : bool = true
|
||||||
export(bool) var generate_on_ready : bool = false
|
export(bool) var generate_on_ready : bool = false
|
||||||
@ -56,7 +57,8 @@ func load_character(file_name: String) -> void:
|
|||||||
|
|
||||||
Server.sset_seed(_player.sseed)
|
Server.sset_seed(_player.sseed)
|
||||||
|
|
||||||
generate()
|
if spawn_mobs:
|
||||||
|
generate()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
extends ItemVisual
|
extends SkeletonModelEntry
|
||||||
class_name ItemVisual2D
|
class_name ItemVisual2D
|
||||||
|
|
||||||
# Copyright (c) 2019 Péter Magyar
|
# Copyright (c) 2019 Péter Magyar
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
tool
|
tool
|
||||||
extends ItemVisualEntry
|
extends SkeletonModelEntry
|
||||||
class_name ItemVisualEntry2D
|
class_name ItemVisualEntry2D
|
||||||
|
|
||||||
# Copyright (c) 2019 Péter Magyar
|
# Copyright (c) 2019 Péter Magyar
|
||||||
|
Loading…
Reference in New Issue
Block a user