12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections.Generic;
- namespace XGame.Framework.Time
- {
- public class ClockContainer : IClockContainer, IDisposable
- {
- private readonly List<Clock> _clockList = new List<Clock>();
- public IClock AddClock(long timestamp)
- {
- Clock clock = new Clock(timestamp);
- _clockList.Add(clock);
- return clock;
- }
- public void Dispose()
- {
- _clockList.Clear();
- }
- public bool RemoveClock(IClock clock)
- {
- Clock node = (Clock)clock;
- if (_clockList.Contains(node))
- {
- _clockList.Remove(node);
- return true;
- }
- return false;
- }
- public void Update(int millisecond)
- {
- for (int i = 0; i < _clockList.Count; i++)
- {
- _clockList[i].Update(millisecond);
- }
- }
- }
- }
|