33 lines
834 B
C#
33 lines
834 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using BITKit;
|
|
using BITKit.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Player.Survival
|
|
{
|
|
[CustomType(typeof(IPlayerSurvivalService))]
|
|
public class PlayerSurvivalService : EntityComponent, IPlayerSurvivalService
|
|
{
|
|
public IPlayerSurvivalElement[] Elements { get; set; } = Array.Empty<IPlayerSurvivalElement>();
|
|
[SerializeReference, SubclassSelector] private IPlayerSurvivalElement[] initialElements = Array.Empty<IPlayerSurvivalElement>();
|
|
|
|
private IntervalUpdate _interval = new(1);
|
|
public override void OnAwake()
|
|
{
|
|
Elements = initialElements;
|
|
}
|
|
|
|
public override void OnUpdate(float deltaTime)
|
|
{
|
|
if (_interval.AllowUpdate is false) return;
|
|
foreach (var x in Elements)
|
|
{
|
|
x.Value -= 1;
|
|
}
|
|
}
|
|
}
|
|
}
|