35 lines
945 B
C#
35 lines
945 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Project.B.CharacterController
|
|
{
|
|
public class CharacterService:ICharacterService,IDisposable
|
|
{
|
|
private readonly IFixedTicker _ticker;
|
|
public IDictionary<int,ICharacterController> Dictionary => _dictionary;
|
|
private readonly ConcurrentDictionary<int,ICharacterController> _dictionary = new();
|
|
|
|
public CharacterService(IFixedTicker ticker)
|
|
{
|
|
_ticker = ticker;
|
|
_ticker.Add(OnTick);
|
|
}
|
|
public void Dispose()
|
|
{
|
|
_ticker.Remove(OnTick);
|
|
}
|
|
private void OnTick(float obj)
|
|
{
|
|
foreach (var (id, characterController) in Dictionary)
|
|
{
|
|
characterController.UpdateState(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|