public void EndShoot(MyShootActionEnum action) { MyAnalyticsHelper.ReportActivityEnd(this.Owner, "Drilling"); m_drillBase.StopDrill(); m_tryingToDrill = false; SinkComp.Update(); }
public override void EndShoot(MyShootActionEnum action) { if (m_activated) { MyAnalyticsHelper.ReportActivityEnd(this.Owner, "Welding"); } m_playedFailSound = false; base.EndShoot(action); }
protected override void OnClosed() { base.OnClosed(); MyAnalyticsHelper.ReportActivityEnd(null, "show_blueprints"); if (m_activeDetail) { m_detailScreen.CloseScreen(); } }
public override bool CloseScreen() { bool ret = base.CloseScreen(); m_musicPlayed = false; /* if (ret == true) { if (MyGuiScreenGamePlay.Static != null && MyGuiScreenGamePlay.Static.IsPausable() && MySandboxGame.IsPaused()) MySandboxGame.SwitchPause(); } */ MyAnalyticsHelper.ReportActivityEnd(null, "show_main_menu"); return ret; }
public override bool CloseScreen() { if (m_pauseGame) { MySandboxGame.PausePop(); } bool ret = base.CloseScreen(); m_musicPlayed = false; MyAnalyticsHelper.ReportActivityEnd(null, "show_main_menu"); return(ret); }
public override void EndShoot(MyShootActionEnum action) { MyAnalyticsHelper.ReportActivityEnd(this.Owner, "Grinding"); base.EndShoot(action); }
protected override void OnClosed() { base.OnClosed(); MyAnalyticsHelper.ReportActivityEnd(null, "show_workshop"); }
public bool RemovePilot() { if (m_pilot == null) { return(true); } MyAnalyticsHelper.ReportActivityEnd(m_pilot, "Cockpit"); System.Diagnostics.Debug.Assert(m_pilot.Physics != null); if (m_pilot.Physics == null) { //probably already closed pilot left in cockpit m_pilot = null; return(true); } StopLoopSound(); m_pilot.OnMarkForClose -= m_pilotClosedHandler; if (m_pilot.IsDead) { if (this.ControllerInfo.Controller != null) { this.SwitchControl(m_pilot); } Hierarchy.RemoveChild(m_pilot); MyEntities.Add(m_pilot); m_pilot.WorldMatrix = WorldMatrix; m_pilotGunDefinition = null; m_rechargeSocket.Unplug(); m_pilot.SuitBattery.ResourceSink.TemporaryConnectedEntity = null; m_pilot = null; return(true); } bool usePilotOriginalWorld = false; MatrixD placementMatrix = MatrixD.Identity; if (m_pilotRelativeWorld.HasValue) { placementMatrix = MatrixD.Multiply((MatrixD)m_pilotRelativeWorld.Value, this.WorldMatrix); if (m_pilot.CanPlaceCharacter(ref placementMatrix)) { usePilotOriginalWorld = true; } } Vector3D?allowedPosition = null; if (!usePilotOriginalWorld) { allowedPosition = FindFreeNeighbourPosition(); if (!allowedPosition.HasValue) { allowedPosition = PositionComp.GetPosition(); } } RemovePilotFromSeat(m_pilot); EndShootAll(); if (usePilotOriginalWorld || allowedPosition.HasValue) { Hierarchy.RemoveChild(m_pilot); MyEntities.Add(m_pilot); m_pilot.Physics.Enabled = true; m_rechargeSocket.Unplug(); m_pilot.SuitBattery.ResourceSink.TemporaryConnectedEntity = null; m_pilot.Stand(); // allowedPosition is in center of character MatrixD placeMatrix = (usePilotOriginalWorld) ? placementMatrix : MatrixD.CreateWorld(allowedPosition.Value - WorldMatrix.Up, WorldMatrix.Forward, WorldMatrix.Up); if (m_pilot.Physics.CharacterProxy != null) { m_pilot.Physics.CharacterProxy.ImmediateSetWorldTransform = true; } if (!MyEntities.CloseAllowed) { m_pilot.PositionComp.SetWorldMatrix(placeMatrix, this); } if (m_pilot.Physics.CharacterProxy != null) { m_pilot.Physics.CharacterProxy.ImmediateSetWorldTransform = false; } if (Parent != null && Parent.Physics != null) // Cockpit could be removing the pilot after it no longer belongs to any grid (e.g. during a split) { m_pilot.Physics.LinearVelocity = Parent.Physics.LinearVelocity; if (Parent.Physics.LinearVelocity.LengthSquared() > 100) { var jetpack = m_pilot.JetpackComp; if (jetpack != null) { jetpack.EnableDampeners(false); jetpack.TurnOnJetpack(true); } } } if (this.ControllerInfo.Controller != null) { this.SwitchControl(m_pilot); } if (m_pilotGunDefinition != null) { m_pilot.SwitchToWeapon(m_pilotGunDefinition); } else { m_pilot.SwitchToWeapon(null); } var pilot = m_pilot; m_pilot = null; if (MySession.Static.CameraController == this) { MySession.SetCameraController(MyCameraControllerEnum.Entity, pilot); } return(true); } else { //System.Diagnostics.Debug.Assert(false, "There is no place where to put astronaut. Kill him!"); } return(false); }
public void TurnOnJetpack(bool newState, bool fromLoad = false, bool updateSync = true, bool fromInit = false) { bool originalNewState = newState; newState = newState && MySession.Static.Settings.EnableJetpack; newState = newState && Character.Definition.Jetpack != null; newState = newState && (!MySession.Static.SurvivalMode || MyFakes.ENABLE_JETPACK_IN_SURVIVAL || MySession.Static.IsAdminModeEnabled); bool valueChanged = TurnedOn != newState; TurnedOn = newState; ThrustComp.Enabled = newState; ThrustComp.ControlThrust = Vector3.Zero; ThrustComp.MarkDirty(); ThrustComp.UpdateBeforeSimulation(); if (!ThrustComp.Enabled) { ThrustComp.SetRequiredFuelInput(ref FuelDefinition.Id, 0f, null); } ThrustComp.ResourceSink(Character).Update(); if (!Character.ControllerInfo.IsLocallyControlled() && !fromInit && !Sync.IsServer && !MyFakes.CHARACTER_SERVER_SYNC) { return; } MyCharacterMovementEnum currentMovementState = Character.GetCurrentMovementState(); if (currentMovementState == MyCharacterMovementEnum.Sitting) { return; } Character.StopFalling(); bool noHydrogen = false; bool canUseJetpack = newState; if (!IsPowered && canUseJetpack && (MySession.Static.IsAdminModeEnabled == false || MySession.Static.LocalCharacter != Character)) { canUseJetpack = false; noHydrogen = true; } if (canUseJetpack) { Character.IsUsing = null; } if (MySession.Static.ControlledEntity == Character && valueChanged && !fromLoad) { m_jetpackToggleNotification.Text = (noHydrogen) ? MySpaceTexts.NotificationJetpackOffNoHydrogen : (canUseJetpack || (originalNewState)) ? MySpaceTexts.NotificationJetpackOn : MySpaceTexts.NotificationJetpackOff; MyHud.Notifications.Add(m_jetpackToggleNotification); if (canUseJetpack) { MyAnalyticsHelper.ReportActivityStart(Character, "jetpack", "character", string.Empty, string.Empty); } else { MyAnalyticsHelper.ReportActivityEnd(Character, "jetpack"); } //unable sound + turn off jetpack if (noHydrogen) { MyGuiAudio.PlaySound(MyGuiSounds.HudUnable); TurnedOn = false; ThrustComp.Enabled = false; ThrustComp.ControlThrust = Vector3.Zero; ThrustComp.MarkDirty(); ThrustComp.UpdateBeforeSimulation(); ThrustComp.SetRequiredFuelInput(ref FuelDefinition.Id, 0f, null); ThrustComp.ResourceSink(Character).Update(); } } var characterProxy = Character.Physics.CharacterProxy; if (characterProxy != null) { characterProxy.Forward = Character.WorldMatrix.Forward; characterProxy.Up = Character.WorldMatrix.Up; characterProxy.EnableFlyingState(Running); if (currentMovementState != MyCharacterMovementEnum.Died) { if (!Running && (characterProxy.GetState() == HkCharacterStateType.HK_CHARACTER_IN_AIR || (int)characterProxy.GetState() == MyCharacter.HK_CHARACTER_FLYING)) { Character.StartFalling(); } //If we are in any state but not standing and new state is to be flying, dont change to standing. Else is probably ok? else if (currentMovementState != MyCharacterMovementEnum.Standing && !newState) { Character.PlayCharacterAnimation("Idle", MyBlendOption.Immediate, MyFrameOption.Loop, 0.2f); Character.SetCurrentMovementState(MyCharacterMovementEnum.Standing); currentMovementState = Character.GetCurrentMovementState(); } } if (Running && currentMovementState != MyCharacterMovementEnum.Died) { Character.PlayCharacterAnimation("Jetpack", MyBlendOption.Immediate, MyFrameOption.Loop, 0.0f); Character.SetCurrentMovementState(MyCharacterMovementEnum.Flying); Character.SetLocalHeadAnimation(0, 0, 0.3f); // If the character is running when enabling the jetpack, these will keep making him fly in the same direction always if not zeroed characterProxy.PosX = 0; characterProxy.PosY = 0; } // When disabling the jetpack normally during the game in zero-G, disable jetpack autoenable if (!fromLoad && !newState && characterProxy.Gravity.LengthSquared() <= 0.1f) { CurrentAutoEnableDelay = -1; } } }
public void TurnOnJetpack(bool newState, bool fromInit = false, bool fromLoad = false) { int num1; int num2; MyEntityController controller = base.Character.ControllerInfo.Controller; newState = newState && MySession.Static.Settings.EnableJetpack; newState = newState && (base.Character.Definition.Jetpack != null); if (!newState) { num1 = 0; } else if ((!MySession.Static.SurvivalMode || MyFakes.ENABLE_JETPACK_IN_SURVIVAL) || (controller == null)) { num1 = 1; } else { num1 = (int)MySession.Static.CreativeToolsEnabled(controller.Player.Id.SteamId); } newState = (bool)num2; bool flag = this.TurnedOn != newState; this.TurnedOn = newState; this.ThrustComp.Enabled = newState; this.ThrustComp.ControlThrust = Vector3.Zero; this.ThrustComp.MarkDirty(false); this.ThrustComp.UpdateBeforeSimulation(true, base.Character.RelativeDampeningEntity); if (!this.ThrustComp.Enabled) { this.ThrustComp.SetRequiredFuelInput(ref this.FuelDefinition.Id, 0f, null); } this.ThrustComp.ResourceSink(base.Character).Update(); if ((base.Character.ControllerInfo.IsLocallyControlled() || fromInit) || Sync.IsServer) { MyCharacterMovementEnum currentMovementState = base.Character.GetCurrentMovementState(); if (currentMovementState != MyCharacterMovementEnum.Sitting) { if (this.TurnedOn) { base.Character.StopFalling(); } bool flag2 = false; bool flag3 = newState; if ((!this.IsPowered & flag3) && (((base.Character.ControllerInfo.Controller != null) && !MySession.Static.CreativeToolsEnabled(base.Character.ControllerInfo.Controller.Player.Id.SteamId)) || (!ReferenceEquals(MySession.Static.LocalCharacter, base.Character) && !Sync.IsServer))) { flag3 = false; flag2 = true; } if (flag3) { if (base.Character.IsOnLadder) { base.Character.GetOffLadder(); } base.Character.IsUsing = null; } if (flag && !base.Character.IsDead) { base.Character.UpdateCharacterPhysics(false); } if ((ReferenceEquals(MySession.Static.ControlledEntity, base.Character) & flag) && !fromLoad) { if (flag3) { MyAnalyticsHelper.ReportActivityStart(base.Character, "jetpack", "character", string.Empty, string.Empty, true); } else { MyAnalyticsHelper.ReportActivityEnd(base.Character, "jetpack"); } if (flag2) { MyGuiAudio.PlaySound(MyGuiSounds.HudUnable); this.TurnedOn = false; this.ThrustComp.Enabled = false; this.ThrustComp.ControlThrust = Vector3.Zero; this.ThrustComp.MarkDirty(false); this.ThrustComp.UpdateBeforeSimulation(true, base.Character.RelativeDampeningEntity); this.ThrustComp.SetRequiredFuelInput(ref this.FuelDefinition.Id, 0f, null); this.ThrustComp.ResourceSink(base.Character).Update(); } } MyCharacterProxy characterProxy = base.Character.Physics.CharacterProxy; if (characterProxy == null) { if (this.Running && (currentMovementState != MyCharacterMovementEnum.Died)) { base.Character.PlayCharacterAnimation("Jetpack", MyBlendOption.Immediate, MyFrameOption.Loop, 0f, 1f, false, null, false); base.Character.SetLocalHeadAnimation(0f, 0f, 0.3f); } } else { MatrixD worldMatrix = base.Character.WorldMatrix; characterProxy.SetForwardAndUp((Vector3)worldMatrix.Forward, (Vector3)worldMatrix.Up); characterProxy.EnableFlyingState(this.Running); if ((currentMovementState != MyCharacterMovementEnum.Died) && !base.Character.IsOnLadder) { if (!this.Running && ((characterProxy.GetState() == HkCharacterStateType.HK_CHARACTER_IN_AIR) || (characterProxy.GetState() == ((HkCharacterStateType)5)))) { base.Character.StartFalling(); } else if ((currentMovementState != MyCharacterMovementEnum.Standing) && !newState) { base.Character.PlayCharacterAnimation("Idle", MyBlendOption.Immediate, MyFrameOption.Loop, 0.2f, 1f, false, null, false); base.Character.SetCurrentMovementState(MyCharacterMovementEnum.Standing); currentMovementState = base.Character.GetCurrentMovementState(); } } if (this.Running && (currentMovementState != MyCharacterMovementEnum.Died)) { base.Character.PlayCharacterAnimation("Jetpack", MyBlendOption.Immediate, MyFrameOption.Loop, 0f, 1f, false, null, false); base.Character.SetCurrentMovementState(MyCharacterMovementEnum.Flying); base.Character.SetLocalHeadAnimation(0f, 0f, 0.3f); characterProxy.PosX = 0f; characterProxy.PosY = 0f; } if ((!fromLoad && !newState) && (base.Character.Physics.Gravity.LengthSquared() <= 0.1f)) { this.CurrentAutoEnableDelay = -1f; } } } } }