public void Add(IActor actor, IEntityBlueprint blueprint)
        {
            if (_actors.Contains(actor))
            {
                throw new InvalidOperationException("Actors already contains this actor");
            }
            _actors.Add(actor);

            if (blueprint is Player)
            {
                Player = actor;
                return;
            }

            if (_actorsByType.ContainsKey(blueprint))
            {
                _actorsByType[blueprint].Add(actor);
            }
            else
            {
                _actorsByType.Add(blueprint, new List <IActor> {
                    actor
                });
            }
        }
Esempio n. 2
0
 public void Initialize(IEntityBlueprint blueprint)
 {
     Entity.AddComponents(blueprint.GetComponents(Entity));
 }
 public ReadOnlyCollection <IActor> GetCached(IEntityBlueprint type)
 {
     return(_actorsByType.ContainsKey(type) ? _actorsByType[type].AsReadOnly() : null);
 }