AsteroidGame/Assets/Entities/Scripts/PowerBase.cs

42 lines
1.1 KiB
C#

using AsteroidGame.ScriptableObjects;
using GameDev.CoreSystems;
using UnityEngine;
namespace AsteroidGame.Entities
{
public class PowerBase : MonoBehaviour, IPowerSystem
{
[Header("State")]
[SerializeField] protected bool _isGenerator = true;
[SerializeField] protected bool _isConsumer = true;
[SerializeField] protected int _maxPower;
[SerializeField] protected int _currentPower;
public void SetConfig(SoPowerConfig config)
{
_isGenerator = config.isGenerator;
_isConsumer = config.isConsumer;
_maxPower = config.maxPower;
}
#region Setters
public void SetMaxPower(int newValue) => _maxPower = newValue;
#endregion
#region Getters
public bool IsGenerator => _isGenerator;
public bool IsConsumer => _isConsumer;
public int GetMaxPower() => _maxPower;
public int GetCurrentPower() => _currentPower;
public float GetPowerFactor() => (float)_currentPower / _maxPower;
#endregion
}
}