狗屎Minimax坏我代码
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Characters.Inventory
|
||||
{
|
||||
public class OverloadSubmodule : SubmoduleBase<ItemBase>
|
||||
{
|
||||
public float maximumOverload;
|
||||
public float currentOverload;
|
||||
public float minimumCooldown;
|
||||
public float cooldownTimer;
|
||||
[ShowInInspector]
|
||||
public float currentWeight => cooldownTimer > 0f ? 0f : owner.overloadData.overloadWeight;
|
||||
|
||||
[HideInInspector]
|
||||
public Action OnTriggered;
|
||||
public OverloadSubmodule(ItemBase owner, OverloadData data) : base(owner)
|
||||
{
|
||||
this.maximumOverload = data.maxOverload;
|
||||
this.minimumCooldown = data.triggerCooldown;
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
if (cooldownTimer > 0f)
|
||||
{
|
||||
cooldownTimer -= deltaTime;
|
||||
if (cooldownTimer <= 0f)
|
||||
{
|
||||
cooldownTimer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ReceiveEnergy(float amount)
|
||||
{
|
||||
if (cooldownTimer > 0f) return;
|
||||
|
||||
currentOverload += amount;
|
||||
|
||||
if (currentOverload >= maximumOverload)
|
||||
{
|
||||
currentOverload = 0f; // 清空能量
|
||||
cooldownTimer = minimumCooldown; // 开始冷却
|
||||
OnTriggered?.Invoke(); // 触发监听件
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user