This commit is contained in:
SoulliesOfficial
2026-05-27 15:15:28 -04:00
parent 76f498ae2b
commit 72756712f7
669 changed files with 5361 additions and 12268 deletions

View File

@@ -20,9 +20,9 @@ namespace Cielonos.MainGame.Inventory
public FunctionSubmodule(ItemBase owner, FunctionData data) : base(owner)
{
functionUnits = new Dictionary<string, RuntimeFunctionUnit>();
foreach (var kvp in data.functionUnits)
foreach (var unit in data.functionUnitList)
{
functionUnits[kvp.Key] = new RuntimeFunctionUnit(this, kvp.Value);
functionUnits[unit.unitName] = new RuntimeFunctionUnit(this, unit);
}
}
@@ -46,7 +46,7 @@ namespace Cielonos.MainGame.Inventory
public RuntimeFunctionUnit(FunctionSubmodule owner, FunctionData.FunctionUnit data) : base(owner)
{
this.data = data;
maxCooldown = data.interval;
maxCooldown = data.cooldown;
currentCooldown = 0f;
}
@@ -60,30 +60,49 @@ namespace Cielonos.MainGame.Inventory
{
bool cooldownAvailable = currentCooldown <= 0f;
bool energyAvailable = character.attributeSm[CharacterAttribute.Energy] >= GetEffectiveEnergyCost();
return cooldownAvailable && energyAvailable;
bool available = cooldownAvailable && energyAvailable;
if (!available)
{
if(character is Player && owner.owner is MainWeaponBase)
{
if (data.shownInUI || data.isMain)
{
PlayerCanvas.MainWeaponUIArea.functionIconDict[data.unitName].SetFrameOutline(0.25f, Color.red);
}
}
}
return available;
}
public RuntimeFunctionUnit Execute()
{
ResetCooldown();
ConsumeEnergy();
if(character is Player && owner.owner is MainWeaponBase)
{
if (data.shownInUI || data.isMain)
{
PlayerCanvas.MainWeaponUIArea.functionIconDict[data.unitName].SetFrameOutline(0.25f);
}
}
return this;
}
private const float MinCooldownMultiplier = 0.1f;
private const float MaxCooldownReduction = 0.9f;
private const float MaxEnergyCostReduction = 0.9f;
/// <summary> 计算应用 EnergyCostReduction 后的实际能量消耗。 </summary>
private float GetEffectiveEnergyCost()
{
float ecr = Mathf.Clamp(character.attributeSm[CharacterAttribute.EnergyCostReduction], 0f, MaxEnergyCostReduction);
return data.energyCost * (1f - ecr);
float energyCostReduction = Mathf.Clamp(character.attributeSm[CharacterAttribute.EnergyCostReduction], 0f, MaxEnergyCostReduction);
return data.energyCost * (1f - energyCostReduction);
}
private void ResetCooldown()
{
float cdr = Mathf.Clamp(character.attributeSm[CharacterAttribute.CooldownReduction], 0f, 1f - MinCooldownMultiplier);
currentCooldown = maxCooldown * (1f - cdr);
float cooldownReduction = Mathf.Clamp(character.attributeSm[CharacterAttribute.CooldownReduction], 0f, MaxCooldownReduction);
currentCooldown = maxCooldown * (1f - cooldownReduction);
}
private void ConsumeEnergy()