Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Code to block broadcasts from antennas and beacons.
- // Works in situations as player, cockpit, camera.
- // Does not work when player is controlling a turretm or a remote control!!
- // Note: I have no idea how efficient the script is. there may be performance issues
- namespace midspace.BroadcastBlocker.
- {
- using Sandbox.Game.Entities;
- using Sandbox.ModAPI;
- using VRage.Game;
- using VRage.Game.Components;
- using VRage.Game.ModAPI;
- using VRageMath;
- [MySessionComponentDescriptor(MyUpdateOrder.BeforeSimulation)]
- public class SessionComponentLogic : MySessionComponentBase
- {
- private bool _isInitialized;
- public override void UpdateBeforeSimulation()
- {
- if (!_isInitialized && MyAPIGateway.Session != null && MyAPIGateway.Session.Player != null)
- {
- _isInitialized = true; // Set this first to block any other calls from UpdateAfterSimulation().
- }
- if (_isInitialized)
- {
- var character = MyAPIGateway.Session.ControlledObject as IMyCharacter;
- var cockpit = MyAPIGateway.Session.ControlledObject as MyShipController;
- if (character != null)
- {
- MyDataReceiver radioReceiver = character.Components.Get<MyDataReceiver>();
- radioReceiver.Clear();
- }
- if (cockpit != null)
- {
- MyDataReceiver radioReceiver = ((IMyCharacter)(cockpit).Pilot).Components.Get<MyDataReceiver>();
- radioReceiver.Clear();
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment