public MyCubeGridSystems(MyCubeGrid grid) { m_cubeGrid = grid; m_terminalSystem_GroupAdded = TerminalSystem_GroupAdded; m_terminalSystem_GroupRemoved = TerminalSystem_GroupRemoved; ThrustSystem = new MyGridThrustSystem(m_cubeGrid); GyroSystem = new MyGridGyroSystem(m_cubeGrid); WeaponSystem = new MyGridWeaponSystem(); ReflectorLightSystem = new MyGridReflectorLightSystem(m_cubeGrid); if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { WheelSystem = new MyGridWheelSystem(m_cubeGrid); } ConveyorSystem = new MyGridConveyorSystem(m_cubeGrid); LandingSystem = new MyGridLandingSystem(); ControlSystem = new MyGroupControlSystem(); CameraSystem = new MyGridCameraSystem(m_cubeGrid); if (MySession.Static.Settings.EnableOxygen) { OxygenSystem = new MyGridOxygenSystem(m_cubeGrid); } JumpSystem = new MyGridJumpDriveSystem(m_cubeGrid); m_cubeGrid.SyncObject.PowerProducerStateChanged += SyncObject_PowerProducerStateChanged; m_blocksRegistered = true; }
public MyCubeGridSystems(MyCubeGrid grid) { m_cubeGrid = grid; m_terminalSystem_GroupAdded = TerminalSystem_GroupAdded; m_terminalSystem_GroupRemoved = TerminalSystem_GroupRemoved; GyroSystem = new MyGridGyroSystem(m_cubeGrid); WeaponSystem = new MyGridWeaponSystem(); ReflectorLightSystem = new MyGridReflectorLightSystem(m_cubeGrid); if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { WheelSystem = new MyGridWheelSystem(m_cubeGrid); } ConveyorSystem = new MyGridConveyorSystem(m_cubeGrid); LandingSystem = new MyGridLandingSystem(); ControlSystem = new MyGroupControlSystem(); CameraSystem = new MyGridCameraSystem(m_cubeGrid); if (MySession.Static.Settings.EnableOxygen) { GasSystem = new MyGridGasSystem(m_cubeGrid); } if (MyPerGameSettings.EnableJumpDrive) { JumpSystem = new MyGridJumpDriveSystem(m_cubeGrid); } if (MyPerGameSettings.EnableShipSoundSystem && (MyFakes.ENABLE_NEW_SMALL_SHIP_SOUNDS || MyFakes.ENABLE_NEW_LARGE_SHIP_SOUNDS) && MySandboxGame.IsDedicated == false) { ShipSoundComponent = new MyShipSoundComponent(); } m_blocksRegistered = true; }
public MyCubeGridSystems(MyCubeGrid grid) { m_cubeGrid = grid; m_terminalSystem_GroupAdded = TerminalSystem_GroupAdded; m_terminalSystem_GroupRemoved = TerminalSystem_GroupRemoved; GyroSystem = new MyGridGyroSystem(m_cubeGrid); WeaponSystem = new MyGridWeaponSystem(); ReflectorLightSystem = new MyGridReflectorLightSystem(m_cubeGrid); if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { WheelSystem = new MyGridWheelSystem(m_cubeGrid); } ConveyorSystem = new MyGridConveyorSystem(m_cubeGrid); LandingSystem = new MyGridLandingSystem(); ControlSystem = new MyGroupControlSystem(); CameraSystem = new MyGridCameraSystem(m_cubeGrid); if (MySession.Static.Settings.EnableOxygen) { GasSystem = new MyGridGasSystem(m_cubeGrid); } if (MyPerGameSettings.EnableJumpDrive) { JumpSystem = new MyGridJumpDriveSystem(m_cubeGrid); } m_blocksRegistered = true; }
public void DestroyComponent() { for (int i = 0; i < m_emitters.Length; i++) { if (m_emitters[i] != null) { m_emitters[i].StopSound(true); m_emitters[i] = null; } } m_shipGrid = null; m_shipThrusters = null; m_shipWheels = null; }
public void Update100() { //thruster composition + ship category m_distanceToShip = m_initialized && m_shipGrid.Physics != null ? (m_shouldPlay2D ? 0 : (float)Vector3D.DistanceSquared(MySector.MainCamera.Position, m_shipGrid.PositionComp.GetPosition())) : float.MaxValue; if (m_initialized && m_shipGrid.Physics != null && m_shipGrid.IsStatic == false) { if (m_distanceToShip < m_definition.MaxUpdateRange_sq) { if (m_shipThrusters == null) m_shipThrusters = m_shipGrid.Components.Get<MyEntityThrustComponent>(); if (m_shipWheels == null) m_shipWheels = m_shipGrid.GridSystems.WheelSystem; CalculateShipCategory(); if (m_isDebris == false && m_shipState != ShipStateEnum.NoPower && (m_singleThrusterTypeShip == false || ShipHasChanged || m_shipThrusters == null || m_shipThrusters.FinalThrust == Vector3.Zero || m_shipWheels.HasWorkingWheels(false))) CalculateThrusterComposition(); if (m_shipSoundSource == null) m_shipSoundSource = m_shipGrid; if (m_shipGrid.MainCockpit != null && m_shipGrid.GridSizeEnum == MyCubeSize.Small) m_shipSoundSource = m_shipGrid.MainCockpit; if (m_shipGrid.GridSizeEnum == MyCubeSize.Large && MySession.Static.LocalCharacter != null) { BoundingSphereD playerSphere = new BoundingSphereD(MySession.Static.LocalCharacter.PositionComp.GetPosition(), m_definition.LargeShipDetectionRadius); m_shipGrid.GetBlocksInsideSphere(ref playerSphere, m_detectedBlocks); m_insideShip = m_detectedBlocks.Count > 0; } } } //sound emitter update for (int i = 0; i < m_emitters.Length; i++) { m_emitters[i].Entity = m_shipSoundSource; m_emitters[i].Update(); } //wheel contact point callbacks if (m_shipGrid.Physics != null && m_shipWheels != null && m_shipWheels.WheelCount > 0) { bool start = m_distanceToShip < m_definition.WheelsCallbackRangeCreate_sq && m_isDebris == false; bool stop = m_distanceToShip > m_definition.WheelsCallbackRangeRemove_sq || m_isDebris; if ((start || stop) && (m_lastWheelUpdateStart != start || m_lastWheelUpdateStop != stop)) { foreach (var motor in m_shipWheels.Wheels) { if (motor.RotorGrid == null || motor.RotorGrid.Physics == null) continue; if (motor.RotorGrid.HasShipSoundEvents == false && start) { motor.RotorGrid.Physics.RigidBody.ContactPointCallback += RigidBody_ContactPointCallback; motor.RotorGrid.Physics.RigidBody.CallbackLimit = 1; motor.RotorGrid.OnClosing += RotorGrid_OnClosing; motor.RotorGrid.HasShipSoundEvents = true; } else if (motor.RotorGrid.HasShipSoundEvents && stop) { motor.RotorGrid.HasShipSoundEvents = false; motor.RotorGrid.Physics.RigidBody.ContactPointCallback -= RigidBody_ContactPointCallback; motor.RotorGrid.OnClosing -= RotorGrid_OnClosing; } } m_lastWheelUpdateStart = start; m_lastWheelUpdateStop = stop; if (start && m_shipWheelsAction == false) { m_shipWheels.OnMotorUnregister += m_shipWheels_OnMotorUnregister; m_shipWheelsAction = true; } else if (stop && m_shipWheelsAction) { m_shipWheels.OnMotorUnregister -= m_shipWheels_OnMotorUnregister; m_shipWheelsAction = false; } } } }
public bool InitComponent(MyCubeGrid shipGrid) { if (shipGrid.GridSizeEnum == MyCubeSize.Small && MyFakes.ENABLE_NEW_SMALL_SHIP_SOUNDS == false) return false; if (shipGrid.GridSizeEnum == MyCubeSize.Large && MyFakes.ENABLE_NEW_LARGE_SHIP_SOUNDS == false) return false; m_shipGrid = shipGrid; m_shipThrusters = m_shipGrid.Components.Get<MyEntityThrustComponent>(); m_shipWheels = m_shipGrid.GridSystems.WheelSystem; m_thrusterVolumes = new float[(Enum.GetNames(typeof(ShipThrusters)).Length)]; m_thrusterVolumeTargets = new float[(Enum.GetNames(typeof(ShipThrusters)).Length)]; for (int i = 1; i < m_thrusterVolumes.Length; i++) { m_thrusterVolumes[i] = 0f; m_thrusterVolumeTargets[i] = 0f; } m_thrusterVolumes[0] = 1f; m_thrusterVolumeTargets[0] = 1f; for (int i = 0; i < m_emitters.Length; i++) { m_emitters[i] = new MyEntity3DSoundEmitter(m_shipGrid); m_emitters[i].Force2D = m_shouldPlay2D; m_emitters[i].Force3D = !m_shouldPlay2D; } m_initialized = true; return true; }
//thruster composition + ship category private void UpdateCategory() { if (m_initialized && m_shipGrid != null && m_shipGrid.Physics != null && m_shipGrid.IsStatic == false && m_definition != null) { if (m_distanceToShip < m_definition.MaxUpdateRange_sq) { if (m_shipThrusters == null) m_shipThrusters = m_shipGrid.Components.Get<MyEntityThrustComponent>(); if (m_shipWheels == null) m_shipWheels = m_shipGrid.GridSystems.WheelSystem; CalculateShipCategory(); if (m_isDebris == false && m_shipState != ShipStateEnum.NoPower && (m_singleThrusterTypeShip == false || ShipHasChanged || m_shipThrusters == null || m_shipThrusters.FinalThrust == Vector3.Zero || (m_shipWheels != null && m_shipWheels.HasWorkingWheels(false)))) CalculateThrusterComposition(); if (m_shipSoundSource == null) m_shipSoundSource = m_shipGrid; if (m_shipGrid.MainCockpit != null && m_shipGrid.GridSizeEnum == MyCubeSize.Small) m_shipSoundSource = m_shipGrid.MainCockpit; if (m_shipGrid.GridSizeEnum == MyCubeSize.Large && MySession.Static != null && MySession.Static.LocalCharacter != null) { if (MySession.Static.Settings.RealisticSound == false || (MySession.Static.LocalCharacter.AtmosphereDetectorComp != null && (MySession.Static.LocalCharacter.AtmosphereDetectorComp.InAtmosphere || MySession.Static.LocalCharacter.AtmosphereDetectorComp.InShipOrStation))) { BoundingSphereD playerSphere = new BoundingSphereD(MySession.Static.LocalCharacter.PositionComp.GetPosition(), m_definition.LargeShipDetectionRadius); m_shipGrid.GetBlocksInsideSphere(ref playerSphere, m_detectedBlocks); m_insideShip = m_detectedBlocks.Count > 0; } else m_insideShip = false; } } } }