forked from KSP-KOS/KOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateHandler.cs
41 lines (35 loc) · 983 Bytes
/
UpdateHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace kOS
{
public class UpdateHandler
{
private List<IUpdateObserver> _observers = new List<IUpdateObserver>();
public double CurrentTime { get; private set; }
public double LastDeltaTime { get; private set; }
public UpdateHandler()
{
CurrentTime = 0;
LastDeltaTime = 0;
}
public void AddObserver(IUpdateObserver observer)
{
_observers.Add(observer);
}
public void RemoveObserver(IUpdateObserver observer)
{
_observers.Remove(observer);
}
public void UpdateObservers(double deltaTime)
{
LastDeltaTime = deltaTime;
CurrentTime += deltaTime;
foreach (IUpdateObserver observer in _observers)
{
observer.Update(deltaTime);
}
}
}
}