Beispiel #1
0
        public void CreateEntity()
        {
            var entityDefinition = this.resources.GetResource <EntityDefinition>(GameDataHelper.DeepCreateTestEntityDefinition(this.resources));
            var entity           = new TestEntity(
                entityDefinition,
                this.resources,
                this.avatarFactory,
                new[] { this.entityControllerFactory },
                new ControllerConfig[0],
                Vector3D.Zero,
                Vector3D.Zero,
                Vector3D.Zero);

            Assert.IsNotNull(entity);
        }
Beispiel #2
0
        public void CreateEntityWithControllers()
        {
            var entityDefinition = this.resources.GetResource <EntityDefinition>(GameDataHelper.DeepCreateTestEntityDefinition(this.resources));

            entityDefinition.Controllers = new[]
            {
                new ControllerConfig
                {
                    ControllerId = "controller.testA",
                    Settings     = { { "Foo", "512" }, { "Bar", "Hello World." } }
                },
                new ControllerConfig
                {
                    ControllerId = "controller.testB",
                    Settings     = { { "Foo", "42" }, { "Bar", "Don't Panic" } }
                },
            };
            var controllers = new[]
            {
                new ControllerConfig
                {
                    ControllerId = "controller.testB",
                    Settings     = { { "Bar", "Keep Calm" } }
                },
                new ControllerConfig
                {
                    ControllerId = "controller.testC",
                    Settings     = { { "Foo", "159" }, { "Bar", "Carry On" } }
                },
            };
            var entity = new TestEntity(
                entityDefinition,
                this.resources,
                this.avatarFactory,
                this.controllerFactories,
                controllers,
                Vector3D.Zero,
                Vector3D.Zero,
                Vector3D.Zero);

            Assert.IsTrue(entity.Controllers.All(c => c.Target == entity));
            Assert.IsFalse(entity.Controllers.Any(c => c.Id.ResourceId.StartsWith("controller.testB") && c.Config.GetValue("Bar") == "Don't Panic"));
            Assert.IsTrue(entity.Controllers.Any(c => c.Id.ResourceId.StartsWith("controller.testB") && c.Config.GetValue("Foo") == "42"));
            Assert.IsTrue(entity.Controllers.Any(c => c.Id.ResourceId.StartsWith("controller.testB") && c.Config.GetValue("Bar") == "Keep Calm"));
        }