74 lines
2.1 KiB
C#
74 lines
2.1 KiB
C#
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
{
|
|
public partial class Player
|
|
{
|
|
private float deltaTime => selfTimeSm.DeltaTime;
|
|
}
|
|
|
|
public partial class Player
|
|
{
|
|
private void Regeneration()
|
|
{
|
|
float healthRegenRate = attributeSm[CharacterAttribute.HealthRegeneration] * deltaTime;
|
|
|
|
if (healthRegenRate != 0)
|
|
{
|
|
Heal(healthRegenRate, false);
|
|
}
|
|
|
|
float energyRegenRate = attributeSm[CharacterAttribute.EnergyRegeneration] * deltaTime;
|
|
if (energyRegenRate != 0)
|
|
{
|
|
RecoverEnergy(energyRegenRate, false);
|
|
}
|
|
}
|
|
|
|
|
|
private void DistributeOverloadEnergy(float totalOverflowAmount)
|
|
{
|
|
if (totalOverflowAmount <= 0) return;
|
|
|
|
var overloadSubmodules = new System.Collections.Generic.List<Inventory.OverloadSubmodule>();
|
|
|
|
if (inventorySc.equipmentSm.currentMainWeapon?.overloadSm != null)
|
|
{
|
|
overloadSubmodules.Add(inventorySc.equipmentSm.currentMainWeapon.overloadSm);
|
|
}
|
|
|
|
foreach (var equip in inventorySc.equipmentSm.currentSupportEquipments)
|
|
{
|
|
if (equip?.overloadSm != null)
|
|
{
|
|
overloadSubmodules.Add(equip.overloadSm);
|
|
}
|
|
}
|
|
|
|
foreach (var equip in inventorySc.backpackSm.passiveEquipments)
|
|
{
|
|
if (equip?.overloadSm != null)
|
|
{
|
|
overloadSubmodules.Add(equip.overloadSm);
|
|
}
|
|
}
|
|
|
|
if (overloadSubmodules.Count == 0) return;
|
|
|
|
float totalWeight = 0;
|
|
foreach (var sm in overloadSubmodules)
|
|
{
|
|
totalWeight += sm.currentWeight;
|
|
}
|
|
|
|
if (totalWeight <= 0) return;
|
|
|
|
foreach (var sm in overloadSubmodules)
|
|
{
|
|
float assignedAmount = totalOverflowAmount * (sm.currentWeight / totalWeight);
|
|
sm.ReceiveEnergy(assignedAmount);
|
|
}
|
|
}
|
|
}
|
|
}
|