mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
refactor(资源加载): 将preload替换为load以优化内存使用
统一使用load方法动态加载资源,减少启动时的内存占用 移动Manager类到Tools/Managers目录下 修复DirTool处理remap文件的问题
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
@tool
|
||||
extends Camera2D
|
||||
class_name CameraManager
|
||||
|
||||
@onready var animator: AnimationPlayer = $"%animator"
|
||||
|
||||
var shakeIntensity: float = 0
|
||||
|
||||
static var instance: CameraManager = null
|
||||
|
||||
func _ready():
|
||||
instance = self
|
||||
func _physics_process(_delta):
|
||||
if is_instance_valid(UIState.player):
|
||||
position = UIState.player.position
|
||||
position += MathTool.randv2_range(shakeIntensity)
|
||||
|
||||
static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue):
|
||||
var startTime = WorldManager.getTime()
|
||||
instance.shakeIntensity = intensity
|
||||
await TickTool.until(
|
||||
func():
|
||||
instance.shakeIntensity = steper.call(instance.shakeIntensity, intensity, 1 - (WorldManager.getTime() - startTime) / millseconds)
|
||||
return WorldManager.getTime() - startTime >= millseconds
|
||||
)
|
||||
instance.shakeIntensity = 0
|
||||
static func playAnimation(animation: String):
|
||||
instance.animator.play(animation)
|
||||
@@ -0,0 +1,3 @@
|
||||
class_name ComponentManager
|
||||
|
||||
var store = {}
|
||||
@@ -0,0 +1,17 @@
|
||||
extends Node2D
|
||||
class_name WorldManager
|
||||
|
||||
static var rootNode: Node2D
|
||||
static var tree: SceneTree
|
||||
static var runningTime: int = 0
|
||||
|
||||
func _ready():
|
||||
tree = get_tree()
|
||||
rootNode = self
|
||||
func _physics_process(delta):
|
||||
runningTime += delta * 1000
|
||||
if EntityBase.mobCount() == 0 and runningTime > 3000:
|
||||
UIState.setPanel("MakeFeed")
|
||||
|
||||
static func getTime():
|
||||
return runningTime
|
||||
Reference in New Issue
Block a user