Exemplo n.º 1
0
        public void Setup()
        {
            engine    = EngineFactory.CreateEngine();
            consoleUi = new DeveloperConsoleUI(createCommandProvider());

            var visible = true;

            consoleUi.Show();

            engine.AddSimulator(new BasicSimulator(() =>
            {
                if (TW.Graphics.Keyboard.IsKeyPressed(Key.Grave))
                {
                    visible = !visible;
                    if (visible)
                    {
                        consoleUi.Show();
                    }
                    else
                    {
                        consoleUi.Hide();
                    }
                }
                consoleUi.Update();
            }));

            TW.Graphics.SpectaterCamera.EnableUserInput = false;
        }
 public void Initialize(TWEngine game)
 {
     game.AddSimulator(new BarrelShooterSimulator());
     game.AddSimulator(new PhysXSimulator());
     game.AddSimulator(new WorldRenderingSimulator());
     game.AddSimulator(new PhysXDebugRendererSimulator());
 }
Exemplo n.º 3
0
            public ScenarioGame(GodGameOffline offline, TWEngine engine, Internal.Model.World world,
                                TownCenterType townCenterType, TownCenterService townCenterService,
                                MinerType minerType)
            {
                this.world             = world;
                this.townCenterType    = townCenterType;
                this.townCenterService = townCenterService;
                this.minerType         = minerType;
                offline.AddSimulatorsToEngine(engine);

                int  skipFrames    = 0;
                var  scenarioTasks = Run().GetEnumerator();
                bool complete      = false;

                engine.AddSimulator(() =>
                {
                    skipFrames--;
                    if (skipFrames > 0)
                    {
                        return;
                    }
                    if (!scenarioTasks.MoveNext())
                    {
                        complete = true;
                    }

                    if (complete)
                    {
                        return;
                    }

                    skipFrames = scenarioTasks.Current;
                }, "ScenarioSimulator");
            }
Exemplo n.º 4
0
        public void Initialize(TWEngine engine)
        {
            //testPickupSimulator(engine);
            //testTriggerSimulator(engine);
            //testWayPointTrigger(engine);
            //testWorldmatrixAnimation(engine);
            //testLoadLevel(engine);
            //testLevelBuilding(engine);

            //testAddStupidRedHelperMesh(engine);
            //testFirstPersonCamera(engine);

            TW.Graphics.MouseInputDisabled  = true;
            TW.Graphics.Mouse.CursorEnabled = true;

            var fs = new EngineFileSystem(TWDir.Cache.FullName + "\\EngineFS");

            DI.Set <IEngineFilesystem>(fs);
            DI.Set <EngineTestState>(new EngineTestState(fs));
            DI.Set <TestSceneBuilder>(new TestSceneBuilder(DI.Get <EngineTestState>()));
            DI.Set <UISimulator>(new UISimulator());

            cleanData();
            var initializer = new EngineInitializer(DI.Get <EngineTestState>());

            initializer.SetupEngine(engine);
        }
        public void Initialize(TWEngine game)
        {
            game.AddSimulator(new PhysXSimulator());
            game.AddSimulator(new WorldRenderingSimulator());
            game.AddSimulator(new PhysXDebugRendererSimulator());


            var e = new Engine.WorldRendering.Entity
            {
                Mesh        = MeshFactory.Load("Core\\TileSet\\ts001sg001"),
                Visible     = true,
                Solid       = true,
                WorldMatrix = Matrix.Translation(0, 5, 0)
            };

            e = new Engine.WorldRendering.Entity
            {
                Mesh        = MeshFactory.Load("Core\\TileSet\\ts001sg001"),
                Visible     = true,
                Solid       = false,
                WorldMatrix = Matrix.Translation(0, 10, 0)
            };

            e = new Engine.WorldRendering.Entity
            {
                Mesh        = MeshFactory.Load("Core\\Barrel01"),
                Visible     = true,
                Solid       = true,
                Static      = false,
                WorldMatrix = Matrix.Translation(0, 20, 0)
            };
        }
Exemplo n.º 6
0
 public void AddSimulatorsToEngine(TWEngine engine)
 {
     engine.AddSimulator(updateConnectedClients, "Server-UpdateConnectedClientsSim");
     engine.AddSimulator(processClientInputs, "Server-PlayerInputProcessingSim");
     engine.AddSimulator(WorldSimulationService, "Server-WorldSimulationSim");
     engine.AddSimulator(sendGameStateUpdates, "Server-SendStateSim");
     engine.AddSimulator(clearStateChangesSimulator, "Server-ClearChangesSim");
 }
        public static void addCameraLightSimulator(TWEngine engine)
        {

            engine.AddSimulator(new BasicSimulator(() =>
            {
                
            }));
        }
        public void InitializeEngine()
        {
            engine = EngineFactory.CreateEngine();
            engine.DontLoadPlugin = true;

            engine.Initialize();

            EngineFactory.Instance = new EngineContext(engine);

            engine.AddSimulator(new EngineUISimulator());
        }
        public void LoadIntoEngine(TWEngine engine)
        {
            engine.AddSimulator(PlayerMovementSimulator);
            engine.AddSimulator(gameSimulationService);
            engine.AddSimulator(PlayerCameraSimulator);

            engine.AddSimulator(ScatteredRenderingSimulator);
            //engine.AddSimulator(new AudioSimulator());

            TW.Graphics.SpectaterCamera.FarClip = 2000;
        }
        public IRenderingTester(TWEngine engine, IActionScheduler scheduler, ParticlesBoxRenderer particleBoxRenderer)
        {
            this.engine              = engine;
            this.scheduler           = scheduler;
            this.particleBoxRenderer = particleBoxRenderer;

            scheduler.SetCurrentTime(TW.Graphics.TotalRunTime);

            engine.AddSimulator(new BasicSimulator(update));
            engine.AddSimulator(new WorldRenderingSimulator());
        }
Exemplo n.º 11
0
 public void AddSimulatorsToEngine(TWEngine engine)
 {
     engine.AddSimulator(userInputProcessingService, "Client-UserInputProcessingSim");
     engine.AddSimulator(sendPlayerInputs, "Client-PlayerInputsSendingSim");
     engine.AddSimulator(applyServerStateChanges, "Client-applyServerStateChangesSim");
     engine.AddSimulator(uiRenderingService, "Client-UIRenderingSim");
     engine.AddSimulator(developerConsoleService, "Client-DevConsoleSim");
     engine.AddSimulator(simpleWorldRenderer, "Client-WorldRenderingSim");
     engine.AddSimulator(clearStateChangesSimulator, "Client-ClearChangesSim");
     engine.AddSimulator(worldRenderingSimulator, "Client-EngineWorldRenderingSimulator");
 }
        public void Setup()
        {
            engine            = EngineFactory.CreateEngine();
            toolSelectionMenu = new ToolSelectionMenu();

            engine.AddSimulator(new BasicSimulator(() =>
            {
                toolSelectionMenu.ProcessUserInput();
            }));

            TW.Graphics.SpectaterCamera.EnableUserInput = false;
        }
Exemplo n.º 13
0
        public void TestEngineUI()
        {
            var engine = new TWEngine();

            engine.DontLoadPlugin = true;
            engine.Initialize();

            engine.AddSimulator(new EngineUISimulator());
            engine.AddSimulator(new WorldRenderingSimulator());

            engine.Run();
        }
Exemplo n.º 14
0
        public void TestProfiler()
        {
            var game = new TWEngine();

            game.DontLoadPlugin = true;
            game.Initialize();

            game.AddSimulator(new ProfilerSimulator());
            game.AddSimulator(new WorldRenderingSimulator());

            game.Run();
        }
        public void Setup()
        {
            engine            = EngineFactory.CreateEngine();
            textBox           = new DirectInputTextBox();
            textarea          = new Textarea();
            textarea.Position = new Vector2(100, 100);

            engine.AddSimulator(new BasicSimulator(() =>
            {
                textBox.ProcessUserInput(TW.Graphics.Keyboard);
                textarea.Text = textBox.Text;
            }));

            TW.Graphics.SpectaterCamera.EnableUserInput = false;
        }
Exemplo n.º 16
0
        public void TestRaycastEntity()
        {
            var game = new TWEngine();

            game.DontLoadPlugin = true;
            game.Initialize();

            var world = TW.Data.GetSingleton <Engine.WorldRendering.World>();

            game.AddSimulator(new BasicSimulator(delegate
            {
                var rayPos = TW.Graphics.Camera.ViewInverse.xna().Translation.dx();
                var rayDir = TW.Graphics.Camera.ViewInverse.xna().Forward.dx();
                var ray    = new Ray(rayPos, rayDir);
                var result = world.Raycast(ray);
                if (result.IsHit)
                {
                    TW.Graphics.LineManager3D.AddTriangle(result.V1, result.V2,
                                                          result.V3,
                                                          new Color4(Color.Yellow));
                }
            }));

            game.AddSimulator(new WorldRenderingSimulator());

            new Engine.WorldRendering.Entity
            {
                Mesh        = MeshFactory.Load("Core\\Barrel01"),
                Visible     = true,
                Solid       = true,
                Static      = false,
                WorldMatrix = Matrix.Translation(0, 0.5f, 0)
            };
            new Engine.WorldRendering.Entity
            {
                Mesh        = MeshFactory.Load("Core\\Barrel01"),
                Visible     = true,
                Solid       = true,
                Static      = false,
                WorldMatrix = Matrix.Translation(0, 0.5f, 1)
            };

            game.Run();
        }
Exemplo n.º 17
0
        [PersistanceScope] // Data created when starting a test should persist!
        public void RunTestInEngine(TWEngine engine, NUnitTest test)
        {
            var oldContext = EngineFactory.Instance;

            EngineFactory.Instance = new TWEngineContext(engine);

            //TW.Graphics.Form.Hide();

            var runner = new NUnitTestRunner();

            //TODO: runner.Timeout = 10000;
            runner.RunInThisThread(test);

            DI.Get <TestSceneBuilder>().EnsureTestSceneLoaded();

            //TW.Graphics.Form.Show();

            EngineFactory.Instance = oldContext;
        }
Exemplo n.º 18
0
        public void AddSimulatorsToEngine(TWEngine engine)
        {
            //engine.AddSimulator(updateConnectedClients, "Server-UpdateConnectedClientsSim");
            //engine.AddSimulator(processClientInputs, "Server-PlayerInputProcessingSim");

            //engine.AddSimulator(sendGameStateUpdates, "Server-SendStateSim");
            //engine.AddSimulator(clearStateChangesSimulator, "Server-ClearChangesSim");


            engine.AddSimulator(userInputProcessingService, "Client-UserInputProcessingSim");
            engine.AddSimulator(WorldSimulationService, "Server-WorldSimulationSim");
            //engine.AddSimulator(sendPlayerInputs, "Client-PlayerInputsSendingSim");
            //engine.AddSimulator(applyServerStateChanges, "Client-applyServerStateChangesSim");
            engine.AddSimulator(uiRenderingService, "Client-UIRenderingSim");
            engine.AddSimulator(developerConsoleService, "Client-DevConsoleSim");
            engine.AddSimulator(simpleWorldRenderer, "Client-WorldRenderingSim");
            engine.AddSimulator(clearStateChangesSimulator, "Client-ClearChangesSim");
            engine.AddSimulator(worldRenderingSimulator, "Client-EngineWorldRenderingSimulator");
        }
Exemplo n.º 19
0
        private void bootstrap()
        {
            config = TWConfig.Load();
            config.Save();
            if (config.RunTestUI)
            {
                runWinformsTestrunner();
                return;
            }
            if (config.TestMode)
            {
                var obj = createTestClass(config.TestClass);
                runTestMethod(obj, config.TestMethod);
                return;
            }
            // Run engine!
            var engine = new TWEngine();

            engine.Run();
        }
        public void LoadIntoEngine(TWEngine engine)
        {
            TextOutput = new Textarea() { Position = new Vector2(10, 10), Size = new Vector2(300, 200) };
            // Autostops when engine hotloads
            new Thread(generateMeshesJob).Alter(f => f.Name = "GenerateLodMeshes").Alter(f => f.IsBackground = true).Start();
            new Thread(meshBuilderJob).Alter(f => f.Name = "MeshBuildJob1").Alter(f => f.IsBackground = true).Start();
            new Thread(meshBuilderJob).Alter(f => f.Name = "MeshBuildJob2").Alter(f => f.IsBackground = true).Start();
            new Thread(meshBuilderJob).Alter(f => f.Name = "MeshBuildJob3").Alter(f => f.IsBackground = true).Start();

            //TW.Graphics.FixedTimeStepEnabled = true;
            //TW.Graphics.FixedTimeStep = 1 / 10f;
            TW.Graphics.SpectaterCamera.FarClip = 5000;
            engine.AddSimulator(ProcessUserInput, "ProcessUserInput");
            engine.AddSimulator(UpdateQuadtreeClipmaps, "UpdateClipmaps");
            engine.AddSimulator(DrawDebugOutput, "UpdateLines");
            engine.AddSimulator(CreateUpdatedMeshElements, "CreateMeshElements");
            engine.AddSimulator(new WorldRenderingSimulator());
            engine.AddSimulator(new RecordingSimulator());

        }
Exemplo n.º 21
0
        public void AddToEngine(TWEngine engine)
        {
            TW.Graphics.SpectaterCamera.MovementSpeed = 0.5f;
            TW.Graphics.AcquireRenderer().Wireframe = false;
            TW.Graphics.AcquireRenderer().CullMode  = CullMode.Front;

            //foreach (var v in vertices) lines.AddCenteredBox(v * cellSize, cellSize * 0.2f, Color.OrangeRed.dx());

            statsArea = new Textarea()
            {
                Position = new Vector2(10, 10),
                Size     = new Vector2(300, 200)
            };
            textarea = new Textarea()
            {
                Position = new Vector2(10, statsArea.Position.Y + statsArea.Size.Y), Size = new Vector2(200, 200)
            };

            engine.AddSimulator(() =>
            {
                updateRaycastInfo();
                tryPlaceObject();
                tryRemoveObject();


                UpdateDirty();


                drawRaycastInfo();
                drawHermiteInfoForCube((RaycastedPoint / cellSize).ToFloored(), textarea);
                updateStatsArea();
            }, "UserInput");

            engine.AddSimulator(new WorldRenderingSimulator());

            addLinesSimulator(engine, this.lines);

            engine.AddSimulator(CameraLightSimulator);
        }
Exemplo n.º 22
0
        public static void addLinesSimulator(TWEngine engine, LineManager3DLines lines)
        {
            bool visible = false;

            engine.AddSimulator(() =>
            {
                if (TW.Graphics.Keyboard.IsKeyPressed(Key.Z))
                {
                    TW.Graphics.AcquireRenderer().Wireframe = !TW.Graphics.AcquireRenderer().Wireframe;
                }
                if (TW.Graphics.Keyboard.IsKeyPressed(Key.X))
                {
                    visible = !visible;
                }
                if (!visible)
                {
                    return;
                }

                drawLinesWithDepth(lines);
            }, "linerenderer");
        }
 public SimplePausingExample(TWEngine engine)
 {
     this.engine = engine;
 }
Exemplo n.º 24
0
 private void setup()
 {
     engine = new TWEngine();
     engine.DontLoadPlugin = true;
     engine.Initialize();
 }
 public PersistentCodeLoader(TWEngine twEngine)
 {
     this.twEngine = twEngine;
 }
 public void LoadIntoEngine(TWEngine engine)
 {
     engine.AddSimulator(Update, "InteractiveEnvironmentUpdate");
 }
Exemplo n.º 27
0
 public TypeSerializer(TWEngine engine)
 {
     this.engine = engine;
 }
 public RestartCodeLoader(TWEngine twEngine)
 {
     this.twEngine = twEngine;
 }
Exemplo n.º 29
0
 public TWEngineContext(TWEngine engine)
 {
     this.engine = engine;
 }