Exemplo n.º 1
0
        private void StartNewSandbox()
        {
            MyLog.Default.WriteLine("StartNewSandbox - Start");

            GetSettingsFromControls();
            if (!MySteamWorkshop.CheckLocalModsAllowed(m_mods, m_settings.OnlineMode == MyOnlineModeEnum.OFFLINE))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            MySteamWorkshop.DownloadModsAsync(m_mods, delegate(bool success, string mismatchMods)
            {
                if (success || (m_settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(m_mods))
                {
                    MyGuiScreenLoadSandbox.CheckMismatchmods(mismatchMods, callback : delegate(VRage.Game.ModAPI.ResultEnum val)
                    {
                        MyScreenManager.RemoveAllScreensExcept(null);

                        if (AsteroidAmount < 0)
                        {
                            MyWorldGenerator.SetProceduralSettings(AsteroidAmount, m_settings);
                            m_asteroidAmount = 0;
                        }

                        MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Custom);

                        MyGuiScreenGamePlay.StartLoading(delegate
                        {
                            MySession.Start(
                                m_nameTextbox.Text,
                                GetDescription(),
                                GetPassword(),
                                m_settings,
                                m_mods,
                                new MyWorldGenerator.Args()
                            {
                                AsteroidAmount = this.AsteroidAmount,
                                Scenario       = (m_scenarioTypesGroup.SelectedButton as MyGuiControlScenarioButton).Scenario
                            }
                                );
                        });
                    });
                }
                else
                {
                    if (MySteam.IsOnline)
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                                   messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                                   buttonType: MyMessageBoxButtonsType.OK));
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                                   messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline),
                                                   buttonType: MyMessageBoxButtonsType.OK));
                    }
                }
                MyLog.Default.WriteLine("StartNewSandbox - End");
            });
        }
Exemplo n.º 2
0
        public static void LoadMission(string sessionPath, bool multiplayer, MyOnlineModeEnum onlineMode, short maxPlayers)
        {
            MyLog.Default.WriteLine("LoadSession() - Start");
            MyLog.Default.WriteLine(sessionPath);

            ulong checkpointSizeInBytes;
            var   checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes);

            var persistentEditMode = checkpoint.Settings.ScenarioEditMode;

            checkpoint.Settings.OnlineMode       = onlineMode;
            checkpoint.Settings.MaxPlayers       = maxPlayers;
            checkpoint.Settings.Scenario         = true;
            checkpoint.Settings.GameMode         = MyGameModeEnum.Survival;
            checkpoint.Settings.ScenarioEditMode = false;

            if (!MySession.IsCompatibleVersion(checkpoint))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            if (!MySteamWorkshop.CheckLocalModsAllowed(checkpoint.Mods, checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            m_checkpointData = new CheckpointData()
            {
                Checkpoint         = checkpoint,
                CheckpointSize     = checkpointSizeInBytes,
                PersistentEditMode = persistentEditMode,
                SessionPath        = sessionPath,
            };

            if (checkpoint.BriefingVideo != null && checkpoint.BriefingVideo.Length > 0 && !MyFakes.XBOX_PREVIEW)
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionVideo),
                                           messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWatchVideo),
                                           buttonType: MyMessageBoxButtonsType.YES_NO,
                                           callback: OnVideoMessageBox));
            }
            else
            {
                var checkpointData = m_checkpointData.Value;
                m_checkpointData = null;
                LoadMission(checkpointData);
            }
        }
Exemplo n.º 3
0
 private void server_SessionClosed( MySession session, CloseReason value )
 {
     throw new NotImplementedException();
 }
        public static void LoadSingleplayerSession(string sessionPath)
        {
            MyLog.Default.WriteLine("LoadSession() - Start");
            MyLog.Default.WriteLine(sessionPath);

            ulong checkpointSizeInBytes;
            var   checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes);

            if (!MySession.IsCompatibleVersion(checkpoint))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            if (!MySteamWorkshop.CheckLocalModsAllowed(checkpoint.Mods, checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }


            MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success)
            {
                if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods))
                {
                    //Sandbox.Audio.MyAudio.Static.Mute = true;

                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                    // May be called from gameplay, so we must make sure we unload the current game
                    if (MySession.Static != null)
                    {
                        MySession.Static.Unload();
                        MySession.Static = null;
                    }
                    MyGuiScreenGamePlay.StartLoading(delegate
                    {
                        MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Load);
                        MySession.Load(sessionPath, checkpoint, checkpointSizeInBytes);
                    });
                }
                else
                {
                    MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed).ToString());
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                               messageText : MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed),
                                               buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result)
                    {
                        if (MyFakes.QUICK_LAUNCH != null)
                        {
                            MyGuiScreenMainMenu.ReturnToMainMenu();
                        }
                    }));
                }
                MyLog.Default.WriteLine("LoadSession() - End");
            });
        }
Exemplo n.º 5
0
 //客户端连接
 void app_NewSessionConnected(MySession session)
 {
     //Message($"客户端{session.SessionID}已连接");
     session.Send("qqqqq");
 }
Exemplo n.º 6
0
 //帧头*,帧尾#
 void MyServer_NewRequestReceived(MySession session, StringRequestInfo requestInfo)
 {
     SerialPort_DataSend("hello");
     LogHelper.WriteLog(requestInfo.Body);
 }
Exemplo n.º 7
0
 void server_NewSessionConnected(MySession session)
 {
     session.Send("Hello there.");
 }
Exemplo n.º 8
0
 public TaggedTextArray disconnect()
 {
     return((TaggedTextArray)MySession.execute("ConnectionLib", "disconnectAll", new object[] { }));
 }
Exemplo n.º 9
0
 public PersonsTO cprsLaunch(string pwd, string sitecode, string DUZ, string DFN)
 {
     return((PersonsTO)MySession.execute("ConnectionLib", "cprsLaunch", new object[] { pwd, sitecode, DUZ, DFN }));
 }
Exemplo n.º 10
0
 public DataSourceArray connect(string sitelist)
 {
     return((DataSourceArray)MySession.execute("ConnectionLib", "connectToLoginSite", new object[] { sitelist }));
 }
Exemplo n.º 11
0
 public UserTO login(string username, string pwd, string context)
 {
     return((UserTO)MySession.execute("AccountLib", "login", new object[] { username, pwd, context }));
 }
Exemplo n.º 12
0
 public RegionArray getVHA()
 {
     return((RegionArray)MySession.execute("SitesLib", "getVHA", new object[] {}));
 }
Exemplo n.º 13
0
 public SiteArray setupMultiSiteQuery(string appPwd)
 {
     return((SiteArray)MySession.execute("AccountLib", "setupMultiSourcePatientQuery", new object[] { appPwd, "" }));
 }
Exemplo n.º 14
0
 public PatientArray nptLookup(string SSN)
 {
     return((PatientArray)MySession.execute("PatientLib", "nptLookup", new object[] { SSN, "", "", "", "", "", "" }));
 }
Exemplo n.º 15
0
 void StartSandbox(MyMwcSectorIdentifier sector)
 {
     MySession.StartSandbox(sector.Position, sector.UserId);
 }
Exemplo n.º 16
0
 public TaggedPatientArrays match(string target)
 {
     return((TaggedPatientArrays)MySession.execute("PatientLib", "match", new object[] { target }));
 }
Exemplo n.º 17
0
 public PatientArray mpiLookup(string SSN)
 {
     //return (PatientArray)MySession.execute("PatientLib", "mpiLookup", new object[] { SSN, "", "", "", "", "", "" });
     return((PatientArray)MySession.execute("PatientLib", "mpiMatchSSN", new object[] { SSN }));
 }
Exemplo n.º 18
0
 public PatientTO select(string DFN)
 {
     return((PatientTO)MySession.execute("PatientLib", "select", new object[] { DFN }));
 }
Exemplo n.º 19
0
 private void server_SessionClosed(MySession session, CloseReason value)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 20
0
 public TaggedTextArray visit(string pwd, string sitelist, string userSitecode, string userName, string DUZ, string SSN, string context)
 {
     return((TaggedTextArray)MySession.execute("AccountLib", "visitSites", new object[] { pwd, sitelist, userSitecode, userName, DUZ, SSN, context }));
 }
        // Updates spectator position (spring connected to desired position)
        public override void UpdateAfterSimulation()
        {
            Sandbox.Game.Entities.IMyControllableEntity controlledEntity = MySession.ControlledEntity as Sandbox.Game.Entities.IMyControllableEntity;
            if (controlledEntity == null)
            {
                return;
            }

            var headMatrix = controlledEntity.GetHeadMatrix(true);

            if (controlledEntity is MyCharacter)
            {
                var character = controlledEntity as MyCharacter;
                headMatrix = character.Get3rdBoneMatrix(true, true);
            }

            m_targetOrientation = (Matrix)headMatrix.GetOrientation();
            m_target            = headMatrix.Translation;


            //VRageRender.MyRenderProxy.DebugDrawAxis(headMatrix, 1, false);

            UpdateCurrentSpring();

            m_transformedLookAt = Vector3D.Transform(m_lookAt, m_targetOrientation);
            m_desiredPosition   = m_target + m_transformedLookAt;

            //m_position = m_desiredPosition;
            //m_velocity = Vector3.Zero;
            // Calculate spring force
            Vector3D stretch = m_position - m_desiredPosition;

            Vector3D force = -m_currentSpring.Stiffness * stretch - m_currentSpring.Damping * m_velocity;

            force.AssertIsValid();

            // Apply acceleration
            Vector3 acceleration = (Vector3)force / m_currentSpring.Mass;

            m_velocity += acceleration * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
            m_velocity.AssertIsValid();

            // Apply velocity
            if (!Sandbox.Game.Multiplayer.Sync.IsServer)
            {  //We are not able to interpolate camera correctly if position is updated through server
                m_position = m_desiredPosition;
            }
            else
            {
                m_position += m_velocity * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
            }
            m_position.AssertIsValid();

            // Limit backward distance from target
            double backward = Vector3D.Dot((Vector3D)m_targetOrientation.Backward, (m_target - m_position));

            if (backward > -BACKWARD_CUTOFF)
            {
                m_position += (Vector3D)m_targetOrientation.Backward * (backward + BACKWARD_CUTOFF);
            }

            // Roll spring
            Quaternion targetOrientation = Quaternion.CreateFromRotationMatrix(m_targetOrientation);

            // Computes angle difference between current and target orientation
            var angleDifference = (float)Math.Acos(MathHelper.Clamp(Quaternion.Dot(m_orientation, targetOrientation), -1, 1));

            // Normalize angle
            angleDifference = angleDifference > MathHelper.PiOver2 ? MathHelper.Pi - angleDifference : angleDifference;

            // Compute spring physics
            float angleForce = -AngleSpring.Stiffness * angleDifference - AngleSpring.Damping * m_angleVelocity;

            m_angleVelocity += angleForce / AngleSpring.Mass * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
            if (angleDifference > 0)
            {
                float factor = Math.Abs(m_angleVelocity * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS / angleDifference);
                if (angleDifference > MathHelper.PiOver4)
                {
                    factor = Math.Max(factor, 1.0f - MathHelper.PiOver4 / angleDifference);
                }
                factor              = MathHelper.Clamp(factor, 0, 1);
                m_orientation       = Quaternion.Slerp(m_orientation, targetOrientation, factor);
                m_orientationMatrix = Matrix.CreateFromQuaternion(m_orientation);
            }

            if (m_saveSettings)
            {
                MySession.SaveControlledEntityCameraSettings(false);
                m_saveSettings = false;
            }

            ++m_updateCount;
        }
Exemplo n.º 22
0
 public TaggedNoteArrays getNotesWithText(String fromDate, String toDate, int nNotes)
 {
     return((TaggedNoteArrays)MySession.execute("NoteLib", "getNotesWithText", new object[] { fromDate, toDate, nNotes }));
 }
Exemplo n.º 23
0
 //客户端断开
 void app_SessionClosed(MySession session, CloseReason value)
 {
     //Message($"客户端{session.SessionID}已断开,原因:{value.ToString()}");
 }
Exemplo n.º 24
0
 public TaggedProblemArrays getProblemList(string type)
 {
     return((TaggedProblemArrays)MySession.execute("ClinicalLib", "getProblemList", new object[] { type }));
 }
Exemplo n.º 25
0
 protected void btnDeconnexion_Click(object sender, EventArgs e)
 {
     MySession.LogOut();
     Response.Redirect("~/Default.aspx" + MySession.GenerateGetParams());
 }
Exemplo n.º 26
0
 public TaggedMedicationArrays getAllMeds()
 {
     return((TaggedMedicationArrays)MySession.execute("MedsLib", "getAllMeds", new object[] { }));
 }
Exemplo n.º 27
0
 void server_NewSessionConnected( MySession session )
 {
     session.Send( "Hello there." );
 }
Exemplo n.º 28
0
 public TaggedTextArray getOutpatientRxProfile()
 {
     return((TaggedTextArray)MySession.execute("MedsLib", "getOutpatientRxProfile", new object[] { }));
 }
Exemplo n.º 29
0
        public static void PrepPacket(object source, ElapsedEventArgs e)
        {
            lock (SessionManager.SessionList)
            {
                foreach (Session MySession in SessionManager.SessionList)
                {
                    if ((MySession.RdpReport || MySession.RdpMessage) && MySession.ClientFirstConnect)
                    {
                        ///If creating outgoing packet, write this data to new list to minimize writes to session
                        List <byte> OutGoingMessage = new List <byte>();

                        lock (MySession.SessionMessages)
                        {
                            ///Add our SessionMessages to this list
                            OutGoingMessage.AddRange(MySession.SessionMessages);

                            ///Clear client session Message List
                            MySession.SessionMessages.Clear();
                        }
                        Logger.Info("Packing header into packet");
                        ///Add RDPReport if applicable
                        AddRDPReport(MySession, OutGoingMessage);

                        ///Bundle needs to be incremented after every sent packet, seems like a good spot?
                        MySession.IncrementServerBundleNumber();

                        ///Add session ack here if it has not been done yet
                        ///Lets client know we acknowledge session
                        ///Making sure remoteMaster is 1 (client) makes sure we have them ack our session
                        if (!MySession.remoteMaster)
                        {
                            if (MySession.SessionAck == false)
                            {
                                ///To ack session, we just repeat session information as an ack
                                AddSession(MySession, OutGoingMessage);
                            }
                        }

                        ///Adds bundle type
                        AddBundleType(MySession, OutGoingMessage);

                        ///Get Packet Length
                        ushort PacketLength = (ushort)OutGoingMessage.Count();

                        ///Add Session Information
                        AddSession(MySession, OutGoingMessage);

                        ///Add the Session stuff here that has length built in with session stuff
                        AddSessionHeader(MySession, OutGoingMessage, PacketLength);

                        ///Done? Send to CommManagerOut
                        CommManagerOut.AddEndPoints(MySession, OutGoingMessage);
                    }

                    ///No packet needed to respond to client
                    else
                    {
                        Logger.Info("No Packet needed to respond to last message from client");
                    }
                }
            }
        }
Exemplo n.º 30
0
 public TaggedRadiologyReportArrays getRadiologyReports(string fromDate, string toDate, int nrex)
 {
     return((TaggedRadiologyReportArrays)MySession.execute("ClinicalLib", "getRadiologyReports", new object[] { fromDate, toDate, nrex }));
 }
Exemplo n.º 31
0
        // 用户登录
        private string userLogin()
        {
            myJson my = new myJson();

            try
            {
                #region 检测用户名,密码
                string userName = Funcs.Get("userName"); //用户名
                string pwd      = Funcs.Get("pwd");      //密码

                string         strSql = "select su.*,sp.paramsName userTypeName from system_users su inner join system_params sp on su.userType=sp.id where su.userName=@userName and su.password=@pwd";
                SqlParameter[] param  = new SqlParameter[] {
                    new SqlParameter("@userName", SqlDbType.VarChar)
                    {
                        Value = userName
                    },
                    new SqlParameter("@pwd", SqlDbType.VarChar)
                    {
                        Value = Funcs.MD5(pwd)
                    }
                };

                DataTable tb = Utility.SqlHelper.GetDataTable(strSql, param);
                if (tb == null || tb.Rows.Count < 1)
                {
                    my.flag = 0;
                    my.msg  = "用户名或密码错误!";
                    return(JsonConvert.SerializeObject(my));
                }
                if (int.Parse(tb.Rows[0]["userstatus"].ToString()) == 0)
                {
                    my.flag = 0;
                    my.msg  = "您的帐号已暂停使用,请联系管理员!";
                    return(JsonConvert.SerializeObject(my));
                }
                #endregion

                #region 保存用户信息,权限到Session
                string loginUserId = tb.Rows[0]["id"].ToString();
                //防止一个帐号多处登录
                Global.Add(int.Parse(loginUserId), HttpContext.Current.Session.SessionID);


                //保存用户的信息到Session
                MySession.Add("userId", tb.Rows[0]["id"]);
                MySession.Add("userName", tb.Rows[0]["userName"]);
                MySession.Add("userTypeName", tb.Rows[0]["userTypeName"]);
                MySession.Add("trueName", tb.Rows[0]["trueName"]);

                #endregion

                my.flag = 1;
                my.msg  = "登录成功";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "登录失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Exemplo n.º 32
0
        private void TrySpawnBot()
        {
            Vector3D cameraPos, cameraDir;

            if (MySession.GetCameraControllerEnum() == Common.ObjectBuilders.MyCameraControllerEnum.ThirdPersonSpectator || MySession.GetCameraControllerEnum() == Common.ObjectBuilders.MyCameraControllerEnum.Entity)
            {
                var headMatrix = MySession.ControlledEntity.GetHeadMatrix(true, true);
                cameraPos = headMatrix.Translation;
                cameraDir = headMatrix.Forward;
            }
            else
            {
                cameraPos = MySector.MainCamera.Position;
                cameraDir = MySector.MainCamera.WorldMatrix.Forward;
            }

            List <MyPhysics.HitInfo> hitInfos = new List <MyPhysics.HitInfo>();

            MyPhysics.CastRay(cameraPos, cameraPos + cameraDir * 100, hitInfos, MyPhysics.ObjectDetectionCollisionLayer);
            if (hitInfos.Count == 0)
            {
                return;
            }

            MyPhysics.HitInfo?closestValidHit = null;
            foreach (var hitInfo in hitInfos)
            {
                var ent = hitInfo.HkHitInfo.Body.GetEntity();
                if (ent is MyCubeGrid)
                {
                    closestValidHit = hitInfo;
                    break;
                }
                else if (ent is MyVoxelMap)
                {
                    closestValidHit = hitInfo;
                    break;
                }
            }

            if (closestValidHit.HasValue)
            {
                Vector3D position = closestValidHit.Value.Position;
                MyAIComponent.Static.SpawnNewBot(BotToSpawn, position);
            }
        }