コード例 #1
0
        private void CollectDataAction(DataTable dt, ModelEngine engine)
        {
            HashSet <string> objectSet = new HashSet <string>();
            HashSet <string> dbLinkSet = new HashSet <string>();

            DataTable objectDt = null;

            if (engine.Inputs.GetItem("AllObjects") != null)
            {
                var experiment = engine.GetExperiment(0);
                if (experiment != null)
                {
                    objectDt = experiment.LoadInput("AllObjects");
                }
            }

            CollectObjectSet(objectDt, objectSet, dbLinkSet);

            string modelName = engine.Name;

            //Inputs
            CollectDataAction(dt, engine.Inputs, objectSet, dbLinkSet, modelName);

            //Outputs
            CollectDataAction(dt, engine.Outputs, objectSet, dbLinkSet, modelName);
        }
コード例 #2
0
        private DataTable CreateDataTable(IExperimentResultItem result)
        {
            DataTable dt = CreateSchema(true);

            ModelEngine engine = result.Model.TargetObject as ModelEngine;

            if (engine == null)
            {
                return(dt);
            }

            ModelEngine parent = engine.Parent ?? engine;

            CollectDataAction(dt, parent);

            if (parent.HasLinkedModels)
            {
                foreach (string fileName in parent.LinkedModels.Values)
                {
                    ModelEngine m = ModelEngine.Load(fileName);
                    if (m == null)
                    {
                        continue;
                    }

                    CollectDataAction(dt, m);
                }
            }

            return(dt);
        }
コード例 #3
0
 public void OnEnable()
 {
     editableObj = (EditableObject)target;
     the         = this;
     editableObj.DrawEventHandlers += new FFMProject.DrawDelegate(OnDraw);
     editableObj.ModelCreator       = ModelCreator;
 }
コード例 #4
0
        public virtual void DirectedTests()
        {
            QueryModel  model  = new QueryModel(_workspace, SerializationFormatKind.Atom, null);
            ModelEngine engine = new ModelEngine(model);

            engine.Options.WeightScheme = WeightScheme.Custom;
            engine.Options.Timeout      = 100;

            engine.RunUntil(delegate()
            {
                return(engine.Models.Actions.AllCovered);
            });

            //engine.RunScenario(model.Actions.Find("From", "Where", " Navigation","Select","Expand"));
            //engine.RunUntil(delegate()
            //{
            //    return model.Actions.Accessed > 4;
            //});

            _query     = model.QueryResult;
            _container = model.ResContainer;
            _pType     = model.ResultType;

            if (_query != null || _pType != null)
            {
                VerifyClient(model);
            }
        }
コード例 #5
0
        public float UpdateHeight(ModelEngine engine)
        {
            Matrix4x4 w2c_tm = engine.camera.worldToCameraMatrix;

            Vector3 [] vThirdDirs = { w2c_tm.GetRow(0), w2c_tm.GetRow(1) };
            int        nThirdIdx  = 0;

            float fDotNearestZero = 1.0f;

            for (int i = 0; i < vThirdDirs.Length; ++i)
            {
                float fDot = Vector3.Dot(floorPlane_.normal, vThirdDirs[i]);
                if (Mathf.Abs(fDot) < fDotNearestZero)
                {
                    fDotNearestZero = fDot;
                    nThirdIdx       = i;
                }
            }

            Vector3 v0 = pivot_;
            Vector3 v1 = pivot_ + floorPlane_.normal;
            Vector2 v2 = pivot_ + vThirdDirs [nThirdIdx];

            helperPlane_ = new Plane(v0, v1, v2);

            Ray   ray = engine.ViewRay();
            float t;

            if (helperPlane_.Raycast(ray, out t))
            {
                return(floorPlane_.GetDistanceToPoint(ray.origin + ray.direction * t));
            }

            return(0);
        }
コード例 #6
0
 public override void OnLMBUp(ModelEngine engine)
 {
     if (phase_ == E4Phases.DrawBase)
     {
         phase_             = E4Phases.RaiseHeight;
         heightManipulator_ = new HeightManipulator(plane_, base_[1]);
         height_            = 0;
     }
 }
コード例 #7
0
        public override void OnLMBDown(ModelEngine engine)
        {
            RaycastHit hit;

            if (engine.Raycast(out hit))
            {
                PlaceSubdividedObj(hit.point, hit.normal, engine.material);
            }
        }
コード例 #8
0
        private void CollectSchemas(DataTable dt, ModelEngine engine)
        {
            string modelName = engine.Name;

            //Inputs
            CollectSchemas(dt, engine.Inputs, modelName, "Inputs");

            //Outputs
            CollectSchemas(dt, engine.Outputs, modelName, "Outputs");
        }
コード例 #9
0
 public override void OnMouseMove(ModelEngine engine)
 {
     if (phase_ == E4Phases.PlaceFirstSpot)
     {
         engine.HitPos(out cursor_, cursor_);
     }
     else if (phase_ == E4Phases.RaiseHeight)
     {
         height_ = Mathf.Clamp(heightManipulator_.UpdateHeight(engine), 0, 100.0f);
         UpdateModel();
     }
 }
コード例 #10
0
        public override void OnMouseDrag(ModelEngine engine)
        {
            if (phase_ == E4Phases.DrawBase)
            {
                float t;
                Ray   ray = engine.ViewRay();
                if (plane_.Raycast(ray, out t))
                {
                    base_[1] = cursor_ = ray.origin + ray.direction * t;
                }

                UpdateModel();
            }
        }
コード例 #11
0
 /// <summary>
 /// Loads all content for the game, and starts the systems.
 /// </summary>
 /// <param name="sender">Irrelevant.</param>
 /// <param name="e">Irrelevant.</param>
 private void Window_Load(object sender, EventArgs e)
 {
     SysConsole.Output(OutputType.INIT, "GameClient starting load sequence...");
     GL.Viewport(0, 0, Window.Width, Window.Height);
     GL.Enable(EnableCap.Texture2D);
     GL.Enable(EnableCap.Blend);
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
     GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
     GL.Disable(EnableCap.CullFace);
     GraphicsUtil.CheckError("GEB - Initial");
     SysConsole.Output(OutputType.INIT, "GameClient loading file helpers...");
     Files = new FileHandler();
     Files.Init();
     SysConsole.Output(OutputType.INIT, "GameClient loading shader helpers...");
     Shaders = new ShaderEngine();
     Shaders.InitShaderSystem();
     SysConsole.Output(OutputType.INIT, "GameClient loading texture helpers...");
     Textures = new TextureEngine();
     Textures.InitTextureSystem(Files);
     GraphicsUtil.CheckError("GEB - Textures");
     SysConsole.Output(OutputType.INIT, "GameClient loading font helpers...");
     GLFonts = new GLFontEngine(Textures, Shaders);
     GLFonts.Init(Files);
     FontSets = new FontSetEngine(GLFonts)
     {
         FixTo = Shaders.ColorMult2DShader
     };
     // TODO: FGE/Core->Languages engine!
     FontSets.Init((subdata) => null, () => Ortho, () => GlobalTickTime);
     GraphicsUtil.CheckError("GEB - Fonts");
     SysConsole.Output(OutputType.INIT, "GameClient loading 2D/UI render helper...");
     MainUI = new ViewUI2D(this);
     SysConsole.Output(OutputType.INIT, "GameEngine loading model engine...");
     Animations = new AnimationEngine();
     Models     = new ModelEngine();
     Models.Init(Animations, this);
     SysConsole.Output(OutputType.INIT, "GameEngine loading render helper...");
     Rendering3D = new Renderer(Textures, Shaders, Models);
     Rendering3D.Init();
     Rendering2D = new Renderer2D(Textures, Shaders);
     Rendering2D.Init();
     SysConsole.Output(OutputType.INIT, "GameClient calling engine load...");
     CurrentEngine.Load();
     SysConsole.Output(OutputType.INIT, "GameClient calling external load event...");
     OnWindowLoad?.Invoke();
     SysConsole.Output(OutputType.INIT, "GameClient is ready and loaded! Starting main game loop...");
     GraphicsUtil.CheckError("GEB - Loaded");
     Loaded = true;
 }
コード例 #12
0
        public bool ModelEngineSave(ModelEngine obj)
        {
            bool retVal = true;
            string procName = (obj.IsNew ? "dbo.OXO_ModelEngine_New" : "dbo.OXO_ModelEngine_Edit");

			using (IDbConnection conn = DbHelper.GetDBConnection())
            {
				try
				{
                    obj.Save(this.CurrentCDSID);

					var para = new DynamicParameters();

					para.Add("@p_Programme_Id", obj.ProgrammeId, dbType: DbType.Int32);
					para.Add("@p_Size", obj.Size, dbType: DbType.String, size: 50);
					para.Add("@p_Cylinder", obj.Cylinder, dbType: DbType.String, size: 50);
					para.Add("@p_Turbo", obj.Turbo, dbType: DbType.String, size: 50);
					para.Add("@p_Fuel_Type", obj.FuelType, dbType: DbType.String, size: 50);
					para.Add("@p_Power", obj.Power, dbType: DbType.String, size: 50);
              //      para.Add("@p_Electrification", obj.Electrification, dbType: DbType.String, size: 50);
					para.Add("@p_Active", obj.Active, dbType: DbType.Boolean);
                    if (obj.IsNew)
                    {
                        para.Add("@p_Created_By", obj.CreatedBy, dbType: DbType.String, size: 8);
                        para.Add("@p_Created_On", obj.CreatedOn, dbType: DbType.DateTime);
                    }
                    para.Add("@p_Updated_By", obj.UpdatedBy, dbType: DbType.String, size: 8);
                    para.Add("@p_Last_Updated", obj.LastUpdated, dbType: DbType.DateTime);
                    para.Add("@p_Id", obj.Id, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);					    					
					conn.Execute(procName, para, commandType: CommandType.StoredProcedure);

					if (obj.Id == 0)
					{
						obj.Id = para.Get<int>("@p_Id");
					}

				}
				catch (Exception ex)
				{
                    Log.Error(ex);
                    throw;
				}
			}

            return retVal;
            
        }
コード例 #13
0
 public override void OnLMBDown(ModelEngine engine)
 {
     if (phase_ == E4Phases.PlaceFirstSpot)
     {
         RaycastHit hit;
         if (engine.Raycast(out hit))
         {
             phase_   = E4Phases.DrawBase;
             base_[0] = base_[1] = hit.point;
             plane_   = new Plane(hit.point, hit.point + new Vector3(0, 0, 1), hit.point + new Vector3(1, 0, 0));
         }
     }
     else if (phase_ == E4Phases.RaiseHeight)
     {
         phase_ = E4Phases.PlaceFirstSpot;
     }
 }
コード例 #14
0
ファイル: QueryModel.cs プロジェクト: zhonli/odata.net
        public virtual void Where()
        {
            AstoriaTestLog.WriteLineIgnore("Calling Where");

            //Sub model - projections
            PredicateModel model  = new PredicateModel(this.Workspace, this.ResContainer, this.property, this.ParentRelKey, this.ResType);
            ModelEngine    engine = new ModelEngine(this.Engine, model);

            engine.Run();

            ExpNode e = model.Result;

            this.ParentRelKey = e as KeyExpression;
            if (null == _parentKey)
            {
                /* no keys for resource type*/
                this.Reload();
                return;
            }

            int i = this.Engine.Options.Random.Next(0, 10);

            if (i % 7 == 0)
            {
                e       = ((KeyExpression)e).Predicate;
                bFilter = true;
            }

            if (e != null)
            {
                if (_query is ScanExpression)
                {
                    _query = ((ScanExpression)_query).Where(e) as PredicateExpression;
                }
                else if (_query is NavigationExpression)
                {
                    _query = ((NavigationExpression)_query).Where(e) as PredicateExpression;
                }

                bWhere  = true;
                IsKey   = true;
                _action = LastAction.Where;
                AstoriaTestLog.WriteLineIgnore(".Where()");
            }
        }
コード例 #15
0
ファイル: QueryModel.cs プロジェクト: zhonli/odata.net
        public void Sort(bool bAsc)
        {
            //Sub model - sort
            SortModel   model  = new SortModel(this._workspace, _fromContainer.BaseType);
            ModelEngine engine = new ModelEngine(this.Engine, model);

            engine.Run();

            PropertyExpression[] ordervalues = model.SortResult;

            if (_query is TopExpression)
            {
                _query = ((TopExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is SkipExpression)
            {
                _query = ((SkipExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is CountExpression)
            {
                _query = ((CountExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is ExpandExpression)
            {
                _query = ((ExpandExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is NavigationExpression)
            {
                _query = ((NavigationExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is PredicateExpression)
            {
                _query = ((PredicateExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is ScanExpression)
            {
                _query = ((ScanExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }

            bSort     = true;
            _action   = LastAction.OrderBy;
            bIsOption = true;
            AstoriaTestLog.WriteLineIgnore(".OrderBy(" + ordervalues.ToString() + ")");
        }
コード例 #16
0
        public ModelEngine ModelEngineGet(int id)
        {
            ModelEngine retVal = null;

			using (IDbConnection conn = DbHelper.GetDBConnection())
			{
				try
				{
					var para = new DynamicParameters();
					para.Add("@p_Id", id, dbType: DbType.Int32);
					retVal = conn.Query<ModelEngine>("dbo.OXO_ModelEngine_Get", para, commandType: CommandType.StoredProcedure).FirstOrDefault();
				}
				catch (Exception ex)
				{
                    Log.Error(ex);
                    throw;
				}
			}

            return retVal;
        }
コード例 #17
0
        public override void Display(ModelEngine engine)
        {
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(cursor_, 0.25f);

            if (phase_ == E4Phases.DrawBase)
            {
                Vector3[] vs = { base_ [0],
                                 new Vector3(base_ [0].x,base_ [0].y,  base_ [1].z),
                                 base_ [1],
                                 new Vector3(base_ [1].x,base_ [0].y,  base_ [0].z) };
                Gizmos.color = Color.red;
                Gizmos.DrawLine(vs[0], vs[1]);
                Gizmos.DrawLine(vs[1], vs[2]);
                Gizmos.DrawLine(vs[2], vs[3]);
                Gizmos.DrawLine(vs[3], vs[0]);
            }
            else if (phase_ == E4Phases.RaiseHeight)
            {
                Gizmos.color = Color.red;
                Gizmos.DrawLine(base_[1], base_[1] + plane_.normal * height_);
            }
        }
コード例 #18
0
ファイル: QueryModel.cs プロジェクト: zhonli/odata.net
        public virtual void From()
        {
            if (RunningUnderScenarioModel)
            {
                _query = Query.From(Exp.Variable(ResContainer));
                _pType = ResContainer.BaseType.ClientClrType;
                AstoriaTestLog.WriteLineIgnore("Query.From(" + ResContainer.Name + ")");
            }
            else
            {
                ScanModel   model  = new ScanModel(_workspace);
                ModelEngine engine = new ModelEngine(this.Engine, model);
                engine.Run();

                this.ResContainer = model.ResultContainer;
                _query            = Query.From(Exp.Variable(model.ResultContainer));
                _pType            = model.ResultContainer.BaseType.ClientClrType;
                AstoriaTestLog.WriteLineIgnore("Query.From(" + model.ResultContainer.Name + ")");
            }


            _action = LastAction.From;
            IsCount = false;
        }
コード例 #19
0
        public virtual void RunModel()
        {
            QueryModel  model  = new QueryModel(_workspace, _kind, null);
            ModelEngine engine = new ModelEngine(model);

            engine.Options.WeightScheme = WeightScheme.Custom;
            engine.Options.Timeout      = 100;

            engine.RunUntil(delegate()
            {
                return(model.Actions.Accessed > 5);
            });


            _query     = model.QueryResult;
            _container = model.ResContainer;
            _pType     = model.ResultType;

            if (_query != null || _pType != null)
            {
                switch (_queryType)
                {
                case "server":
                    VerifyServer(_query);
                    break;

                case "client":
                    VerifyClient(model);
                    break;

                case "linq":
                    VerifyClientLinq(model);
                    break;
                }
            }
        }
コード例 #20
0
 public abstract void OnLMBDown(ModelEngine engine);
コード例 #21
0
 public virtual void Update(ModelEngine engine)
 {
 }
コード例 #22
0
ファイル: ClientBase.cs プロジェクト: BenCat07/Voxalia
        /// <summary>
        /// Called when the window is loading, only to be used by the startup process.
        /// </summary>
        void Window_Load(object sender, EventArgs e)
        {
            SysConsole.Output(OutputType.CLIENTINIT, "Window generated!");
            DPIScale = Window.Width / CVars.r_width.ValueF;
            SysConsole.Output(OutputType.CLIENTINIT, "DPIScale is " + DPIScale + "!");
            SysConsole.Output(OutputType.CLIENTINIT, "Setting up a game engine backend placeholder...");
            FakeEngine();
            SysConsole.Output(OutputType.CLIENTINIT, "Loading base textures...");
            PreInitRendering();
            Textures = new TextureEngine();
            Textures.InitTextureSystem(Files);
            ItemFrame        = Textures.GetTexture("ui/hud/item_frame");
            CWindow.Textures = Textures;
            SysConsole.Output(OutputType.CLIENTINIT, "Loading shaders...");
            Shaders    = new ShaderEngine();
            GLVendor   = GL.GetString(StringName.Vendor);
            GLVersion  = GL.GetString(StringName.Version);
            GLRenderer = GL.GetString(StringName.Renderer);
            SysConsole.Output(OutputType.CLIENTINIT, "Vendor: " + GLVendor + ", GLVersion: " + GLVersion + ", Renderer: " + GLRenderer);
            if (GLVendor.ToLowerFast().Contains("intel"))
            {
                SysConsole.Output(OutputType.CLIENTINIT, "Disabling good graphics (Appears to be Intel: '" + GLVendor + "')");
                Shaders.MCM_GOOD_GRAPHICS = false;
            }
            Shaders.InitShaderSystem();
            CWindow.Shaders = Shaders;
            Engine.GetShaders();
            GraphicsUtil.CheckError("Load - Shaders");
            SysConsole.Output(OutputType.CLIENTINIT, "Loading animation engine...");
            Animations         = new AnimationEngine();
            CWindow.Animations = Animations;
            SysConsole.Output(OutputType.CLIENTINIT, "Loading model engine...");
            Models = new ModelEngine();
            Models.Init(Animations, CWindow);
            LODHelp        = new ModelLODHelper(this);
            CWindow.Models = Models;
            SysConsole.Output(OutputType.CLIENTINIT, "Loading rendering helper...");
            Rendering = new Renderer(Textures, Shaders, Models);
            Rendering.Init();
            CWindow.Rendering3D = Rendering;
            CWindow.Rendering2D = new Renderer2D(Textures, Shaders);
            CWindow.Rendering2D.Init();
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing load screen...");
            load_screen = Textures.GetTexture("ui/menus/loadscreen");
            Establish2D();
            SWLoading.Start();
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Loading block textures...");
            TBlock = new TextureBlock();
            TBlock.Generate(this, CVars, Textures, false);
            GraphicsUtil.CheckError("Load - Textures");
            SysConsole.Output(OutputType.CLIENTINIT, "Loading fonts...");
            Fonts = new GLFontEngine(Textures, Shaders);
            Fonts.Init(Files);
            FontSets = new FontSetEngine(Fonts);
            FontSets.Init((subdat) => Languages.GetText(Files, subdat), () => Ortho, () => GlobalTickTimeLocal);
            GraphicsUtil.CheckError("Load - Fonts");
            PassLoadScreen();
            CWindow.FontSets = FontSets;
            CWindow.GLFonts  = Fonts;
            SysConsole.Output(OutputType.CLIENTINIT, "Loading general graphics settings...");
            CVars.r_vsync.OnChanged += OnVsyncChanged;
            OnVsyncChanged(CVars.r_vsync, EventArgs.Empty);
            CVars.r_cloudshadows.OnChanged += OnCloudShadowChanged;
            CVars.r_transpll.OnChanged     += OnLLChanged;
            OnLLChanged(CVars.r_transpll, EventArgs.Empty);
            GraphicsUtil.CheckError("Load - General Graphics");
            SysConsole.Output(OutputType.CLIENTINIT, "Loading UI engine...");
            UIConsole.InitConsole(); // TODO: make this non-static
            InitChatSystem();
            PassLoadScreen();
            GraphicsUtil.CheckError("Load - UI");
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing rendering engine...");
            InitRendering();
            GraphicsUtil.CheckError("Load - Rendering");
            SysConsole.Output(OutputType.CLIENTINIT, "Loading particle effect engine...");
            Particles = new ParticleHelper(this)
            {
                Engine = new ParticleEngine(this)
            };
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing mouse and keyboard handlers...");
            KeyHandler.Init();
            Gamepad = new GamePadHandler();
            Gamepad.Init(this);
            PassLoadScreen();
            GraphicsUtil.CheckError("Load - Keyboard/mouse");
            SysConsole.Output(OutputType.CLIENTINIT, "Building the sound system...");
            Sounds.Init(Engine);
            GraphicsUtil.CheckError("Load - Sound");
            SysConsole.Output(OutputType.CLIENTINIT, "Building game world...");
            BuildWorld();
            PassLoadScreen();
            GraphicsUtil.CheckError("Load - World");
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing networking...");
            Network = new NetworkBase(this);
            RegisterDefaultEntityTypes();
            GraphicsUtil.CheckError("Load - Net");
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Loading Voxel computer...");
            try
            {
                VoxelComputer = new VoxelComputeEngine();
                VoxelComputer.Init(this);
            }
            catch (Exception ex)
            {
                SysConsole.Output(ex);
            }
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Playing background music...");
            BackgroundMusic();
            CVars.a_musicvolume.OnChanged += OnMusicVolumeChanged;
            CVars.a_musicpitch.OnChanged  += OnMusicPitchChanged;
            CVars.a_music.OnChanged       += OnMusicChanged;
            CVars.a_echovolume.OnChanged  += OnEchoVolumeChanged;
            OnEchoVolumeChanged(null, null);
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Setting up screens...");
            TheMainMenuScreen         = new MainMenuScreen(this);
            TheGameScreen             = new GameScreen(this);
            TheSingleplayerMenuScreen = new SingleplayerMenuScreen(this);
            TheLoadScreen             = new LoadScreen(this);
            CScreen = TheMainMenuScreen;
            SysConsole.Output(OutputType.CLIENTINIT, "Trying to grab RawGamePad...");
            try
            {
                RawGamePad = new XInput();
            }
            catch (Exception ex)
            {
                SysConsole.Output(OutputType.CLIENTINIT, "Failed to grab RawGamePad: " + ex.Message);
            }
            SysConsole.Output(OutputType.CLIENTINIT, "Preparing inventory...");
            InitInventory();
            PassLoadScreen();
            SysConsole.Output(OutputType.CLIENTINIT, "Creating sky...");
            CreateSkyBox();
            SysConsole.Output(OutputType.CLIENTINIT, "Requesting a menu server...");
            LocalServer?.ShutDown();
            LocalServer = new Server(28009)
            {
                IsMenu = true
            };                                                 // TODO: Grab first free port?
            Object locky = new Object();
            bool   ready = false;

            Schedule.StartAsyncTask(() =>
            {
                LocalServer.StartUp("menu", () =>
                {
                    lock (locky)
                    {
                        ready = true;
                    }
                });
            });
            while (true)
            {
                lock (locky)
                {
                    if (ready)
                    {
                        break;
                    }
                }
                PassLoadScreen();
                Thread.Sleep(50);
            }
            SysConsole.Output(OutputType.CLIENTINIT, "Connecting to a menu server...");
            Network.LastConnectionFailed = false;
            Network.Connect("localhost", "28009", true, null); // TODO: Grab accurate local IP?
            Stopwatch sw = new Stopwatch();

            sw.Start();
            bool annc = false;

            while (true)
            {
                if (Network.LastConnectionFailed)
                {
                    SysConsole.Output(OutputType.CLIENTINIT, "Failed to connect to menu server! Failing!");
                    Window.Close();
                    return;
                }
                if (Network.IsAlive)
                {
                    break;
                }
                sw.Stop();
                long ms = sw.ElapsedMilliseconds;
                sw.Start();
                if (ms > 10000 && !annc)
                {
                    annc = true;
                    SysConsole.Output(OutputType.WARNING, "Taking weirdly long, did something fail?!");
                }
                if (ms > 20000)
                {
                    SysConsole.Output(OutputType.CLIENTINIT, "Timed out while trying to connect to menu server! Failing!");
                    Window.Close();
                    return;
                }
                PassLoadScreen();
                Thread.Sleep(50);
            }
            SysConsole.Output(OutputType.CLIENTINIT, "Showing main menu...");
            ShowMainMenu();
            GraphicsUtil.CheckError("Load - Final");
            SysConsole.Output(OutputType.CLIENTINIT, "Ready and looping!");
        }
コード例 #23
0
 public override void Display(ModelEngine engine)
 {
 }
コード例 #24
0
 public abstract void OnLMBUp(ModelEngine engine);
コード例 #25
0
 public override void OnMouseMove(ModelEngine engine)
 {
 }
コード例 #26
0
        /// <summary>
        /// Starts up and run the server.
        /// </summary>
        /// <param name="game">The game name.</param>
        /// <param name="loaded">The action to fire when the server is loaded.</param>
        public void StartUp(string game, Action loaded = null)
        {
            CurThread = Thread.CurrentThread;
            Files     = new FileHandler();
            GameName  = FileHandler.CleanFileName(game);
            Files.SetSaveDirEarly("server_" + GameName);
            SysConsole.Written += OnConsoleWritten;
            SysConsole.Output(OutputType.INIT, "Launching as new server, this is " + (this == Central ? "" : "NOT ") + "the Central server.");
            SysConsole.Output(OutputType.INIT, "Loading console input handler...");
            ConsoleHandler.Init();
            ConsoleHandler.OnCommandInput += CommandInputHandle;
            SysConsole.Output(OutputType.INIT, "Loading command engine...");
            Commands = new ServerCommands();
            Commands.Init(new ServerOutputter(this), this);
            SysConsole.Output(OutputType.INIT, "Loading CVar engine...");
            CVars = new ServerCVar();
            CVars.Init(this, Commands.Output);
            SysConsole.Output(OutputType.INIT, "Loading default settings...");
            Config   = new FDSSection(Files.ReadText("server_config.fds"));
            Settings = new ServerSettings(this, Config);
            if (Files.Exists("serverdefaultsettings.cfg"))
            {
                string contents = Files.ReadText("serverdefaultsettings.cfg");
                Commands.ExecuteCommands(contents);
            }
            if (Files.Exists("server_eid.txt"))
            {
                cID = long.Parse(Files.ReadText("server_eid.txt") ?? "1");
            }
            SysConsole.Output(OutputType.INIT, "Loading player command engine...");
            PCEngine = new PlayerCommandEngine();
            SysConsole.Output(OutputType.INIT, "Loading permissions engine...");
            PermGroups = new PermissionsGroupEngine()
            {
                TheServer = this
            };
            SysConsole.Output(OutputType.INIT, "Loading item registry...");
            ItemInfos = new ItemInfoRegistry();
            Items     = new ItemRegistry(this);
            Recipes   = new RecipeRegistry()
            {
                TheServer = this
            };
            SysConsole.Output(OutputType.INIT, "Loading model handler...");
            Models = new ModelEngine(this);
            SysConsole.Output(OutputType.INIT, "Loading animation handler...");
            Animations = new AnimationEngine();
            SysConsole.Output(OutputType.INIT, "Preparing networking...");
            Networking = new NetworkBase(this);
            Networking.Init();
            SysConsole.Output(OutputType.INIT, "Loading plugins...");
            Plugins = new PluginManager(this);
            Plugins.Init();
            SysConsole.Output(OutputType.INIT, "Loading scripts...");
            AutorunScripts();
            SysConsole.Output(OutputType.INIT, "Building initial world(s)...");
            foreach (string str in Settings.Worlds)
            {
                LoadWorld(str.ToLowerFast());
            }
            SysConsole.Output(OutputType.INIT, "Preparing block image system...");
            BlockImages = new BlockImageManager();
            BlockImages.Init(this);
            loaded?.Invoke();
            SysConsole.Output(OutputType.INIT, "Ticking...");
            // Tick
            double    TARGETFPS    = 30d;
            Stopwatch Counter      = new Stopwatch();
            Stopwatch DeltaCounter = new Stopwatch();

            DeltaCounter.Start();
            double TotalDelta   = 0;
            double CurrentDelta = 0d;
            double TargetDelta  = 0d;
            int    targettime   = 0;

            try
            {
                while (true)
                {
                    // Update the tick time usage counter
                    Counter.Reset();
                    Counter.Start();
                    // Update the tick delta counter
                    DeltaCounter.Stop();
                    // Delta time = Elapsed ticks * (ticks/second)
                    CurrentDelta = ((double)DeltaCounter.ElapsedTicks) / ((double)Stopwatch.Frequency);
                    // Begin the delta counter to find out how much time is /really/ slept+ticked for
                    DeltaCounter.Reset();
                    DeltaCounter.Start();
                    // How much time should pass between each tick ideally
                    TARGETFPS = Settings.FPS;
                    if (TARGETFPS < 1 || TARGETFPS > 600)
                    {
                        Settings.FPS = 30;
                        TARGETFPS    = 30;
                    }
                    TargetDelta = (1d / TARGETFPS);
                    // How much delta has been built up
                    TotalDelta += CurrentDelta;
                    while (TotalDelta > TargetDelta * 3)
                    {
                        // Lagging - cheat to catch up!
                        TargetDelta *= 2;
                    }
                    // As long as there's more delta built up than delta wanted, tick
                    while (TotalDelta > TargetDelta)
                    {
                        if (NeedShutdown.IsCancellationRequested)
                        {
                            CurThread = Thread.CurrentThread;
                            ShutDown(ShutdownCallback);
                            return;
                        }
                        else if (NeedsQuickShutdown.IsCancellationRequested)
                        {
                            CurThread = Thread.CurrentThread;
                            ShutDownQuickly();
                            return;
                        }
                        lock (TickLock)
                        {
                            Tick(TargetDelta);
                        }
                        TotalDelta -= TargetDelta;
                    }
                    // The tick is done, stop measuring it
                    Counter.Stop();
                    // Only sleep for target milliseconds/tick minus how long the tick took... this is imprecise but that's okay
                    targettime = (int)((1000d / TARGETFPS) - Counter.ElapsedMilliseconds);
                    // Only sleep at all if we're not lagging
                    if (targettime > 0)
                    {
                        // Try to sleep for the target time - very imprecise, thus we deal with precision inside the tick code
                        Thread.Sleep(targettime);
                    }
                }
            }
            catch (ThreadAbortException)
            {
                return;
            }
        }
コード例 #27
0
 public abstract void OnMouseDrag(ModelEngine engine);
コード例 #28
0
        /// <summary>
        /// Called when the window is loading, only to be used by the startup process.
        /// </summary>
        void Window_Load(object sender, EventArgs e)
        {
            SysConsole.Output(OutputType.INIT, "Window generated!");
            DPIScale = Window.Width / CVars.r_width.ValueF;
            SysConsole.Output(OutputType.INIT, "DPIScale is " + DPIScale + "!");
            SysConsole.Output(OutputType.INIT, "Loading base textures...");
            PreInitRendering();
            Textures = new TextureEngine();
            Textures.InitTextureSystem(this);
            ItemFrame = Textures.GetTexture("ui/hud/item_frame");
            SysConsole.Output(OutputType.INIT, "Loading shaders...");
            Shaders  = new ShaderEngine();
            GLVendor = GL.GetString(StringName.Vendor);
            CVars.s_glvendor.Value = GLVendor;
            GLVersion = GL.GetString(StringName.Version);
            CVars.s_glversion.Value = GLVersion;
            GLRenderer = GL.GetString(StringName.Renderer);
            CVars.s_glrenderer.Value = GLRenderer;
            SysConsole.Output(OutputType.INIT, "Vendor: " + GLVendor + ", GLVersion: " + GLVersion + ", Renderer: " + GLRenderer);
            if (GLVendor.ToLowerFast().Contains("intel"))
            {
                SysConsole.Output(OutputType.INIT, "Disabling good graphics (Appears to be Intel: '" + GLVendor + "')");
                Shaders.MCM_GOOD_GRAPHICS = false;
            }
            Shaders.InitShaderSystem(this);
            View3D.CheckError("Load - Shaders");
            SysConsole.Output(OutputType.INIT, "Loading rendering helper...");
            Rendering = new Renderer(Textures, Shaders);
            Rendering.Init();
            SysConsole.Output(OutputType.INIT, "Preparing load screen...");
            Texture load_screen = Textures.GetTexture("ui/menus/loadscreen");

            load_screen.Bind();
            Shaders.ColorMultShader.Bind();
            Establish2D();
            Rendering.RenderRectangle(0, 0, Window.Width, Window.Height);
            Window.SwapBuffers();
            SysConsole.Output(OutputType.INIT, "Loading block textures...");
            TBlock = new TextureBlock();
            TBlock.Generate(this, CVars, Textures);
            View3D.CheckError("Load - Textures");
            SysConsole.Output(OutputType.INIT, "Loading fonts...");
            Fonts = new GLFontEngine(Shaders);
            Fonts.Init(this);
            FontSets = new FontSetEngine(Fonts);
            FontSets.Init(this);
            View3D.CheckError("Load - Fonts");
            SysConsole.Output(OutputType.INIT, "Loading animation engine...");
            Animations = new AnimationEngine();
            SysConsole.Output(OutputType.INIT, "Loading model engine...");
            Models = new ModelEngine();
            Models.Init(Animations, this);
            SysConsole.Output(OutputType.INIT, "Loading general graphics settings...");
            CVars.r_vsync.OnChanged += onVsyncChanged;
            onVsyncChanged(CVars.r_vsync, null);
            CVars.r_cloudshadows.OnChanged += onCloudShadowChanged;
            View3D.CheckError("Load - General Graphics");
            SysConsole.Output(OutputType.INIT, "Loading UI engine...");
            UIConsole.InitConsole(); // TODO: make this non-static
            InitChatSystem();
            View3D.CheckError("Load - UI");
            SysConsole.Output(OutputType.INIT, "Preparing rendering engine...");
            InitRendering();
            View3D.CheckError("Load - Rendering");
            SysConsole.Output(OutputType.INIT, "Loading particle effect engine...");
            Particles = new ParticleHelper(this)
            {
                Engine = new ParticleEngine(this)
            };
            SysConsole.Output(OutputType.INIT, "Preparing mouse, keyboard, and gamepad handlers...");
            KeyHandler.Init();
            GamePadHandler.Init();
            View3D.CheckError("Load - Keyboard/mouse");
            SysConsole.Output(OutputType.INIT, "Building the sound system...");
            Sounds = new SoundEngine();
            Sounds.Init(this, CVars);
            View3D.CheckError("Load - Sound");
            SysConsole.Output(OutputType.INIT, "Building game world...");
            BuildWorld();
            View3D.CheckError("Load - World");
            SysConsole.Output(OutputType.INIT, "Preparing networking...");
            Network = new NetworkBase(this);
            RegisterDefaultEntityTypes();
            View3D.CheckError("Load - Net");
            SysConsole.Output(OutputType.INIT, "Playing background music...");
            BackgroundMusic();
            CVars.a_musicvolume.OnChanged += onMusicVolumeChanged;
            CVars.a_musicpitch.OnChanged  += onMusicPitchChanged;
            CVars.a_music.OnChanged       += onMusicChanged;
            CVars.a_echovolume.OnChanged  += OnEchoVolumeChanged;
            OnEchoVolumeChanged(null, null);
            SysConsole.Output(OutputType.INIT, "Setting up screens...");
            TheMainMenuScreen         = new MainMenuScreen(this);
            TheGameScreen             = new GameScreen(this);
            TheSingleplayerMenuScreen = new SingleplayerMenuScreen(this);
            SysConsole.Output(OutputType.INIT, "Preparing inventory...");
            InitInventory();
            SysConsole.Output(OutputType.INIT, "Showing main menu...");
            ShowMainMenu();
            SysConsole.Output(OutputType.INIT, "Trying to grab RawGamePad...");
            try
            {
                RawGamePad = new XInput();
            }
            catch (Exception ex)
            {
                SysConsole.Output(OutputType.INIT, "Failed to grab RawGamePad: " + ex.Message);
            }
            View3D.CheckError("Load - Final");
            SysConsole.Output(OutputType.INIT, "Ready and looping!");
        }
コード例 #29
0
 public abstract void Display(ModelEngine engine);
コード例 #30
0
 public abstract void OnMouseMove(ModelEngine engine);