public virtual void Init(MyObjectBuilder_Character characterBuilder) { if (characterBuilder == null) { return; } m_inertiaDampenersNotification = new MyHudNotification(); m_jetpackToggleNotification = new MyHudNotification(); CurrentAutoEnableDelay = characterBuilder.AutoenableJetpackDelay; if (ThrustComp != null) { Character.Components.Remove <MyJetpackThrustComponent>(); } var thrustProperties = Character.Definition.Jetpack.ThrustProperties; FuelConverterDefinition = null;; FuelConverterDefinition = !MyFakes.ENABLE_HYDROGEN_FUEL ? new MyFuelConverterInfo { Efficiency = 1.0f } : Character.Definition.Jetpack.ThrustProperties.FuelConverter; MyDefinitionId fuelId = new MyDefinitionId(); if (!FuelConverterDefinition.FuelId.IsNull()) { fuelId = thrustProperties.FuelConverter.FuelId; } MyGasProperties fuelDef = null; if (MyFakes.ENABLE_HYDROGEN_FUEL) { MyDefinitionManager.Static.TryGetDefinition(fuelId, out fuelDef); } FuelDefinition = fuelDef ?? new MyGasProperties // Use electricity by default { Id = MyResourceDistributorComponent.ElectricityId, EnergyDensity = 1f, }; ForceMagnitude = thrustProperties.ForceMagnitude; MinPowerConsumption = thrustProperties.MinPowerConsumption; MaxPowerConsumption = thrustProperties.MaxPowerConsumption; MinPlanetaryInfluence = thrustProperties.MinPlanetaryInfluence; MaxPlanetaryInfluence = thrustProperties.MaxPlanetaryInfluence; EffectivenessAtMinInfluence = thrustProperties.EffectivenessAtMinInfluence; EffectivenessAtMaxInfluence = thrustProperties.EffectivenessAtMaxInfluence; NeedsAtmosphereForInfluence = thrustProperties.NeedsAtmosphereForInfluence; ConsumptionFactorPerG = thrustProperties.ConsumptionFactorPerG; MyEntityThrustComponent thrustComp = new MyJetpackThrustComponent(); thrustComp.Init(); Character.Components.Add(thrustComp); ThrustComp.DampenersEnabled = characterBuilder.DampenersEnabled; foreach (Vector3I direction in Base6Directions.IntDirections) { ThrustComp.Register(Character, direction); // Preferably there should be a jetpack entity (equipment) that could hold the thrusts instead of the character } thrustComp.ResourceSink(Character).TemporaryConnectedEntity = Character; Character.SuitRechargeDistributor.AddSink(thrustComp.ResourceSink(Character)); TurnOnJetpack(characterBuilder.JetpackEnabled, true, true); }
public virtual void Init(MyObjectBuilder_Character characterOb) { m_lastOxygenUpdateTime = MySession.Static.GameplayFrameCounter; m_gasIdToIndex = new Dictionary <MyDefinitionId, int>(); if (MyFakes.ENABLE_HYDROGEN_FUEL && Definition.SuitResourceStorage != null) { m_storedGases = new GasData[Definition.SuitResourceStorage.Count]; for (int gasIndex = 0; gasIndex < m_storedGases.Length; ++gasIndex) { var gasInfo = Definition.SuitResourceStorage[gasIndex]; m_storedGases[gasIndex] = new GasData { Id = gasInfo.Id, FillLevel = 1f, MaxCapacity = gasInfo.MaxCapacity, Throughput = gasInfo.Throughput, LastOutputTime = MySession.Static.GameplayFrameCounter, LastInputTime = MySession.Static.GameplayFrameCounter }; m_gasIdToIndex.Add(gasInfo.Id, gasIndex); } if (characterOb.StoredGases != null) { if (!MySession.Static.CreativeMode) { foreach (var gasInfo in characterOb.StoredGases) { int gasIndex; if (!m_gasIdToIndex.TryGetValue(gasInfo.Id, out gasIndex)) { continue; } m_storedGases[gasIndex].FillLevel = gasInfo.FillLevel; } } } } if (m_storedGases == null) { m_storedGases = new GasData[0]; } Debug.Assert(ContainsGasStorage(OxygenId), characterOb.SubtypeName + " is missing Oxygen resource."); Debug.Assert(ContainsGasStorage(HydrogenId), characterOb.SubtypeName + " is missing Hydrogen resource."); if (MySession.Static.Settings.EnableOxygen) { float oxygenFillLevel = GetGasFillLevel(OxygenId); m_oldSuitOxygenLevel = oxygenFillLevel == 0f ? OxygenCapacity : oxygenFillLevel; } EnvironmentOxygenLevel = characterOb.EnvironmentOxygenLevel; OxygenLevelAtCharacterLocation = 0f; m_oxygenBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationBottleRefill, level: MyNotificationLevel.Important); m_gasBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationGasBottleRefill, level: MyNotificationLevel.Important); m_lowOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenLow, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_criticalOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenCritical, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_helmetToggleNotification = m_helmetToggleNotification ?? new MyHudNotification(); // Init() is called when toggling helmet so this check is required // todo: this should be independent on animation/layer names string animationOpenHelmet; string animationCloseHelmet; Character.Definition.AnimationNameToSubtypeName.TryGetValue("HelmetOpen", out animationOpenHelmet); Character.Definition.AnimationNameToSubtypeName.TryGetValue("HelmetClose", out animationCloseHelmet); if ((animationOpenHelmet != null && animationCloseHelmet != null) || (Character.UseNewAnimationSystem && Character.AnimationController.Controller.GetLayerByName("Helmet") != null)) { NeedsOxygenFromSuit = characterOb.NeedsOxygenFromSuit; } else { NeedsOxygenFromSuit = Definition.NeedsOxygen; // compatibility } NeedsUpdateBeforeSimulation = true; NeedsUpdateBeforeSimulation100 = true; if (m_soundEmitter == null) { m_soundEmitter = new MyEntity3DSoundEmitter(Character); } if (!HelmetEnabled) // default state == helmet is enabled { AnimateHelmet(); } }
void Matchmaking_LobbyChatUpdate(Lobby lobby, ulong changedUser, ulong makingChangeUser, ChatMemberStateChangeEnum stateChange) { //System.Diagnostics.Debug.Assert(MySession.Static != null); if (lobby.LobbyId == Lobby.LobbyId) { if (stateChange == ChatMemberStateChangeEnum.Entered) { MySandboxGame.Log.WriteLineAndConsole("Player entered: " + MySteam.API.Friends.GetPersonaName(changedUser) + " (" + changedUser + ")"); MyTrace.Send(TraceWindow.Multiplayer, "Player entered"); Peer2Peer.AcceptSession(changedUser); // When some clients connect at the same time then some of them can have already added clients // (see function MySyncLayer.RegisterClientEvents which registers all Members in Lobby). if (Sync.Clients == null || !Sync.Clients.HasClient(changedUser)) { RaiseClientJoined(changedUser); } if (MySandboxGame.IsGameReady && changedUser != ServerId) { // Player is able to connect to the battle which already started - player is then kicked and we do not want to show connected message in HUD. bool showMsg = true; if (MyFakes.ENABLE_BATTLE_SYSTEM && MySession.Static != null && MySession.Static.Battle && !BattleCanBeJoined) { showMsg = false; } if (showMsg) { var playerJoined = new MyHudNotification(MyCommonTexts.NotificationClientConnected, 5000, level: MyNotificationLevel.Important); playerJoined.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser)); MyHud.Notifications.Add(playerJoined); } } } else { // Kicked client can be already removed from Clients if (Sync.Clients == null || Sync.Clients.HasClient(changedUser)) { RaiseClientLeft(changedUser, stateChange); } if (changedUser == ServerId) { MyTrace.Send(TraceWindow.Multiplayer, "Host left: " + stateChange.ToString()); RaiseHostLeft(); MyGuiScreenMainMenu.UnloadAndExitToMenu(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorServerHasLeft))); // Set new server //ServerId = Lobby.GetOwner(); //if (ServerId == Sync.MyId) //{ // Lobby.SetLobbyData(HostNameTag, Sync.MyName); //} } else if (MySandboxGame.IsGameReady) { var playerLeft = new MyHudNotification(MyCommonTexts.NotificationClientDisconnected, 5000, level: MyNotificationLevel.Important); playerLeft.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser)); MyHud.Notifications.Add(playerLeft); } } } }
private void ShowNotification(MyStringId textToDisplay) { var debugNotification = new MyHudNotification(textToDisplay, 5000, level: MyNotificationLevel.Important); MyHud.Notifications.Add(debugNotification); }
public override void UpdateAfterSimulation() { base.UpdateAfterSimulation(); if (m_spawnMedical == null) { return; } if (m_started && m_lemmings.Count == 0) { if (Vector3.Distance((Vector3)((MyEntity)MySession.LocalHumanPlayer.Identity.Character).PositionComp.GetPosition(), (Vector3)m_spawnMedical.PositionComp.GetPosition()) < 6) { SpawnLemming(); m_timeToNextSpawn = SPAWN_TIME; m_timeToNextChange = SPAWN_TIME; MyAudio.Static.ApplyTransition(NO_RANDOM, 0, MUS_FUN, false); MyGlobalEvents.SyncObject.PlayMusic(NO_RANDOM, MUS_FUN, false); m_globalEvent.Enabled = false; m_notification = new MyHudNotification(MySpaceTexts.FirstApril2014, 60 * 1000, level: MyNotificationLevel.Important); MyHud.Notifications.Add(m_notification); MyGlobalEvents.SyncObject.ShowNotification(MySpaceTexts.FirstApril2014, 60 * 1000); } } if (m_timeToNextSpawn >= 0) { m_timeToNextSpawn -= MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS; if (m_timeToNextSpawn <= 0) { m_timeToNextSpawn = SPAWN_TIME; SpawnLemming(); } } bool changeState = false; if (m_timeToNextChange >= 0) { m_timeToNextChange -= MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS; if (m_timeToNextChange <= 0) { m_timeToNextChange = SPAWN_TIME; changeState = true; } } foreach (var lemming in m_lemmings) { lemming.Update(changeState); } if (m_lemmings.Count > 0) { m_timeToEnd -= MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS; if (m_timeToEnd <= 0) { foreach (var lemming in m_lemmings) { lemming.Character.Close(); } m_lemmings.Clear(); m_started = false; } } }
private void UpdateJumpDriveSystem() { // Using this instead of game time because it cannot be affected by sim speed float jumpTime = (float)(TimeUtil.LocalTime - m_jumpStartTime).TotalMilliseconds; float warmupTime = 10000f; float startJumpTime = 1500f; float endJumpTime = 500f; if (m_isJumping) { if (jumpTime < warmupTime) { int prevTimeInt = (int)(m_prevJumpTime / 1000); int timeInt = (int)(jumpTime / 1000); if (prevTimeInt != timeInt) { if (IsLocalCharacterAffectedByJump()) { var notification = new MyHudNotification(MySpaceTexts.NotificationJumpWarmupTime, 500); int secondsRemaining = (int)(Math.Round((warmupTime - jumpTime) / 1000)); notification.SetTextFormatArguments(secondsRemaining); MyHud.Notifications.Add(notification); } } } else if (jumpTime < startJumpTime + warmupTime) { if (m_soundEmitter.SoundId != m_jumpOutSound.SoundId) { m_soundEmitter.PlaySound(m_jumpOutSound); } UpdateJumpEffect(MathHelper.SmoothStep(1f, 0f, (jumpTime - warmupTime) / startJumpTime)); } else if (!m_jumped) { MyParticleEffect effect; if (MyParticlesManager.TryCreateParticleEffect(53, out effect)) { effect.WorldMatrix = MatrixD.CreateFromTransformScale(Quaternion.Identity, m_grid.WorldMatrix.Translation, Vector3D.One); effect.UserScale = (float)m_grid.PositionComp.WorldAABB.HalfExtents.AbsMax() / 25f; effect.AutoDelete = true; } MyThirdPersonSpectator.Static.ResetPosition(0.0, null); MyThirdPersonSpectator.Static.ResetDistance(); MyThirdPersonSpectator.Static.RecalibrateCameraPosition(); m_jumped = true; var keys = m_shipInfo.Keys.ToList(); foreach (var key in keys) { MatrixD gridMatrix = key.WorldMatrix; gridMatrix.Translation = m_shipInfo[key]; key.WorldMatrix = gridMatrix; } UpdateJumpEffect(0f); MyThirdPersonSpectator.Static.ResetPosition(0.0, null); MyThirdPersonSpectator.Static.ResetDistance(); MyThirdPersonSpectator.Static.RecalibrateCameraPosition(); } else if (jumpTime < startJumpTime + endJumpTime + warmupTime) { if (m_soundEmitter.SoundId != m_jumpInSound.SoundId) { m_soundEmitter.PlaySound(m_jumpInSound); } UpdateJumpEffect(MathHelper.SmoothStep(0f, 1f, (jumpTime - startJumpTime - warmupTime) / (endJumpTime))); } else { UpdateJumpEffect(1f); m_jumped = false; m_isJumping = false; } } m_prevJumpTime = jumpTime; }
static void OnShowNotification(ref ShowNotificationMsg msg, MyNetworkClient sender) { var notification = new MyHudNotification(msg.Text, msg.Time, level: MyNotificationLevel.Important); MyHud.Notifications.Add(notification); }
private void GetNotification(IMyUseObject useObject, UseActionEnum actionType, ref MyHudNotification notification) { if ((useObject.SupportedActions & actionType) != UseActionEnum.None) { MyActionDescription actionInfo = useObject.GetActionInfo(actionType); base.Character.RemoveNotification(ref notification); notification = new MyHudNotification(actionInfo.Text, 0, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, actionInfo.IsTextControlHint ? MyNotificationLevel.Control : MyNotificationLevel.Normal); if (!MyDebugDrawSettings.DEBUG_DRAW_JOYSTICK_CONTROL_HINTS && (!MyInput.Static.IsJoystickConnected() || !MyInput.Static.IsJoystickLastUsed)) { notification.SetTextFormatArguments(actionInfo.FormatParams); } else { if (actionInfo.JoystickText != null) { notification.Text = actionInfo.JoystickText.Value; } if (actionInfo.JoystickFormatParams != null) { notification.SetTextFormatArguments(actionInfo.JoystickFormatParams); } } } }
private void ShowNewMessageHudNotification(MyHudNotification notification) { MyHud.Notifications.Add(notification); }
public override void LoadData() { _notification = new MyHudNotification(MySpaceTexts.NotificationMeteorInbound, 5000, "Red", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Important); }
public void RequestJump(string destinationName, Vector3D destination, long userId) { if (!Vector3.IsZero(MyGravityProviderSystem.CalculateNaturalGravityInPoint(m_grid.WorldMatrix.Translation))) { var notification = new MyHudNotification(MySpaceTexts.NotificationCannotJumpFromGravity, 1500); MyHud.Notifications.Add(notification); return; } if (!Vector3.IsZero(MyGravityProviderSystem.CalculateNaturalGravityInPoint(destination))) { var notification = new MyHudNotification(MySpaceTexts.NotificationCannotJumpIntoGravity, 1500); MyHud.Notifications.Add(notification); return; } if (!IsJumpValid(userId)) { return; } m_selectedDestination = destination; double maxJumpDistance = GetMaxJumpDistance(userId); m_jumpDirection = destination - m_grid.WorldMatrix.Translation; double jumpDistance = m_jumpDirection.Length(); double actualDistance = jumpDistance; if (jumpDistance > maxJumpDistance) { double ratio = maxJumpDistance / jumpDistance; actualDistance = maxJumpDistance; m_jumpDirection *= ratio; } if (actualDistance < MIN_JUMP_DISTANCE) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType: MyMessageBoxButtonsType.OK, messageText: GetWarningText(actualDistance), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWarning) )); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType : MyMessageBoxButtonsType.YES_NO, messageText : GetConfimationText(destinationName, jumpDistance, actualDistance, userId), messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm), size : new Vector2(0.839375f, 0.3675f), callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES && IsJumpValid(userId)) { RequestJump(m_selectedDestination, userId); } else { AbortJump(); } } )); } }
private void UpdateJumpDriveSystem() { // Using this instead of game time because it cannot be affected by sim speed float jumpTime = (float)(TimeUtil.LocalTime - m_jumpStartTime).TotalMilliseconds; float warmupTime = 10000f; float startJumpTime = 1500f; float endJumpTime = 500f; if (m_isJumping) { if (jumpTime < warmupTime) { int prevTimeInt = (int)(m_prevJumpTime / 1000); int timeInt = (int)(jumpTime / 1000); if (prevTimeInt != timeInt) { if (IsLocalCharacterAffectedByJump()) { var notification = new MyHudNotification(MySpaceTexts.NotificationJumpWarmupTime, 500); int secondsRemaining = (int)(Math.Round((warmupTime - jumpTime) / 1000)); notification.SetTextFormatArguments(secondsRemaining); MyHud.Notifications.Add(notification); } } } else if (jumpTime < startJumpTime + warmupTime) { if (m_soundEmitter.SoundId != m_jumpOutSound.SoundId) { m_soundEmitter.PlaySound(m_jumpOutSound); } UpdateJumpEffect(MathHelper.SmoothStep(1f, 0f, (jumpTime - warmupTime) / startJumpTime)); } else if (!m_jumped) { if (Sync.IsServer) { Vector3?suitableLocation = FindSuitableJumpLocation(m_shipInfo[m_grid]); if (suitableLocation.HasValue) { SyncObject.SendPerformJump(suitableLocation.Value); PerformJump(suitableLocation.Value); } else { SyncObject.SendAbortJump(); AbortJump(); } } } else if (jumpTime < startJumpTime + endJumpTime + warmupTime) { if (m_soundEmitter.SoundId != m_jumpInSound.SoundId) { m_soundEmitter.PlaySound(m_jumpInSound); } UpdateJumpEffect(MathHelper.SmoothStep(0f, 1f, (jumpTime - startJumpTime - warmupTime) / (endJumpTime))); } else { CleanupAfterJump(); } } m_prevJumpTime = jumpTime; }
public virtual void Init(MyObjectBuilder_Character characterOb) { m_lastOxygenUpdateTime = MySession.Static.GameplayFrameCounter; m_gasIdToIndex = new Dictionary <MyDefinitionId, int>(); if (MyFakes.ENABLE_HYDROGEN_FUEL && Definition.SuitResourceStorage != null) { m_storedGases = new GasData[Definition.SuitResourceStorage.Count]; for (int gasIndex = 0; gasIndex < m_storedGases.Length; ++gasIndex) { var gasInfo = Definition.SuitResourceStorage[gasIndex]; m_storedGases[gasIndex] = new GasData { Id = gasInfo.Id, FillLevel = 1f, MaxCapacity = gasInfo.MaxCapacity, Throughput = gasInfo.Throughput, LastOutputTime = MySession.Static.GameplayFrameCounter, LastInputTime = MySession.Static.GameplayFrameCounter }; m_gasIdToIndex.Add(gasInfo.Id, gasIndex); } if (characterOb.StoredGases != null) { if (!MySession.Static.CreativeMode) { foreach (var gasInfo in characterOb.StoredGases) { int gasIndex; if (!m_gasIdToIndex.TryGetValue(gasInfo.Id, out gasIndex)) { continue; } m_storedGases[gasIndex].FillLevel = gasInfo.FillLevel; } } } } if (m_storedGases == null) { m_storedGases = new GasData[0]; } Debug.Assert(ContainsGasStorage(OxygenId), characterOb.SubtypeName + " is missing Oxygen resource."); Debug.Assert(ContainsGasStorage(HydrogenId), characterOb.SubtypeName + " is missing Hydrogen resource."); if (MySession.Static.Settings.EnableOxygen) { float oxygenFillLevel = GetGasFillLevel(OxygenId); m_oldSuitOxygenLevel = oxygenFillLevel == 0f ? OxygenCapacity : oxygenFillLevel; } EnvironmentOxygenLevel = characterOb.EnvironmentOxygenLevel; m_oxygenBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationBottleRefill, level: MyNotificationLevel.Important); m_gasBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationGasBottleRefill, level: MyNotificationLevel.Important); m_lowOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenLow, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_criticalOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenCritical, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_helmetToggleNotification = m_helmetToggleNotification ?? new MyHudNotification(); // Init() is called when toggling helmet so this check is required m_needsOxygen = Definition.NeedsOxygen; NeedsUpdateBeforeSimulation = true; NeedsUpdateBeforeSimulation100 = true; }
public void RequestJump(string destinationName, Vector3D destination, long userId) { if (!Vector3.IsZero(MyGravityProviderSystem.CalculateNaturalGravityInPoint(m_grid.WorldMatrix.Translation))) { var notification = new MyHudNotification(MySpaceTexts.NotificationCannotJumpFromGravity, 1500); MyHud.Notifications.Add(notification); return; } if (!Vector3.IsZero(MyGravityProviderSystem.CalculateNaturalGravityInPoint(destination))) { var notification = new MyHudNotification(MySpaceTexts.NotificationCannotJumpIntoGravity, 1500); MyHud.Notifications.Add(notification); return; } if (!IsJumpValid(userId)) { return; } if (MySession.Static.Settings.WorldSizeKm > 0 && destination.Length() > MySession.Static.Settings.WorldSizeKm * 500) { var notification = new MyHudNotification(MySpaceTexts.NotificationCannotJumpOutsideWorld, 1500); MyHud.Notifications.Add(notification); return; } m_selectedDestination = destination; double maxJumpDistance = GetMaxJumpDistance(userId); m_jumpDirection = destination - m_grid.WorldMatrix.Translation; double jumpDistance = m_jumpDirection.Length(); double actualDistance = jumpDistance; if (jumpDistance > maxJumpDistance) { double ratio = maxJumpDistance / jumpDistance; actualDistance = maxJumpDistance; m_jumpDirection *= ratio; } //By Gregory: Check for obstacle not that fast but happens rarely(on Jump drive enable) //TODO: make compatible with GetMaxJumpDistance and refactor to much code checks for actual jump var direction = Vector3D.Normalize(destination - m_grid.WorldMatrix.Translation); var startPos = m_grid.WorldMatrix.Translation + m_grid.PositionComp.LocalAABB.Extents.Max() * direction; var line = new LineD(startPos, destination); var intersection = MyEntities.GetIntersectionWithLine(ref line, m_grid, null, ignoreObjectsWithoutPhysics: false); Vector3D newDestination = Vector3D.Zero; Vector3D newDirection = Vector3D.Zero; if (intersection.HasValue) { MyEntity MyEntity = intersection.Value.Entity as MyEntity; var targetPos = MyEntity.WorldMatrix.Translation; var obstaclePoint = MyUtils.GetClosestPointOnLine(ref startPos, ref destination, ref targetPos); MyPlanet MyEntityPlanet = intersection.Value.Entity as MyPlanet; if (MyEntityPlanet != null) { var notification = new MyHudNotification(MySpaceTexts.NotificationCannotJumpIntoGravity, 1500); MyHud.Notifications.Add(notification); return; } //var Radius = MyEntityPlanet != null ? MyEntityPlanet.MaximumRadius : MyEntity.PositionComp.LocalAABB.Extents.Length(); var Radius = MyEntity.PositionComp.LocalAABB.Extents.Length(); destination = obstaclePoint - direction * (Radius + m_grid.PositionComp.LocalAABB.HalfExtents.Length()); m_selectedDestination = destination; m_jumpDirection = m_selectedDestination - startPos; actualDistance = m_jumpDirection.Length(); } if (actualDistance < MIN_JUMP_DISTANCE) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType: MyMessageBoxButtonsType.OK, messageText: GetWarningText(actualDistance, intersection.HasValue), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWarning) )); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType : MyMessageBoxButtonsType.YES_NO, messageText : GetConfimationText(destinationName, jumpDistance, actualDistance, userId, intersection.HasValue), messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm), size : new Vector2(0.839375f, 0.3675f), callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES && IsJumpValid(userId)) { RequestJump(m_selectedDestination, userId); } else { AbortJump(); } } )); } }
static MyGlobalEvents() { m_globalEvents[(int)MyGlobalEventEnum.SunWind] = new MyGlobalEvent( Type : MyGlobalEventEnum.SunWind, Name : MyTextsWrapperEnum.GlobalEventSunWindName, Description : MyTextsWrapperEnum.GlobalEventSunWindDescription, RatePerHour : 12.0f, Icon : null, Enabled : true, Action : delegate(object o, EventArgs e) { //dont allow sunwind in god editor on or when the game is paused if (!MySunWind.IsActive && !(MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()) && !MyMinerGame.IsPaused()) { //MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEventSunWindDescription, 5000)); MySunWind.Start(); //MyAudio.AddCue2D(MySoundCuesEnum.HudSolarFlareWarning); } }, WriteToEventLog: false ); m_globalEvents[(int)MyGlobalEventEnum.FractionStatusChange] = new MyGlobalEvent( Type : MyGlobalEventEnum.FractionStatusChange, Name : MyTextsWrapperEnum.GlobalEventFactionChangeName, Description : MyTextsWrapperEnum.GlobalEventFactionChangeDescription, RatePerHour : 10.0f, Icon : null, Enabled : false, Action : delegate(object o, EventArgs e) { float statusChange = MyMwcUtils.GetRandomFloat(MyFactions.RELATION_WORST, MyFactions.RELATION_BEST) / 10.0f; int[] enumValues = MyMwcFactionsByIndex.GetFactionsIndexes(); System.Diagnostics.Debug.Assert(enumValues.Length > 3); MyMwcObjectBuilder_FactionEnum faction1; do { faction1 = MyMwcFactionsByIndex.GetFaction(MyMwcUtils.GetRandomInt(enumValues.Length)); }while (faction1 == MyMwcObjectBuilder_FactionEnum.None); MyMwcObjectBuilder_FactionEnum faction2; do { faction2 = MyMwcFactionsByIndex.GetFaction(MyMwcUtils.GetRandomInt(enumValues.Length)); }while ((faction1 == faction2) || (faction2 == MyMwcObjectBuilder_FactionEnum.None)); MyFactions.ChangeFactionStatus(faction1, faction2, statusChange); }, WriteToEventLog: false ); m_globalEvents[(int)MyGlobalEventEnum.MeteorWind] = new MyGlobalEvent( Type : MyGlobalEventEnum.SunWind, Name : MyTextsWrapperEnum.GlobalEventMeteorWindName, Description : MyTextsWrapperEnum.GlobalEventSunWindDescription, RatePerHour : MyFakes.ENABLE_RANDOM_METEOR_SHOWER ? 1.0f : 0.0f, Icon : null, Enabled : false, Action : delegate(object o, EventArgs e) { //dont allow sunwind in god editor on or when the game is paused if (!(MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()) && !MyMinerGame.IsPaused()) { //MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEventSunWindDescription, 5000)); MyMeteorWind.Start(); //MyAudio.AddCue2D(MySoundCuesEnum.SfxSolarFlareWarning); } }, WriteToEventLog: false ); // todo implement localization strings m_globalEvents[(int)MyGlobalEventEnum.IceStorm] = new MyGlobalEvent( Type : MyGlobalEventEnum.IceStorm, Name : MyTextsWrapperEnum.GlobalEventIceStormName, //Name: MyTextsWrapperEnum.GlobalEvent_IceStorm_Name, Description : MyTextsWrapperEnum.GlobalEventSunWindDescription, //IceStorm_Description, RatePerHour : MyFakes.ENABLE_RANDOM_ICE_STORM ? 1.0f : 0.0f, Icon : null, Enabled : false, Action : delegate(object o, EventArgs e) { //dont allow sunwind in god editor on or when the game is paused if (!(MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()) && !MyMinerGame.IsPaused()) { MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEventSunWindDescription, 5000, null)); // MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEvent_IceStorm_Description, 5000)); MyIceStorm.Start(); MyAudio.AddCue2D(MySoundCuesEnum.HudSolarFlareWarning); } }, WriteToEventLog: false ); m_globalEvents[(int)MyGlobalEventEnum.IceComet] = new MyGlobalEvent( Type : MyGlobalEventEnum.IceComet, Name : MyTextsWrapperEnum.GlobalEventIceCometName, Description : MyTextsWrapperEnum.GlobalEventIceCometDescription, RatePerHour : 0.0f, Icon : null, Enabled : false, Action : delegate(object o, EventArgs e) { if (!(MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()) && !MyMinerGame.IsPaused()) { MyHudNotification.AddNotification(new MyHudNotification.MyNotification(MyTextsWrapperEnum.GlobalEventSunWindDescription, 5000)); MyIceComet.Start(); MyAudio.AddCue2D(MySoundCuesEnum.HudSolarFlareWarning); } }, WriteToEventLog: false ); foreach (MyGlobalEvent e in m_globalEvents) { System.Diagnostics.Debug.Assert(e != null); } MyFactions.OnFactionStatusChanged += new MyFactionStatusChangeHandler(MyFactions_OnFactionStatusChanged); }
private void UpdateJumpDriveSystem() { if (m_isJumping) { float jumpTime = m_jumpTimeLeft; const float startJumpTime = 1.2f; const float particleTime = 0.3f; const float endJumpTime = -0.3f; PlayParticleEffect(); m_jumpTimeLeft -= VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS; if (jumpTime > startJumpTime) { double roundTime = Math.Round(jumpTime); if (roundTime != m_prevJumpTime) { if (IsLocalCharacterAffectedByJump(true)) { var notification = new MyHudNotification(MySpaceTexts.NotificationJumpWarmupTime, 500, priority: 3); notification.SetTextFormatArguments(roundTime); MyHud.Notifications.Add(notification); } } } else if (jumpTime > 0) { IsLocalCharacterAffectedByJump(true); if (m_soundEmitter.SoundId != m_jumpOutSound.Arcade && m_soundEmitter.SoundId != m_jumpOutSound.Realistic) { m_soundEmitter.PlaySound(m_jumpOutSound); } UpdateJumpEffect(jumpTime / startJumpTime); if (jumpTime < particleTime) { //PlayParticleEffect(); } } else if (!m_jumped) { if (Sync.IsServer) { if (m_shipInfo.ContainsKey(m_grid)) { Vector3?suitableLocation = FindSuitableJumpLocation(m_shipInfo[m_grid]); if (suitableLocation.HasValue) { SendPerformJump(suitableLocation.Value); PerformJump(suitableLocation.Value); } else { SendAbortJump(); AbortJump(); } } else { SendAbortJump(); AbortJump(); } } } else if (jumpTime > endJumpTime) { UpdateJumpEffect(jumpTime / endJumpTime); } else { CleanupAfterJump(); if (m_soundEmitter.SoundId != m_jumpInSound.Arcade && m_soundEmitter.SoundId != m_jumpInSound.Realistic) { m_soundEmitter.PlaySound(m_jumpInSound); } } m_prevJumpTime = (float)Math.Round(jumpTime); } }
private static void OnSnapshotDone(bool snapshotSuccess, MySessionSnapshot snapshot) { if (snapshotSuccess) { if (!MySandboxGame.IsDedicated) { var thumbPath = MySession.Static.ThumbPath; try { if (File.Exists(thumbPath)) { File.Delete(thumbPath); } MyGuiSandbox.TakeScreenshot(1200, 672, saveToPath: thumbPath, ignoreSprites: true, showNotification: false); } catch (Exception ex) { MySandboxGame.Log.WriteLine("Could not take session thumb screenshot. Exception:"); MySandboxGame.Log.WriteLine(ex); } } snapshot.SaveParallel(completionCallback: () => { if (!MySandboxGame.IsDedicated) { MyHud.PopRotatingWheelVisible(); if (MySession.Static != null) { if (snapshot.SavingSuccess) { var notification = new MyHudNotification(MyCommonTexts.WorldSaved, 2500); notification.SetTextFormatArguments(MySession.Static.Name); MyHud.Notifications.Add(notification); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: new StringBuilder().AppendFormat(MyTexts.GetString(MyCommonTexts.WorldNotSaved), MySession.Static.Name), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError))); } } } PopInProgress(); }); } else { if (!MySandboxGame.IsDedicated) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: new StringBuilder().AppendFormat(MyTexts.GetString(MyCommonTexts.WorldNotSaved), MySession.Static.Name), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError))); } PopInProgress(); } if (m_callbackOnFinished != null) { m_callbackOnFinished(); } m_callbackOnFinished = null; MyAudio.Static.Mute = false; }