ActorProxyComponent.cs 447 B

123456789101112131415161718192021
  1. using System.Collections.Generic;
  2. namespace Model
  3. {
  4. public class ActorProxyComponent: Component
  5. {
  6. private readonly Dictionary<long, ActorProxy> dictionary = new Dictionary<long, ActorProxy>();
  7. public ActorProxy Get(long id)
  8. {
  9. if (this.dictionary.TryGetValue(id, out ActorProxy actorProxy))
  10. {
  11. return actorProxy;
  12. }
  13. actorProxy = new ActorProxy(id);
  14. this.dictionary[id] = actorProxy;
  15. return actorProxy;
  16. }
  17. }
  18. }