Compare commits
2 Commits
813d034fc5
...
87e455827c
Author | SHA1 | Date |
---|---|---|
|
87e455827c | |
|
bee2db1354 |
|
@ -2,18 +2,59 @@ namespace GameDev.CoreSystems
|
||||||
{
|
{
|
||||||
public interface IPowerSystem
|
public interface IPowerSystem
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This entity generates power
|
||||||
|
/// </summary>
|
||||||
public bool IsGenerator { get; }
|
public bool IsGenerator { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This entity consumes power
|
||||||
|
/// </summary>
|
||||||
public bool IsConsumer { get; }
|
public bool IsConsumer { get; }
|
||||||
|
|
||||||
public void SetMaxPower(int newValue);
|
/// <summary>
|
||||||
|
/// True if consumer demand exceed generator capacity
|
||||||
|
/// </summary>
|
||||||
|
public bool PowerLost { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the power configuration of the entity with the <see cref="SoPowerConfig"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">Power config for the entity</param>
|
||||||
public void Initialize(SoPowerConfig config);
|
public void Initialize(SoPowerConfig config);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Max power for the entity
|
||||||
|
/// Generator capacity or max consumption depending on
|
||||||
|
/// the set type <see cref="IsGenerator"/> or <see cref="IsConsumer"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newMaxPowerValue"></param>
|
||||||
|
public void SetMaxPower(int newMaxPowerValue);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current power for the entity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newCurrentPowerValue">current power generated/consumed power for this entity [W]</param>
|
||||||
|
public void SetCurrentPower(int newCurrentPowerValue);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Max power for the entity
|
||||||
|
/// Generator capacity or max consumption depending on
|
||||||
|
/// the set type <see cref="IsGenerator"/> or <see cref="IsConsumer"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The max power that can be generated/consumed by this entity [W]</returns>
|
||||||
public int GetMaxPower();
|
public int GetMaxPower();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get current power for the entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The power generated/consumed by this entity right now [W]</returns>
|
||||||
public int GetCurrentPower();
|
public int GetCurrentPower();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the power factor for the entity
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The ratio between current power and max power [factor]</returns>
|
||||||
public float GetPowerFactor();
|
public float GetPowerFactor();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,12 +27,13 @@ namespace GameDev.CoreSystems
|
||||||
var position = BarrelEndPoint.position;
|
var position = BarrelEndPoint.position;
|
||||||
var forward = BarrelEndPoint.forward;
|
var forward = BarrelEndPoint.forward;
|
||||||
var ray = new Ray(position, forward);
|
var ray = new Ray(position, forward);
|
||||||
Debug.DrawRay(position, forward * 10, Color.green);
|
|
||||||
|
|
||||||
if (Physics.Raycast(ray, out RaycastHit hitInfo))
|
if (Physics.Raycast(ray, out RaycastHit hitInfo))
|
||||||
{
|
{
|
||||||
if (hitInfo.transform.TryGetComponent(out Targetable target))
|
if (hitInfo.transform.TryGetComponent(out Targetable target))
|
||||||
{
|
{
|
||||||
|
Debug.DrawRay(position, forward * Vector3.Distance(position, target.GetCenterPosition()),
|
||||||
|
Color.red, 0.1f);
|
||||||
target.Damageable.ModifyHealth(Mathf.RoundToInt(-Damage));
|
target.Damageable.ModifyHealth(Mathf.RoundToInt(-Damage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue