Exemplo n.º 1
0
    Systems InitSystems(string featurestr, Contexts contexts)
    {
        var initSystems    = new Feature("Init Systems");
        var inputSystems   = new Feature("Input Systems");
        var gameSystems    = new Feature("Game Systems");
        var viewSystems    = new Feature("View Systems");
        var destroySystems = new Feature("Destroy Systems");

        initSystems.Add(InitSystem(typeof(InitPlayerSystem), contexts));

        //inputSystems.Add(InitSystem(typeof(InitPlayerSystem), contexts));

        gameSystems.Add(InitSystem(typeof(MoveSystem), contexts));

        viewSystems.Add(InitSystem(typeof(AddViewSystem), contexts));
        viewSystems.Add(InitSystem(typeof(RemoveViewSystem), contexts));
        viewSystems.Add(InitSystem(typeof(UpdatePositionSystem), contexts));

        destroySystems.Add(InitSystem(typeof(DestroySystem), contexts));

        var systems = new Feature(featurestr)
                      .Add(initSystems)
                      .Add(inputSystems)
                      .Add(gameSystems)
                      .Add(viewSystems)
                      .Add(destroySystems);

        systems.Initialize();

        return(systems);
    }
Exemplo n.º 2
0
    public MainBootstrap(string name, Contexts contexts, List <ISystem> systems)
    {
        _contexts = contexts;
        _feature  = new Feature($"Bootstrap [{name}]");

        var prioritySystems = new List <IPrioritySystem>();
        var otherSystems    = new List <ISystem>();

        foreach (var system in systems)
        {
            if (system is IPrioritySystem)
            {
                prioritySystems.Add((IPrioritySystem)system);
            }
            else
            {
                otherSystems.Add(system);
            }
        }

        prioritySystems.Sort((x, y) => x.Priority.CompareTo(y.Priority));

        foreach (var system in prioritySystems)
        {
            _feature.Add((ISystem)system);
        }

        foreach (var system in otherSystems)
        {
            _feature.Add(system);
        }
    }
Exemplo n.º 3
0
        public override Systems CreateUpdateSystems(IContexts contexts1)
        {
            var contexts          = contexts1 as Contexts;
            var sessionObjects    = contexts.session.commonSession;
            var entityIdGenerator = sessionObjects.EntityIdGenerator;


            _gameModule = new CompositeGameModule();

            _gameModule.AddModule(new ServerPlayerModule(contexts));
            _gameModule.AddModule(new ServerEntityInitModule(contexts));
            _gameModule.AddModule(new ServerBulletModule(contexts));

            IHitBoxEntityManager hitBoxEntityManager = new HitBoxEntityManager(contexts, true);
            var snapshotSelectorContainer            = contexts.session.serverSessionObjects.CompensationSnapshotSelector;
            ICompensationWorldFactory factory        =
                new ServerCompensationWorldFactory(snapshotSelectorContainer, hitBoxEntityManager);
            var serverDamageInfoCollector = new ServerDamageInfoCollector(contexts.player);

            _gameModule.AddModule(new UserCmdGameModule(contexts,
                                                        factory,
                                                        new BulletHitHandler(contexts,
                                                                             entityIdGenerator,
                                                                             room.PlayerDamager,
                                                                             serverDamageInfoCollector,
                                                                             contexts.session.entityFactoryObject.SoundEntityFactory,
                                                                             SingletonManager.Get <EnvironmentTypeConfigManager>()),
                                                        new MeleeHitHandler(contexts, room.PlayerDamager, entityIdGenerator,
                                                                            serverDamageInfoCollector, contexts.session.entityFactoryObject.SoundEntityFactory),
                                                        new ThrowingHitHandler(contexts, room.PlayerDamager),
                                                        sessionObjects,
                                                        MotorsFactory.CraeteMotors(contexts, SingletonManager.Get <CameraConfigManager>().Config)));
            _gameModule.AddModule(new ServerPostPredictionModule(contexts));
            _gameModule.AddModule(new ServerVehicleModule(contexts,
                                                          contexts.session.serverSessionObjects.VehicleTimer));
            _gameModule.AddModule(new ServerGamePlayModule(contexts, room));
            _gameModule.AddModule(
                new ServerSceneObjectModule(contexts, this, sessionObjects.EquipmentEntityIdGenerator));

            IUserCmdExecuteSystemHandler    userCmdExecuteSystemHandler    = new UserCmdExecuteSystemHandler(contexts);
            IVehicleCmdExecuteSystemHandler vehicleCmdExecuteSystemHandler =
                new ServerVehicleCmdExecuteSystemHandler(contexts);

            var systems = new Feature("GameSessionState");

            systems.Add(new PingSystem(contexts));
            systems.Add(new ServerMainFeature(
                            "ServerSystems",
                            _gameModule,
                            userCmdExecuteSystemHandler,
                            vehicleCmdExecuteSystemHandler,
                            contexts.session.serverSessionObjects.SimulationTimer,
                            new VehicleExecutionSelector(contexts),
                            sessionObjects,
                            room));

            return(systems);
        }
Exemplo n.º 4
0
        public void CanPlaceBasic()
        {
            Labrys.Generation.Grid rawGrid = new Labrys.Generation.Grid();

            rawGrid[0, 0] = Section.Default();

            // Wrap the raw grid in a readonly version
            ReadOnlyGrid grid = new ReadOnlyGrid(rawGrid);

            // Basic 2x2 feature
            Feature feature = new Feature();

            feature.Add(0, 0);
            feature.Add(1, 0);
            feature.Add(0, 1);
            feature.Add(1, 1);

            // Placing it in any configuration over the blocking tile should fail

            // This tests for placing the Feature over different grid positions
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(0, 0), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(-1, 0), new Vector2Int(0, 0), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, -1), new Vector2Int(0, 0), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(-1, -1), new Vector2Int(0, 0), 0));

            // This tests placing the Feature with a different local position.
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(0, 0), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(1, 0), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(0, 1), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(1, 1), 0));

            // This tests both at once.
            // This can be read as "I want to place this Feature so that its upper-right Section is
            // placed at the position (1, 1) in the grid". This should fail, because the bottom-left
            // corner of the Feature is over (0, 0), which already exists.
            Assert.False(feature.CanPlace(grid, new Vector2Int(1, 1), new Vector2Int(1, 1), 0));

            // Weird case, you can use offsets that don't exist but they can still work.
            Assert.False(feature.CanPlace(grid, new Vector2Int(100, 100), new Vector2Int(100, 100), 0));

            // The above types of cases are the only ones that should fail- most other placements
            // that don't follow those patterns should succeed. Here's a few that should work.

            // No local offset
            Assert.True(feature.CanPlace(grid, new Vector2Int(1, 0), new Vector2Int(0, 0), 0));
            Assert.True(feature.CanPlace(grid, new Vector2Int(-2, 0), new Vector2Int(0, 0), 0));
            Assert.True(feature.CanPlace(grid, new Vector2Int(-2, -2), new Vector2Int(0, 0), 0));
            Assert.True(feature.CanPlace(grid, new Vector2Int(10, 0), new Vector2Int(0, 0), 0));

            // Top-right local offset
            Assert.True(feature.CanPlace(grid, new Vector2Int(-1, 0), new Vector2Int(1, 1), 0));
            Assert.True(feature.CanPlace(grid, new Vector2Int(-1, -1), new Vector2Int(1, 1), 0));
            Assert.True(feature.CanPlace(grid, new Vector2Int(0, -1), new Vector2Int(1, 1), 0));

            // Just y local offset
            Assert.True(feature.CanPlace(grid, new Vector2Int(0, -2), new Vector2Int(0, 1), 0));
        }
Exemplo n.º 5
0
        public override Systems CreateUpdateSystems(IContexts contexts)
        {
            Contexts _contexts = (Contexts)contexts;
            var      systems   = new Feature("PreparingPlayer");

            systems.Add(new RequestPlayerInfoSystem(_contexts, this));
            systems.Add(new ClientPreparePlayerMainFeature("MainFeature", GameModuleFactory.CreatePreparePlayerGameModule(_contexts), _contexts.session.commonSession));
            systems.Add(new CheckPreparingPlayerSystem(_contexts, this));
            systems.Add(new ResourceLoadSystem(new PreLoadModule(this, contexts), _contexts.session.commonSession.AssetManager));
            return(systems);
        }
Exemplo n.º 6
0
        public void CanConvertFromFeature_Square()
        {
            // Feature is a 2x2 square.
            Feature feature = new Feature();

            feature.Add(0, 0);
            feature.Add(1, 0);
            feature.Add(0, 1);
            feature.Add(1, 1);

            FeatureAsset featureAsset = FeatureAsset.FromFeature(feature);

            // Basic test- are sections present?
            ValidateSection(featureAsset, new Vector2Int(0, 0));
            ValidateSection(featureAsset, new Vector2Int(1, 0));
            ValidateSection(featureAsset, new Vector2Int(0, 1));
            ValidateSection(featureAsset, new Vector2Int(1, 1));

            /*
             * Layout of the FeatureAsset grid, for reference.
             *
             *  3 o | o | o
             *  2 - r - r -
             *  1 o | x | o
             *  0 - r - r -
             * -1 o | o | o
             *   -1 0 1 2 3
             */

            ValidateExternalLink(featureAsset, new Vector2Int(0, 3));  // Top
            ValidateExternalLink(featureAsset, new Vector2Int(2, 3));
            ValidateExternalLink(featureAsset, new Vector2Int(-1, 0)); // Left
            ValidateExternalLink(featureAsset, new Vector2Int(-1, 2));
            ValidateExternalLink(featureAsset, new Vector2Int(0, -1)); // Bottom
            ValidateExternalLink(featureAsset, new Vector2Int(2, -1));
            ValidateExternalLink(featureAsset, new Vector2Int(3, 0));  // Right
            ValidateExternalLink(featureAsset, new Vector2Int(3, 2));

            ValidateInternalLink(featureAsset, new Vector2Int(1, 2)); // Top
            ValidateInternalLink(featureAsset, new Vector2Int(0, 1)); // Left
            ValidateInternalLink(featureAsset, new Vector2Int(1, 0)); // Bottom
            ValidateInternalLink(featureAsset, new Vector2Int(2, 1)); // Right
            ValidateInternalLink(featureAsset, new Vector2Int(1, 1)); // Middle

            ValidateMissingLink(featureAsset, new Vector2Int(-1, -1));
            ValidateMissingLink(featureAsset, new Vector2Int(1, -1));
            ValidateMissingLink(featureAsset, new Vector2Int(3, -1));
            ValidateMissingLink(featureAsset, new Vector2Int(-1, 1));
            //ValidateMissingLink(featureAsset, new Vector2Int(1, 1)); // Middle
            ValidateMissingLink(featureAsset, new Vector2Int(3, 1));
            ValidateMissingLink(featureAsset, new Vector2Int(-1, 3));
            ValidateMissingLink(featureAsset, new Vector2Int(1, 3));
            ValidateMissingLink(featureAsset, new Vector2Int(3, 3));
        }
Exemplo n.º 7
0
    Feature getFeatures()
    {
        var feature = new Feature("Game");

        feature.Add(new InitializeMapSystem(_context));
        feature.Add(new CellToPositionSystem(_context));
        feature.Add(new CreateViewSystem(_context));
        feature.Add(new ApplyPositionSystem(_context));

        return(feature);
    }
Exemplo n.º 8
0
    static public void Main3()
    {
        var application = new Feature("Application")
        {
            Name = "Application", Description = "Application"
        };
        var drivers = new Feature("Drivers")
        {
            Name = "Drivers", Description = "Drivers", AttributesDefinition = $"Display = {FeatureDisplay.expand}"
        };
        var driver1 = new Feature("Driver 1")
        {
            Name = "Driver 1", Description = "Driver 1", IsEnabled = false
        };
        var driver2 = new Feature("Driver 2")
        {
            Name = "Driver 2", Description = "Driver 2"
        };

        var project =
            new ManagedProject("MyProduct",
                               new Dir(@"%ProgramFiles%\My Company\My Product",
                                       new File(application, @"Files\Bin\MyApp.exe"),
                                       new Dir("Drivers",
                                               new Dir("Driver1",
                                                       new File(driver1, @"Files\Docs\Manual.txt")),
                                               new Dir("Driver2",
                                                       new File(driver2, @"Files\Docs\Manual.txt")))));

        // project.Package.AttributesDefinition = "InstallPrivileges=elevated;AdminImage=yes;InstallScope=perMachine";
        // project.UI = WUI.WixUI_InstallDir;

        project.ManagedUI = new ManagedUI();
        project.ManagedUI.InstallDialogs.Add(Dialogs.Welcome)
        .Add(Dialogs.Features)
        .Add(Dialogs.InstallDir)
        .Add(Dialogs.Progress)
        .Add(Dialogs.Exit);

        //removing entry dialog
        project.ManagedUI.ModifyDialogs.Add(Dialogs.MaintenanceType)
        .Add(Dialogs.Features)
        .Add(Dialogs.Progress)
        .Add(Dialogs.Exit);

        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");

        drivers.Add(driver1);
        drivers.Add(driver2);

        project.PreserveTempFiles = true;
        project.BuildMsi();
    }
Exemplo n.º 9
0
    Systems createNestedSystems()
    {
        var systems1 = new Feature("Nested 1");
        var systems2 = new Feature("Nested 2");
        var systems3 = new Feature("Nested 3");

        systems1.Add(systems2);
        systems2.Add(systems3);
        systems1.Add(createSomeSystems());

        return(new Feature("Nested Systems")
               .Add(systems1));
    }
Exemplo n.º 10
0
        public override Systems CreateUpdateSystems(IContexts contexts)
        {
            var systems       = new Feature("PreLoadingState");
            var contextsImpl  = contexts as Contexts;
            var commonSession = contextsImpl.session.commonSession;

            systems.Add(new LoadRequestManagerSystem(commonSession));
            systems.Add(new ResourceLoadSystem(
                            new PreLoadModule(this, contexts),
                            commonSession.LoadRequestManager));

            return(systems);
        }
Exemplo n.º 11
0
        public override Systems CreateUpdateSystems(IContexts contexts1)
        {
            var gameModule = new CompositeGameModule();
            var contexts   = contexts1 as Contexts;

            gameModule.AddModule(new ServerInitModule(contexts, this));

            var feature = new Feature("ServerLoadConfigurationState");

            feature.Add(new ServerPrepareFeature("loadConfig", gameModule, contexts.session.commonSession.AssetManager));
            feature.Add(new BaseConfigurationInitModule(this, contexts.session.commonSession.AssetManager));
            return(feature);
        }
    Systems createNestedSystems()
    {
        var systems1 = new Feature("Nested 1");
        var systems2 = new Feature("Nested 2");
        var systems3 = new Feature("Nested 3");

        systems1.Add(systems2);
        systems2.Add(systems3);
        systems1.Add(createSomeSystems());

        return new Feature("Nested Systems")
            .Add(systems1);
    }
Exemplo n.º 13
0
        public void CanConvertFromFeature_Line()
        {
            // Feature 1 is a horizontal line.
            Feature feature1 = new Feature();

            feature1.Add(0, 0);
            feature1.Add(1, 0);
            feature1.Add(2, 0);

            FeatureAsset featureAsset1 = FeatureAsset.FromFeature(feature1);

            // Basic test. Make sure all sections are present in FeatureAsset.
            // FA uses a 2x grid, so we multiply all inputs by 2 to verify.

            ValidateSection(featureAsset1, new Vector2Int(0, 0));
            ValidateSection(featureAsset1, new Vector2Int(1, 0));
            ValidateSection(featureAsset1, new Vector2Int(2, 0));


            /* -1012345
             *  o|o|o|o
             *  -X-X-X-
             *  o|o|o|o
             */

            // Middle
            ValidateExternalLink(featureAsset1, new Vector2Int(-1, 0));
            ValidateInternalLink(featureAsset1, new Vector2Int(1, 0)); // Should be internal
            ValidateInternalLink(featureAsset1, new Vector2Int(3, 0)); // Should be internal
            ValidateExternalLink(featureAsset1, new Vector2Int(5, 0));

            // Top row
            ValidateExternalLink(featureAsset1, new Vector2Int(0, 1));
            ValidateExternalLink(featureAsset1, new Vector2Int(2, 1));
            ValidateExternalLink(featureAsset1, new Vector2Int(4, 1));

            // Bottom row
            ValidateExternalLink(featureAsset1, new Vector2Int(0, -1));
            ValidateExternalLink(featureAsset1, new Vector2Int(2, -1));
            ValidateExternalLink(featureAsset1, new Vector2Int(4, -1));

            // Invalid links
            ValidateMissingLink(featureAsset1, new Vector2Int(-1, 1));
            ValidateMissingLink(featureAsset1, new Vector2Int(1, 1));
            ValidateMissingLink(featureAsset1, new Vector2Int(3, 1));
            ValidateMissingLink(featureAsset1, new Vector2Int(5, 1));
            ValidateMissingLink(featureAsset1, new Vector2Int(-1, -1));
            ValidateMissingLink(featureAsset1, new Vector2Int(1, -1));
            ValidateMissingLink(featureAsset1, new Vector2Int(3, -1));
            ValidateMissingLink(featureAsset1, new Vector2Int(5, -1));
        }
Exemplo n.º 14
0
        public void CanConvertFromFeature_Diagonal()
        {
            // Feature is a diagonal line. Shouldn't have a link on the diagonal.
            Feature feature = new Feature();

            feature.Add(0, 0);
            feature.Add(1, 1);

            FeatureAsset featureAsset = FeatureAsset.FromFeature(feature);

            ValidateMissingLink(featureAsset, new Vector2Int(1, 1));

            // More tests should go here
        }
Exemplo n.º 15
0
 public static void AddTearDownSystems(this Feature feature, params ITearDownSystem[] systems)
 {
     foreach (var system in systems)
     {
         feature.Add(system);
     }
 }
Exemplo n.º 16
0
 public static void AddCleanupSystems(this Feature feature, params ICleanupSystem[] systems)
 {
     foreach (var system in systems)
     {
         feature.Add(system);
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Converts this Editor FeatureAsset into a Generation Feature.
        ///
        /// There may be fewer connections in the output of this compared to a
        /// FeatureAsset made from an input Feature. This is because FeatureAsset
        /// aggressively prunes connections that do not exist in the structure.
        /// </summary>
        /// <returns>A new feature.</returns>
        public Feature ToFeature()
        {
            Feature feature = new Feature();

            foreach (KeyValuePair <Vector2Int, Section> feSection in sections)
            {
                Connection internalConnections = Connection.None;
                Connection externalConnections = Connection.None;
                for (int i = 0; i < dirVectors.Length; i++)
                {
                    Vector2Int adjPos = feSection.Key + dirVectors[i];
                    if (TryGetLink(adjPos, out Link link))
                    {
                        if (link.open)
                        {
                            internalConnections |= dirConnections[i];
                        }

                        if (link.external)
                        {
                            externalConnections |= dirConnections[i];
                        }
                    }
                }

                Vector2Int position = new Vector2Int(feSection.Key.x / GRID_DENSITY, feSection.Key.y / GRID_DENSITY);
                feature.Add(position, internalConnections, feSection.Value.variant, externalConnections);
            }
            return(feature);
        }
Exemplo n.º 18
0
 public static void AddInitializeSystems(this Feature feature, params IInitializeSystem[] systems)
 {
     foreach (var system in systems)
     {
         feature.Add(system);
     }
 }
Exemplo n.º 19
0
    static public void Main(string[] args)
    {
        var binaries = new Feature("MyApp Binaries", "Application binaries");
        var docs     = new Feature("MyApp Documentation");
        var tuts     = new Feature("MyApp Tutorial");

        docs.Add(tuts);
        binaries.Add(docs);

        var project =
            new Project("MyProduct",
                        new Dir(@"%ProgramFiles%\My Company\My Product",
                                new File(binaries, @"Files\Bin\MyApp.exe"),
                                new Dir(@"Docs\Manual",
                                        new File(docs, @"Files\Docs\Manual.txt"),
                                        new File(tuts, @"Files\Docs\Tutorial.txt"))));

        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
        project.UI   = WUI.WixUI_FeatureTree;

        project.DefaultFeature = binaries; //this line is optional

        project.PreserveTempFiles = true;

        project.BuildMsi();
    }
Exemplo n.º 20
0
    static public void Main(string[] args)
    {
        // Note you can detect at runtime if the feature hs been marked for installation by using condition
        // like this Condition.Create("ADDLOCAL >< \"your_feature_name\"")

        var binaries = new Feature("MyApp Binaries", "Application binaries");
        var docs     = new Feature("MyApp Documentation");
        var tuts     = new Feature("MyApp Tutorial");

        docs.Add(tuts);
        binaries.Add(docs);

        var project =
            new Project("MyProduct",
                        new Dir(@"%ProgramFiles%\My Company\My Product",
                                new File(binaries, @"Files\Bin\MyApp.exe"),
                                new Dir(@"Docs\Manual",
                                        new File(docs, @"Files\Docs\Manual.txt"),
                                        new File(tuts, @"Files\Docs\Tutorial.txt")),
                                new Dir(docs, "logdocs", new DirPermission("Everyone", GenericPermission.All)),
                                new Dir(tuts, "logtuts", new DirPermission("Everyone", GenericPermission.All))));

        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
        project.UI   = WUI.WixUI_FeatureTree;

        project.DefaultFeature = binaries; //this line is optional

        project.PreserveTempFiles = true;

        project.BuildMsi();
    }
Exemplo n.º 21
0
 public static void AddExecuteSystems(this Feature feature, params IExecuteSystem[] systems)
 {
     foreach (var system in systems)
     {
         feature.Add(system);
     }
 }
Exemplo n.º 22
0
    static public void Main(string[] args)
    {
        var featureA = new Feature("Feature A", "Feature A description");
        var featureB = new Feature("Feature B", "Feature B description");
        var complete = new Feature("Complete");

        complete.Add(featureA)
        .Add(featureB);

        var project =
            new Project("MyMergeModuleSetup",
                        new MediaTemplate {
            CompressionLevel = CompressionLevel.none, EmbedCab = false
        },
                        new Dir(@"%ProgramFiles%\My Company",
                                // new File(featureA, @"Files\MainFile.txt"),
                                new Merge(featureB, @"Files\MyMergeModule.msm"),
                                new Merge(featureB, @"Files\MyMergeModule1.msm")),
                        new EnvironmentVariable("foo", "bar"));

        //must be cleared to work with MediaTemplate
        project.Media.Clear();
        project.DefaultFeature   = complete;
        project.UI               = WUI.WixUI_FeatureTree;
        project.InstallerVersion = 200; //you may want to change it to match MSM module installer version

        project.PreserveTempFiles = true;

        project.BuildMsi();
    }
        public override Systems CreateUpdateSystems(IContexts contexts1)
        {
            var contexts          = contexts1 as Contexts;
            var sessionObjects    = contexts.session.commonSession;
            var entityIdGenerator = sessionObjects.EntityIdGenerator;


            _gameModule = new CompositeGameModule();

            _gameModule.AddModule(new ServerPlayerModule(contexts));
            //if (GameRules.IsChicken(contexts.session.commonSession.RoomInfo.ModeId))
            //{
            _gameModule.AddModule(new ServerEntityInitModule(contexts));
            //}

            IHitBoxEntityManager hitBoxEntityManager = new HitBoxEntityManager(contexts, true);
            var SnapshotSelector =
                contexts.session.serverSessionObjects.SnapshotSelector;
            ICompensationWorldFactory factory =
                new ServerCompensationWorldFactory(SnapshotSelector, hitBoxEntityManager);

            _gameModule.AddModule(new UserCmdGameModule(contexts, factory,
                                                        new BulletHitHandler(contexts, entityIdGenerator, room.PlayerDamager),
                                                        new MeleeHitHandler(room.PlayerDamager),
                                                        new ThrowingHitHandler(room.PlayerDamager), sessionObjects,
                                                        MotorsFactory.CraeteMotors(contexts, SingletonManager.Get <CameraConfigManager>().Config)));
            _gameModule.AddModule(new ServerPostPredictionModule(contexts));
            _gameModule.AddModule(new ServerVehicleModule(contexts,
                                                          contexts.session.serverSessionObjects.VehicleTimer));
            _gameModule.AddModule(new ServerGamePlayModule(contexts, room));
            _gameModule.AddModule(
                new ServerSceneObjectModule(contexts, this, sessionObjects.EquipmentEntityIdGenerator));

            IServerUserCmdList serrverServerUserCmdList = new ServerServerUserCmdList(contexts);
            IVehicleCmdExecuteSystemHandler vehicleCmdExecuteSystemHandler =
                new ServerVehicleCmdExecuteSystemHandler(contexts);

            var systems = new Feature("GameSessionState");

            systems.Add(new PingSystem(contexts));
            systems.Add(new ServerMainFeature("ServerSystems", _gameModule, serrverServerUserCmdList,
                                              vehicleCmdExecuteSystemHandler, contexts.session.serverSessionObjects.SimulationTimer,
                                              new VehicleExecutionSelector(contexts), sessionObjects, room));

            return(systems);
        }
Exemplo n.º 24
0
        public override Systems CreateUpdateSystems(IContexts contexts)
        {
            Contexts _contexts = (Contexts)contexts;
            var      systems   = new Feature("ClientOptionLoadState");

            systems.Add(new OptionConfigurationInitModule(this, _contexts.session.commonSession.AssetManager));
            return(systems);
        }
Exemplo n.º 25
0
        public void IsMinimumCorrect()
        {
            Feature feature = new Feature();

            feature.Add(1, 2);
            feature.Add(2, 2);
            feature.Add(3, 2);

            feature.Add(1, 3);
            feature.Add(2, 3);
            feature.Add(3, 3);

            feature.Add(1, 4);
            feature.Add(2, 4);
            feature.Add(3, 4);

            // Basic true statements
            Assert.AreEqual(1, feature.MinX);
            Assert.AreEqual(2, feature.MinY);
            Assert.AreEqual(3, feature.MaxX);
            Assert.AreEqual(4, feature.MaxY);

            /*
             * Note the four bounding corners are as follows:
             *
             * (1,4) - (3,4)
             *   |       |
             * (1,2) - (3,2)
             *
             * When we get the minimum under different rotations, we want the
             * new bottom-left corner. This maps to the Nth corner starting from
             * the bottom-left corner, going counterclockwise- i.e., bottom-left,
             * then bottom-right, etc. N is the same as the rotation amount.
             */

            Vector2Int bottomLeft  = new Vector2Int(1, 2);
            Vector2Int bottomRight = new Vector2Int(3, 2);
            Vector2Int topLeft     = new Vector2Int(1, 4);
            Vector2Int topRight    = new Vector2Int(3, 4);

            // Check the 0 rotation case
            Assert.AreEqual(bottomLeft, Feature.Rotate(new Vector2Int(feature.MinX, feature.MinY), 0));
            Assert.AreEqual(bottomLeft, feature.RotatedMin(0));
            Assert.AreEqual(Feature.Rotate(bottomLeft, 0), feature.RotatedMin(0));

            // Check the other rotations
            Assert.AreEqual(Feature.Rotate(bottomRight, 1), feature.RotatedMin(1));
            Assert.AreEqual(Feature.Rotate(topRight, 2), feature.RotatedMin(2));
            Assert.AreEqual(Feature.Rotate(topLeft, 3), feature.RotatedMin(3));
        }
Exemplo n.º 26
0
        public void CanConnectBasic()
        {
            Labrys.Generation.Grid rawGrid = new Labrys.Generation.Grid();
            rawGrid[0, 0] = Section.Default();

            // Wrap the raw grid in a readonly version
            ReadOnlyGrid grid = new ReadOnlyGrid(rawGrid);

            // 3x1 feature
            Feature feature = new Feature();

            feature.Add(0, 0);
            feature.Add(1, 0);
            feature.Add(2, 0);

            //Assert.True(feature.CanConnect(grid, Vector2Int.zero));
            List <Feature.Configuration> configurations = feature.CanConnect(grid, Vector2Int.zero);
        }
Exemplo n.º 27
0
        public override Systems CreateUpdateSystems(IContexts contexts)
        {
            Contexts _contexts = (Contexts)contexts;
            var      systems   = new Feature("ClientPreLoadState");

            systems.Add(new PreloadFeature("ClientPreLoadState", CreateSystems(_contexts, this), _contexts.session.commonSession));

            return(systems);
        }
Exemplo n.º 28
0
        public override Systems CreateUpdateSystems(IContexts contexts)
        {
            Contexts _contexts = (Contexts)contexts;

            var systems = new Feature("ProfilePreparationState");

            systems.Add(new ProfilePreparationFeature("ProfilePreparationState", CreateSystems(_contexts), _contexts.session.commonSession));

            return(systems);
        }
Exemplo n.º 29
0
        public override Systems CreateUpdateSystems(IContexts contexts)
        {
            var systems       = new Feature("MapLoadState");
            var contextsImpl  = contexts as Contexts;
            var commonSession = contextsImpl.session.commonSession;

            systems.Add(new SceneResourceLoadingFeature("SceneResourceLoading", CreateSystems(contextsImpl),
                                                        commonSession));
            return(systems);
        }
Exemplo n.º 30
0
        public void CanConvertToFromFeature()
        {
            Feature feature1 = new Feature();

            feature1.Add(0, 0);
            feature1.Add(1, 0);
            feature1.Add(2, 0);

            FeatureAsset featureAsset1 = FeatureAsset.FromFeature(feature1);
            Feature      testFeature1  = featureAsset1.ToFeature();

            // Basic test. All input positions should be present in output
            Assert.Contains(new Vector2Int(0, 0), testFeature1.Elements.Keys);
            Assert.Contains(new Vector2Int(1, 0), testFeature1.Elements.Keys);
            Assert.Contains(new Vector2Int(2, 0), testFeature1.Elements.Keys);

            // Basic test. Ensure bounds are unchanged
            Assert.AreEqual(feature1.MaxX, testFeature1.MaxX);
            Assert.AreEqual(feature1.MaxY, testFeature1.MaxY);
            Assert.AreEqual(feature1.MinX, testFeature1.MinX);
            Assert.AreEqual(feature1.MinY, testFeature1.MinY);


            // Harder test. Conversion of Feature -> FeatureAsset -> Feature does not obey identity property.
            // All connections at the end will be present in the original, but additionally,
            // they will be restricted based on FeatureAsset retention rules.
            //
            // Thus, we test FeatureAsset retention rules separately, and ensure that
            // FeatureAfter.connections & FeatureBefore.connections == FeatureAfter.connections
            // to be sure that no connections are ever dropped.
            foreach (KeyValuePair <Vector2Int, Labrys.Generation.Section> kvp in testFeature1.Elements)
            {
                Labrys.Generation.Section orig = feature1.Elements[kvp.Key];
                Labrys.Generation.Section conv = kvp.Value;

                // Some connections may be lost. Ensure no new ones are added.
                Assert.AreEqual(orig.externalConnections & conv.externalConnections, conv.externalConnections);
                Assert.AreEqual(orig.internalConnections & conv.internalConnections, conv.internalConnections);

                // Make sure variants are unchanged.
                Assert.AreEqual(orig.GetVariant(), conv.GetVariant());
            }
        }
Exemplo n.º 31
0
        public void CanPlaceWithRotationAndOffset()
        {
            Labrys.Generation.Grid rawGrid = new Labrys.Generation.Grid();
            rawGrid[0, 0] = Section.Default();

            // Wrap the raw grid in a readonly version
            ReadOnlyGrid grid = new ReadOnlyGrid(rawGrid);

            // 3x1 feature, but offset.
            // With normalization, should be same as CanPlaceWithRotation; the only difference is
            // that the local offset needs to be different to align with the input coordinates.
            Feature feature = new Feature();

            feature.Add(5, 3);
            feature.Add(6, 3);
            feature.Add(7, 3);

            // Basic tests for placement
            Assert.False(feature.CanPlace(grid, new Vector2Int(-2, 0), new Vector2Int(5, 3), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(-1, 0), new Vector2Int(5, 3), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(5, 3), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(6, 3), 0));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(6, 3), 0));

            // Rotated cases
            Assert.True(feature.CanPlace(grid, new Vector2Int(0, -2), new Vector2Int(5, 3), 1));
            Assert.True(feature.CanPlace(grid, new Vector2Int(0, -1), new Vector2Int(5, 3), 1));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 1), new Vector2Int(5, 3), 1));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 2), new Vector2Int(5, 3), 1));
            Assert.True(feature.CanPlace(grid, new Vector2Int(0, 3), new Vector2Int(5, 3), 1));

            Assert.False(feature.CanPlace(grid, new Vector2Int(2, 0), new Vector2Int(5, 3), 2));
            Assert.False(feature.CanPlace(grid, new Vector2Int(1, 0), new Vector2Int(5, 3), 2));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(5, 3), 2));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(6, 3), 2));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, 0), new Vector2Int(7, 3), 2));

            Assert.True(feature.CanPlace(grid, new Vector2Int(0, 2), new Vector2Int(5, 3), 3));
            Assert.True(feature.CanPlace(grid, new Vector2Int(0, 1), new Vector2Int(5, 3), 3));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, -1), new Vector2Int(5, 3), 3));
            Assert.False(feature.CanPlace(grid, new Vector2Int(0, -2), new Vector2Int(5, 3), 3));
            Assert.True(feature.CanPlace(grid, new Vector2Int(0, -3), new Vector2Int(5, 3), 3));
        }
    Systems createEmptySystems()
    {
        var systems1 = new Feature("Empty 1");
        var systems2 = new Feature("Empty 2");
        var systems3 = new Feature("Empty 3");

        systems1.Add(systems2);
        systems2.Add(systems3);

        return new Feature("Empty Systems")
            .Add(systems1);
    }