public override HashSet <IMyReplicable> GetDependencies() { m_dependencies.Clear(); MyPlayerCollection playerCollection = MySession.Static.Players; var connectedPlayers = playerCollection.GetOnlinePlayers(); foreach (var player in connectedPlayers) { if (player.Character == Instance) { var broadcasters = Instance.RadioReceiver.GetRelayedBroadcastersForPlayer(player.Identity.IdentityId); foreach (var broadcaster in broadcasters) { IMyReplicable dep = MyExternalReplicable.FindByObject(broadcaster.Entity); if (dep != null) { m_dependencies.Add(dep.GetParent() ?? dep); } } } } return(m_dependencies); }
protected override void OnHook() { Debug.Assert(MyMultiplayer.Static != null, "Should not get here without multiplayer"); base.OnHook(); m_propertySync = new StateGroups.MyPropertySyncStateGroup(this, Grid.SyncType); if (Sync.IsServer == false) { MyPlayerCollection.UpdateControl(Grid.EntityId); foreach (var block in Instance.CubeBlocks) // CubeBlocks is getter of readonly field m_cubeBlocks, should never be null (but check it!) { if (block.FatBlock is MyCockpit) { // block.FatBlock is not null MyPlayerCollection.UpdateControl(block.FatBlock.EntityId); if (MySession.Static.LocalHumanPlayer != null && MySession.Static.LocalHumanPlayer.Controller != null && MySession.Static.LocalHumanPlayer.Controller.ControlledEntity == block.FatBlock) { MySession.Static.SetCameraController(VRage.Game.MyCameraControllerEnum.Entity, block.FatBlock); break; } } } } Grid.OnBlockAdded += Grid_OnBlockAdded; Grid.OnBlockRemoved += Grid_OnBlockRemoved; }
public override float GetPriority(MyClientInfo state) { if (Grid == null || Grid.Physics == null) { return(0.0f); } float priority = base.GetPriority(state); if (priority == 0.0f) { MyPlayerCollection playerCollection = MySession.Static.Players; var connectedPlayers = playerCollection.GetOnlinePlayers(); foreach (var player in connectedPlayers) { if (player.Client.SteamUserId == state.EndpointId.Value && player.Character != null) { var broadcasters = player.Character.RadioReceiver.GetRelayedBroadcastersForPlayer(player.Identity.IdentityId); foreach (var broadcaster in broadcasters) { var cubeblock = broadcaster.Entity as MyCubeBlock; if (cubeblock != null && cubeblock.CubeGrid == Grid) { return(0.1f); // Minimal priority, update, but not that often } } } } } return(priority); }
private void StartEntitySync() { SeamlessClient.TryShow("Requesting Player From Server"); Sync.Players.RequestNewPlayer(Sync.MyId, 0, MyGameService.UserName, null, realPlayer: true, initialPlayer: true); if (MySession.Static.ControlledEntity == null && Sync.IsServer && !Sandbox.Engine.Platform.Game.IsDedicated) { MyLog.Default.WriteLine("ControlledObject was null, respawning character"); //m_cameraAwaitingEntity = true; MyPlayerCollection.RequestLocalRespawn(); } //typeof(MyGuiScreenTerminal).GetMethod("CreateTabs") MyMultiplayer.Static.OnSessionReady(); MySession.Static.LoadDataComponents(); //MyGuiSandbox.LoadData(false); //MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HUDScreen)); MyRenderProxy.RebuildCullingStructure(); MyRenderProxy.CollectGarbage(); SeamlessClient.TryShow("OnlinePlayers: " + MySession.Static.Players.GetOnlinePlayers().Count); SeamlessClient.TryShow("Loading Complete!"); MyMultiplayer.Static.OnSessionReady(); //Recreate all controls... Will fix weird gui/paint/crap MyGuiScreenHudSpace.Static.RecreateControls(true); }
public override void Handle() { Essentials.Log.Info("Cleaning up identities."); MyPlayerCollection playerCollection = MyAPIGateway.Players as MyPlayerCollection; if (playerCollection == null) { return; } HashSet <long> owners = new HashSet <long>( ); HashSet <MyIdentity> toRemove = new HashSet <MyIdentity>( ); HashSet <IMyEntity> entities = new HashSet <IMyEntity>( ); Wrapper.GameAction(() => MyAPIGateway.Entities.GetEntities(entities, x => x is IMyCubeGrid)); foreach (IMyEntity entity in entities) { var grid = entity as IMyCubeGrid; if (grid == null) { continue; } foreach (long owner in grid.SmallOwners) { owners.Add(owner); } } var myIdentities = playerCollection.GetAllIdentities( ); foreach (MyIdentity identity in myIdentities) { if (!identity.IsDead) { continue; } if (!owners.Contains(identity.IdentityId)) { toRemove.Add(identity); } } int count = toRemove.Count; Wrapper.GameAction(() => { foreach (MyIdentity identity in toRemove) { Essentials.Log.Info($"Removed identity {identity.DisplayName}: {identity.IdentityId}"); playerCollection.RemoveIdentity(identity.IdentityId); } }); Essentials.Log.Info($"Removed {count} identities."); base.Handle(); }
public static string GetPlayerNameOrElse(this MyPlayerCollection self, long playerId, string defaultPlayerName) { if (self.TryGetPlayerById(playerId, out var p)) { return(p.DisplayName); } return(defaultPlayerName); }
private void RespawnShipImmediately(string shipPrefabId) { var identity = Sync.Players.TryGetIdentity(MySession.Static.LocalPlayerId); Debug.Assert(identity != null, "Could not get local player identity! This should not happen!"); bool newPlayer = identity == null || identity.FirstSpawnDone; MyPlayerCollection.RespawnRequest(MySession.Static.LocalCharacter == null, newPlayer, 0, shipPrefabId); CloseScreen(); }
protected override void OnHook() { Debug.Assert(MyMultiplayer.Static != null, "Should not get here without multiplayer"); base.OnHook(); m_propertySync = new MyPropertySyncStateGroup(this, Grid.SyncType); if (Sync.IsServer == false) { MyPlayerCollection.UpdateControl(Grid.EntityId); } }
public static bool TryGetIdentityFromSteamID(this MyPlayerCollection Collection, ulong SteamID, out MyIdentity Player) { Player = Collection.TryGetPlayerIdentity(new MyPlayer.PlayerId(SteamID, 0)); if (Player == null) { return(false); } return(true); }
public virtual void Spawn(Vector3D?spawnPosition, bool spawnedByPlayer) { this.CreatedByPlayer = spawnedByPlayer; MyCharacter controlledEntity = this.m_player.Controller.ControlledEntity as MyCharacter; if ((((controlledEntity != null) && controlledEntity.IsDead) || this.m_player.Identity.IsDead) && !this.m_respawnRequestSent) { this.m_respawnRequestSent = true; MyPlayerCollection.OnRespawnRequest(false, false, 0L, null, spawnPosition, new SerializableDefinitionId?((SerializableDefinitionId)this.BotDefinition.Id), false, this.m_player.Id.SerialId, null, Color.Red); } }
private void OnNewPlayerSuccess(MyPlayer.PlayerId playerId) { if (((playerId.SteamId == Sync.MyId) && (playerId.SerialId != 0)) && Sync.Players.GetPlayerById(playerId).IsRealPlayer) { MyPlayerCollection.RespawnRequest(true, true, 0L, string.Empty, playerId.SerialId, null, Color.Red); int num = this.m_clients.Count + 1; MyVirtualClient item = new MyVirtualClient(new Endpoint(Sync.MyId, (byte)num), CreateClientState(), playerId); this.m_clients.Add(item); EndpointId targetEndpoint = new EndpointId(); Vector3D? position = null; MyMultiplayer.RaiseStaticEvent <int>(x => new Action <int>(MyVirtualClients.OnVirtualClientAdded), num, targetEndpoint, position); } }
private void OnLocalRespawnRequest() { if (MyFakes.SHOW_FACTIONS_GUI) { ulong playerId = MySession.Static.LocalHumanPlayer != null ? MySession.Static.LocalHumanPlayer.Id.SteamId : Sync.MyId; int serialId = MySession.Static.LocalHumanPlayer != null ? MySession.Static.LocalHumanPlayer.Id.SerialId : 0; MyMultiplayer.RaiseStaticEvent(s => RespawnRequest_Implementation, playerId, serialId); } else { MyPlayerCollection.RespawnRequest(MySession.Static.LocalHumanPlayer == null, false, 0, null); } }
public static MyPlayer TryGetPlayerBySteamId(this MyPlayerCollection collection, ulong steamId, int serialId = 0) { long identity = collection.TryGetIdentityId(steamId, serialId); if (identity == 0) { return(null); } if (!collection.TryGetPlayerId(identity, out MyPlayer.PlayerId playerId)) { return(null); } return(collection.TryGetPlayerById(playerId, out MyPlayer player) ? player : null); }
public void Spawn(Vector3D?spawnPosition) { var character = m_player.Controller.ControlledEntity as MyCharacter; if (character != null && character.IsDead || m_player.Identity.IsDead) { if (!m_respawnRequestSent) { m_respawnRequestSent = true; ProfilerShort.Begin("Bot.RespawnRequest"); MyPlayerCollection.RespawnRequest(false, false, 0, null, m_player.Id.SerialId, spawnPosition); ProfilerShort.End(); } } }
private void StartScenario() { if (Sync.IsServer) { ServerStartGameTime = DateTime.UtcNow; } if (m_waitingScreen != null) { MyGuiSandbox.RemoveScreen(m_waitingScreen); m_waitingScreen = null; } GameState = MyState.Running; m_startBattleTime = MySession.Static.ElapsedPlayTime; MyPlayerCollection.RequestLocalRespawn(); }
private void OnLocalRespawnRequest() { if (MyFakes.SHOW_FACTIONS_GUI && !MySession.Static.CreativeMode) { //First check all the Cryo Chambers if (!TryFindCryoChamberCharacter(MySession.LocalHumanPlayer)) { //If nothing was found, go to respawn screen MyGuiSandbox.AddScreen(new MyGuiScreenMedicals()); } } else { MyPlayerCollection.RespawnRequest(MySession.LocalHumanPlayer == null, false, 0, null); } }
public bool CreatePlayer(string playerName, long playerId, ulong steamId, bool safe = true) { try { if (GetFastPlayerIdentityFromPlayerId(playerId) != null) { return(false); } if (GetFastPlayerIdFromSteamId(steamId) != 0) { return(false); } MyPlayerCollection playerCollection = Sync.Players; // This method adds the player to online players, so it's not quite what we want, but the parameters allow us to pull types // This should be replaced by just grabbing playerIdentifierType from elsewhere, but this already took too long MethodInfo createNewPlayerMethod = BaseObject.GetEntityMethod(playerCollection, PlayerMapCreateNewPlayerInternalMethod); Type playerIdentifierType = createNewPlayerMethod.GetParameters()[3].ParameterType.GetElementType(); SandboxGameAssemblyWrapper.Instance.GameAction(() => { // Create Network Client //object networkClient = Activator.CreateInstance(networkClientType, new object[] { steamId }); // Create Identity // Create MyPlayer.PlayerId type object playerIdentifier = Activator.CreateInstance(playerIdentifierType, steamId, 0); // Adding to m_playerIdentityIds should save player to checkpoint //result = BaseObject.InvokeEntityMethod(myPlayerCollection, PlayerMapCreateNewPlayerInternalMethod, new object[] { myIdentity, myNetworkClient, playerName, myPlayerId }); object playerIdentiferDictionary = BaseObject.GetEntityFieldValue(playerCollection, PlayerMapGetSteamItemMappingField); playerIdentiferDictionary.GetType().GetMethod("Add").Invoke(playerIdentiferDictionary, new[] { playerIdentifier, playerId }); }); return(true); } catch (Exception ex) { ApplicationLog.BaseLog.Error(ex); return(false); } }
public override float GetPriority(MyClientInfo state) { if (Grid == null || Grid.Projector != null || Grid.IsPreview) { return(0.0f); } float priority = base.GetPriority(state); if (priority == 0.0f) { MyPlayerCollection playerCollection = MySession.Static.Players; var connectedPlayers = playerCollection.GetOnlinePlayers(); foreach (var player in connectedPlayers) { if (player.Client.SteamUserId == state.EndpointId.Value && player.Character != null) { var broadcasters = player.Character.RadioReceiver.GetRelayedBroadcastersForPlayer(player.Identity.IdentityId); foreach (var broadcaster in broadcasters) { var cubeblock = broadcaster.Entity as MyCubeBlock; if (cubeblock != null && cubeblock.CubeGrid == Grid) { return(0.1f); // Minimal priority, update, but not that often } } } } } if (MyFakes.ENABLE_SENT_GROUP_AT_ONCE) { MyCubeGrid master = MyGridPhysicsStateGroup.GetMasterGrid(Grid); if (master != Grid) { return(MyExternalReplicable.FindByObject(master).GetPriority(state)); } } return(priority); }
public bool RemoveIdentity(long playerId) { try { MyPlayerCollection myPlayerCollection = Sync.Players; object myAllIdentities = BaseObject.GetEntityFieldValue(myPlayerCollection, PlayerMapGetPlayerItemMappingField); bool result = false; SandboxGameAssemblyWrapper.Instance.GameAction(() => { result = (bool)myAllIdentities.GetType().GetMethod("Remove").Invoke(myAllIdentities, new object[] { playerId }); }); return(result); } catch (Exception ex) { ApplicationLog.BaseLog.Error(ex); return(false); } }
public override bool Update(bool hasFocus) { if (m_respawnsTable.RowsCount == 0 && State != MyGuiScreenState.CLOSING && MySession.LocalHumanPlayer != null) { MyPlayerCollection.RespawnRequest(joinGame: true, newPlayer: true, medicalId: 0, shipPrefabId: null); CloseScreen(); } UpdateSpawnShipTimes(); bool retval = base.Update(hasFocus); if (m_selectedRespawnShip != null) { int cooldown = MyRespawnComponent.GetRespawnCooldownSeconds(MySession.LocalHumanPlayer.Id, m_selectedRespawnShip.Id.SubtypeName); if (MyRespawnComponent.IsSynced && cooldown == 0) { RespawnShipImmediately(m_selectedRespawnShip.Id.SubtypeName); } } return(retval); }
private void HandleDeadBot() { const long TIME_TO_RESPAWN = 10; // s const long TIME_TO_REMOVE = 30; // s if (m_deathTimestamp == 0) { m_removeAfterDeath = !(MyAIComponent.BotFactory.CanCreateBotOfType(BotDefinition.BehaviorType, false)); if (m_removeAfterDeath) { m_deathTimestamp = (long)(Stopwatch.GetTimestamp() + (TIME_TO_REMOVE * Stopwatch.Frequency)); } else { m_deathTimestamp = (long)(Stopwatch.GetTimestamp() + (TIME_TO_RESPAWN * Stopwatch.Frequency)); } } else if (Stopwatch.GetTimestamp() > m_deathTimestamp) { if (m_removeAfterDeath) { MyAIComponent.Static.RemoveBot(Player.Id.SerialId); } else { Vector3D spawnPosition = Vector3D.Zero; if (MyAIComponent.BotFactory.GetBotSpawnPosition(BotDefinition.BehaviorType, out spawnPosition)) { MyPlayerCollection.RespawnRequest(false, false, 0, null, Player.Id.SerialId, spawnPosition); m_respawnRequestSent = true; } else { MyAIComponent.Static.RemoveBot(Player.Id.SerialId); } } m_deathTimestamp = 0; } }
public bool RemovePlayer(ulong steamId) { try { MyPlayerCollection playerCollection = Sync.Players; object playerIdentiferDictionary = BaseObject.GetEntityFieldValue(playerCollection, PlayerMapGetSteamItemMappingField); object onlinePlayers = BaseObject.GetEntityFieldValue(playerCollection, PlayerMapPlayerDictionary); Type playerIdentifierType = playerIdentiferDictionary.GetType().GetGenericArguments()[0]; // Create MyPlayer.PlayerId type object playerIdentifier = Activator.CreateInstance(playerIdentifierType, steamId, 0); bool result = false; if ((bool)playerIdentiferDictionary.GetType().GetMethod("ContainsKey").Invoke(playerIdentiferDictionary, new[] { playerIdentifier })) { SandboxGameAssemblyWrapper.Instance.GameAction(() => { result = (bool)playerIdentiferDictionary.GetType().GetMethod("Remove").Invoke(playerIdentiferDictionary, new[] { playerIdentifier }); }); } if ((bool)onlinePlayers.GetType().GetMethod("ContainsKey").Invoke(onlinePlayers, new[] { playerIdentifier })) { SandboxGameAssemblyWrapper.Instance.GameAction(() => { result = result && (bool)onlinePlayers.GetType().GetMethod("Remove").Invoke(onlinePlayers, new[] { playerIdentifier }); }); } return(result); } catch (Exception ex) { ApplicationLog.BaseLog.Error(ex); return(false); } }
private void HandleDeadBot() { if (this.m_deathCountdownMs > 0) { int totalGamePlayTimeInMilliseconds = MySandboxGame.TotalGamePlayTimeInMilliseconds; this.m_deathCountdownMs -= totalGamePlayTimeInMilliseconds - this.m_lastCountdownTime; this.m_lastCountdownTime = totalGamePlayTimeInMilliseconds; } else { Vector3D zero = Vector3D.Zero; if (!this.m_removeAfterDeath && MyAIComponent.BotFactory.GetBotSpawnPosition(this.BotDefinition.BehaviorType, out zero)) { MyPlayerCollection.OnRespawnRequest(false, false, 0L, null, new Vector3D?(zero), new SerializableDefinitionId?((SerializableDefinitionId)this.BotDefinition.Id), false, this.Player.Id.SerialId, null, Color.Red); this.m_respawnRequestSent = true; } else if (!this.m_botRemoved) { this.m_botRemoved = true; MyAIComponent.Static.RemoveBot(this.Player.Id.SerialId, false); } } }
private void HandleDeadBot() { if (m_deathCountdownMs <= 0) { Vector3D spawnPosition = Vector3D.Zero; if (!m_removeAfterDeath && MyAIComponent.BotFactory.GetBotSpawnPosition(BotDefinition.BehaviorType, out spawnPosition)) { MyPlayerCollection.RespawnRequest(false, false, 0, null, Player.Id.SerialId, spawnPosition, BotDefinition.Id); m_respawnRequestSent = true; } else if (!m_botRemoved) { m_botRemoved = true; MyAIComponent.Static.RemoveBot(Player.Id.SerialId); } } else { var currentTime = MySandboxGame.TotalGamePlayTimeInMilliseconds; m_deathCountdownMs -= currentTime - m_lastCountdownTime; m_lastCountdownTime = currentTime; } }
public bool UpdatePlayer(ulong steamId, long newPlayerId) { try { long playerId = Instance.GetFastPlayerIdFromSteamId(steamId); if (playerId == 0) { return(false); } MyPlayerCollection playerCollection = Sync.Players; object playerIdentityDictionary = BaseObject.GetEntityFieldValue(playerCollection, PlayerMapGetPlayerItemMappingField); object playerIdentiferDictionary = BaseObject.GetEntityFieldValue(playerCollection, PlayerMapGetSteamItemMappingField); object onlinePlayers = BaseObject.GetEntityFieldValue(playerCollection, PlayerMapPlayerDictionary); Type playerIdentifierType = playerIdentiferDictionary.GetType().GetGenericArguments()[0]; // Create MyPlayer.PlayerId type object playerIdentifier = Activator.CreateInstance(playerIdentifierType, steamId, 0); bool result = false; if ((bool)playerIdentityDictionary.GetType().GetMethod("ContainsKey").Invoke(playerIdentityDictionary, new object[] { playerId })) { SandboxGameAssemblyWrapper.Instance.GameAction(() => { try { object identity = playerIdentityDictionary.GetType().GetMethod("get_Item").Invoke(playerIdentityDictionary, new object[] { playerId }); if (identity != null) { BaseObject.SetEntityFieldValue(identity, PlayerMapIdentityPlayerId, newPlayerId); } } catch (Exception ex) { result = false; } }); } if ((bool)playerIdentiferDictionary.GetType().GetMethod("ContainsKey").Invoke(playerIdentiferDictionary, new[] { playerIdentifier })) { SandboxGameAssemblyWrapper.Instance.GameAction(() => { try { playerIdentiferDictionary.GetType().GetMethod("Remove").Invoke(playerIdentiferDictionary, new[] { playerIdentifier }); playerIdentiferDictionary.GetType().GetMethod("Add").Invoke(playerIdentiferDictionary, new[] { playerIdentifier, newPlayerId }); } catch (Exception ex) { result = false; } }); } if ((bool)onlinePlayers.GetType().GetMethod("ContainsKey").Invoke(onlinePlayers, new[] { playerIdentifier })) { SandboxGameAssemblyWrapper.Instance.GameAction(() => { try { object player = onlinePlayers.GetType().GetMethod("get_Item").Invoke(onlinePlayers, new[] { playerIdentifier }); if (player != null) { BaseObject.SetEntityFieldValue(player, PlayerMapPlayerIdentity, newPlayerId); //object identity = BaseObject.GetEntityFieldValue(player, PlayerMapPlayerIdentity); //identity.GetType().GetField(PlayerMapIdentityPlayerId).SetValue(identity, newPlayerId); } } catch (Exception ex) { result = false; } }); } } catch (Exception ex) { return(false); } return(true); }
private void RespawnAtMedicalRoom(long medicalId) { MyPlayerCollection.RespawnRequest(joinGame: MySession.Static.LocalCharacter == null, newPlayer: false, respawnEntityId: medicalId, shipPrefabId: null); CloseScreen(); }
public static bool TryGetPlayerById(this MyPlayerCollection self, long id, out MyPlayer player) { player = null; return(self.TryGetPlayerId(id, out var playerId) && self.TryGetPlayerById(playerId, out player)); }
public static bool TryGetSteamId(this MyPlayerCollection self, long playerId, out ulong steamId) { steamId = self.TryGetSteamId(playerId); return(steamId != 0); }
public static bool TryGetPlayerByGrid(this MyPlayerCollection self, IMyCubeGrid grid, out MyPlayer player) { player = null; return(grid.BigOwners.TryGetFirst(out var ownerId) && self.TryGetPlayerById(ownerId, out player)); }
public override void UpdateBeforeSimulation() { base.UpdateBeforeSimulation(); if (!(MySession.Static.IsScenario || MySession.Static.Settings.ScenarioEditMode)) { return; } if (!Sync.IsServer) { return; } if (MySession.Static.OnlineMode == MyOnlineModeEnum.OFFLINE && GameState < MyState.Running) { if (GameState == MyState.Loaded) { GameState = MyState.Running; ServerStartGameTime = DateTime.UtcNow; } return; } switch (GameState) { case MyState.Loaded: if (MySession.Static.OnlineMode != MyOnlineModeEnum.OFFLINE && MyMultiplayer.Static == null) { if (MyFakes.XBOX_PREVIEW) { GameState = MyState.Running; } else { m_bootUpCount++; if (m_bootUpCount > 100) //because MyMultiplayer.Static is initialized later than this part of game { //network start failure - trying to save what we can :-) MyPlayerCollection.RequestLocalRespawn(); GameState = MyState.Running; } } return; } if (MySandboxGame.IsDedicated || MySession.Static.Settings.ScenarioEditMode) { ServerPreparationStartTime = DateTime.UtcNow; MyMultiplayer.Static.ScenarioStartTime = ServerPreparationStartTime; GameState = MyState.Running; if (!MySandboxGame.IsDedicated) { StartScenario(); } return; } if (MySession.Static.OnlineMode == MyOnlineModeEnum.OFFLINE || MyMultiplayer.Static != null) { if (MyMultiplayer.Static != null) { MyMultiplayer.Static.Scenario = true; MyMultiplayer.Static.ScenarioBriefing = MySession.Static.GetWorld().Checkpoint.Briefing; } MyGuiScreenScenarioMpServer guiscreen = new MyGuiScreenScenarioMpServer(); guiscreen.Briefing = MySession.Static.GetWorld().Checkpoint.Briefing; MyGuiSandbox.AddScreen(guiscreen); m_playersReadyForBattle.Add(Sync.MyId); GameState = MyState.JoinScreen; } break; case MyState.JoinScreen: break; case MyState.WaitingForClients: // Check timeout TimeSpan currenTime = MySession.Static.ElapsedPlayTime; if (AllPlayersReadyForBattle() || (LoadTimeout > 0 && currenTime - m_startBattlePreparationOnClients > TimeSpan.FromSeconds(LoadTimeout))) { StartScenario(); foreach (var playerId in m_playersReadyForBattle) { if (playerId != Sync.MyId) { MySyncScenario.StartScenarioRequest(playerId, ServerStartGameTime.Ticks); } } } break; case MyState.Running: break; case MyState.Ending: if (EndAction != null && MySession.Static.ElapsedPlayTime - m_stateChangePlayTime > TimeSpan.FromSeconds(10)) { EndAction(); } break; } }