добавил немного функционала

This commit is contained in:
2022-10-31 17:56:35 +05:00
parent 0c76285e81
commit 1ddd2439ee
1092 changed files with 92598 additions and 5951 deletions
+56
View File
@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameSystem : MonoBehaviour
{
public static GameSystem Instance { get; private set; }
public List<IGameComponent> gameComponents { get; private set; } = new List<IGameComponent>();
public void AddGameComponent(IGameComponent component)
{
if(!gameComponents.Contains(component))
gameComponents.Add(component);
}
void Awake()
{
Instance = this;
}
void Start()
{
GameSystem[] gameSystems = FindObjectsOfType<GameSystem>();
if(gameSystems.Length > 1)
{
Destroy(this.gameObject);
return;
}
DontDestroyOnLoad(this);
}
void Update()
{
for(int i = 0; i < gameComponents.Count; i++)
gameComponents[i].OnUpdate();
}
void FixedUpdate()
{
for(int i = 0; i < gameComponents.Count; i++)
gameComponents[i].OnFixedUpdate();
}
void LateUpdate()
{
for(int i = 0; i < gameComponents.Count; i++)
gameComponents[i].OnLateUpdate();
}
public void RemoveGameComponent(IGameComponent component)
{
if(gameComponents.Contains(component))
gameComponents.Remove(component);
}
}