Ejemplo n.º 1
0
        public static T AssertGet <T>(this IEntityComponentContainer container)
            where T : class, IEntityComponent
        {
            var val = container.Get <T>();

            Debug.Assert(val != null);
            return(val);
        }
Ejemplo n.º 2
0
        public static bool Add <T>(this IEntityComponentContainer container, [NotNull] T component)
            where T : class, IEntityComponent
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            return(container.Add(typeof(T), component));
        }
Ejemplo n.º 3
0
        public Entity(
            [NotNull] string name,
            [NotNull] IEntityHandle handle,
            [NotNull] IServiceProvider services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            Name   = name ?? throw new ArgumentNullException(nameof(name));
            Handle = handle ?? throw new ArgumentNullException(nameof(handle));

            Components = new EntityComponentContainer();
            _log       = services.GetLazy <ILogger>();
            _server    = services.GetLazy <IGameServer>();
        }
Ejemplo n.º 4
0
 public static bool Remove <T>(this IEntityComponentContainer container)
     where T : class, IEntityComponent
 {
     return(container.Remove(typeof(T)));
 }
Ejemplo n.º 5
0
 public static T Get <T>(this IEntityComponentContainer container)
     where T : class, IEntityComponent
 {
     return((T)container.Get(typeof(T)));
 }
Ejemplo n.º 6
0
 private static void AssertDoesNotContainComponent(IEntityComponentContainer components, Type type)
 {
     Assert.IsFalse(components.Contains(type));
 }
Ejemplo n.º 7
0
 private static void AssertContainsComponent(IEntityComponentContainer components, Type type)
 {
     Assert.IsTrue(components.Contains(type));
 }