mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-27 22:41:56 +08:00
feat(武器系统): 添加武器升华选项功能
实现武器升华选项系统,允许为武器添加可选的强化效果。主要修改包括: 1. 新增 SublimateOption 类用于定义升华选项 2. 在 Weapon 类中添加 storeExtra 字典和相关方法用于存储额外属性 3. 为 Tree 武器实现具体的升华选项 4. 添加调试标记 debugRebuild
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
class_name SublimateOption
|
||||
|
||||
var displayName: String = "升华"
|
||||
var description: String = "描述"
|
||||
var executor: Callable = func(_weapon: Weapon, _entity: EntityBase): return
|
||||
|
||||
func _init(displayNames: String, descriptions: String, executors: Callable):
|
||||
displayName = displayNames
|
||||
description = descriptions
|
||||
executor = executors
|
||||
|
||||
func apply(entity: EntityBase, index: int):
|
||||
var weapon = entity.weapons[index]
|
||||
if weapon is Weapon:
|
||||
executor.call(weapon, entity)
|
||||
@@ -0,0 +1 @@
|
||||
uid://8e7whqgtnl5w
|
||||
@@ -54,6 +54,7 @@ var chargedTime: float = 0
|
||||
var attackSpeed: float = 1
|
||||
var looping: bool = false
|
||||
var autoUpdate: bool = false
|
||||
var storeExtra: Dictionary = {}
|
||||
|
||||
func _ready():
|
||||
cooldownTimer = CooldownTimer.new()
|
||||
@@ -201,8 +202,8 @@ func buildDescription(showNext: bool = false) -> String:
|
||||
text = "[color=cyan]%s[/color]" % data
|
||||
result = result.replace("$" + key, text)
|
||||
return result
|
||||
func readStore(key: String, default: Variant = null):
|
||||
return store.get(key, default)
|
||||
func readStore(key: String):
|
||||
return store.get(key, 0) + readStoreExtra(key)
|
||||
func playSound(sound: String):
|
||||
var body = sounds.get_node_or_null(sound)
|
||||
if body is AudioStreamPlayer2D:
|
||||
@@ -241,8 +242,16 @@ func exitLoop(entity: EntityBase):
|
||||
if !looping: return
|
||||
looping = false
|
||||
loopExit(entity)
|
||||
func addStoreExtra(key: String, value: float):
|
||||
if !storeExtra.has(key):
|
||||
storeExtra[key] = 0
|
||||
storeExtra[key] += value
|
||||
func readStoreExtra(key: String):
|
||||
return storeExtra.get(key, 0)
|
||||
|
||||
# 抽象
|
||||
func sublimateOptions() -> Array[SublimateOption]:
|
||||
return [] as Array[SublimateOption]
|
||||
func update(_to: int, origin: Dictionary, _entity: EntityBase):
|
||||
return origin
|
||||
func loopStart(_entity: EntityBase):
|
||||
|
||||
Reference in New Issue
Block a user