示例#1
0
        public void Unregister(MyGyro gyro)
        {
            MyDebug.AssertDebug(gyro != null);
            MyDebug.AssertDebug(m_gyros.Contains(gyro));
            m_gyros.Remove(gyro);
            m_gyrosChanged = true;

            gyro.EnabledChanged -= gyro_EnabledChanged;
            gyro.SlimBlock.ComponentStack.IsFunctionalChanged -= ComponentStack_IsFunctionalChanged;
        }
示例#2
0
        public void Register(MyGyro gyro)
        {
            MyDebug.AssertDebug(gyro != null);
            MyDebug.AssertDebug(!m_gyros.Contains(gyro));
            m_gyros.Add(gyro);
            m_gyrosChanged = true;

            gyro.EnabledChanged += gyro_EnabledChanged;
            gyro.SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
            gyro.PropertiesChanged += gyro_PropertiesChanged;
        }
示例#3
0
        // ReSharper disable once InconsistentNaming
        private static void InitPatch(MyGyro __instance)
        {
            var max = ((MyGyroDefinition)_gyroDefinition.GetValue(__instance)).CubeSize == MyCubeSize.Small
                ? MyGridPhysics.GetSmallShipMaxAngularVelocity()
                : MyGridPhysics.GetLargeShipMaxAngularVelocity();

            _gyroOverrideVelocity.GetSync <Vector3>(__instance).ValueChangedInRange(
                new Vector3(-max, -max, -max),
                new Vector3(max, max, max)
                );
        }
示例#4
0
        public void SetupGrid()
        {
            foreach (MyCubeBlock block in _thisGrid.GetFatBlocks())
            {
                MyThrust myThrust = block as MyThrust;
                if (myThrust != null)
                {
                    _gridSystems.ControllableThrusters.AddNewThruster(myThrust);
                    WriteToLog("SetupGrid", $"Adding Thruster {myThrust.GridThrustDirection}", LogType.General);
                    continue;
                }

                MyGyro myGyro = block as MyGyro;
                if (myGyro != null)
                {
                    _gridSystems.ControllableGyros.Add(myGyro);
                    WriteToLog("SetupGrid", $"Adding Gyro", LogType.General);
                    continue;
                }

                IMyTextSurface surface = block as IMyTextSurface;
                if (surface != null)
                {
                    if (((IMyTerminalBlock)surface).CustomData.Contains("DebugL"))
                    {
                        _gridSystems.DebugScreens.AddLeftScreen(surface);
                        _gridSystems.DebugScreens.WriteToLeft(new StringBuilder("Left Debug Screen Detected"));
                        WriteToLog("SetupGrid", $"Adding Left Debug Screen", LogType.General);
                    }

                    if (((IMyTerminalBlock)surface).CustomData.Contains("DebugR"))
                    {
                        _gridSystems.DebugScreens.AddRightScreen(surface);
                        _gridSystems.DebugScreens.WriteToRight(new StringBuilder("Right Debug Screen Detected"));
                        WriteToLog("SetupGrid", $"Adding Right Debug Screen", LogType.General);
                    }
                    continue;
                }

                IMyLandingGear gear = block as IMyLandingGear;
                if (gear == null)
                {
                    continue;
                }
                _gridSystems.ControllableLandingGear.Add(gear);
            }
        }
示例#5
0
        public override void UpdateOnceBeforeFrame()
        {
            Gyro = (MyGyro)Entity;

            if (Gyro?.CubeGrid?.Physics == null)
            {
                return;
            }

            if (TryGetSubparts())
            {
                SubpartOuter.NeedsWorldMatrix = true;
            }

            Gyro.IsWorkingChanged += SetEmissiveColor;

            SetEmissiveColor(Gyro);

            NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
        }
示例#6
0
 public virtual void UnregisterFromSystems(MyCubeBlock block)
 {
     if (block.GetType() != typeof(MyCubeBlock))
     {
         if (this.ResourceDistributor != null)
         {
             MyResourceSourceComponent source = block.Components.Get <MyResourceSourceComponent>();
             if (source != null)
             {
                 this.ResourceDistributor.RemoveSource(source);
             }
             MyResourceSinkComponent sink = block.Components.Get <MyResourceSinkComponent>();
             if (sink != null)
             {
                 this.ResourceDistributor.RemoveSink(sink, true, false);
             }
             IMyRechargeSocketOwner owner = block as IMyRechargeSocketOwner;
             if (owner != null)
             {
                 owner.RechargeSocket.ResourceDistributor = null;
             }
         }
         if (this.WeaponSystem != null)
         {
             IMyGunObject <MyDeviceBase> gun = block as IMyGunObject <MyDeviceBase>;
             if (gun != null)
             {
                 this.WeaponSystem.Unregister(gun);
             }
         }
         if (this.TerminalSystem != null)
         {
             MyTerminalBlock block5 = block as MyTerminalBlock;
             if (block5 != null)
             {
                 this.TerminalSystem.Remove(block5);
             }
         }
         if (block.HasInventory)
         {
             this.ConveyorSystem.Remove(block);
         }
         IMyConveyorEndpointBlock block2 = block as IMyConveyorEndpointBlock;
         if (block2 != null)
         {
             this.ConveyorSystem.RemoveConveyorBlock(block2);
         }
         IMyConveyorSegmentBlock segmentBlock = block as IMyConveyorSegmentBlock;
         if (segmentBlock != null)
         {
             this.ConveyorSystem.RemoveSegmentBlock(segmentBlock);
         }
         MyReflectorLight reflector = block as MyReflectorLight;
         if (reflector != null)
         {
             this.ReflectorLightSystem.Unregister(reflector);
         }
         MyDataBroadcaster broadcaster = block.Components.Get <MyDataBroadcaster>();
         if (broadcaster != null)
         {
             this.RadioSystem.Unregister(broadcaster);
         }
         MyDataReceiver reciever = block.Components.Get <MyDataReceiver>();
         if (reciever != null)
         {
             this.RadioSystem.Unregister(reciever);
         }
         if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT)
         {
             MyMotorSuspension motor = block as MyMotorSuspension;
             if (motor != null)
             {
                 this.WheelSystem.Unregister(motor);
             }
         }
         IMyLandingGear gear = block as IMyLandingGear;
         if (gear != null)
         {
             this.LandingSystem.Unregister(gear);
         }
         MyGyro gyro = block as MyGyro;
         if (gyro != null)
         {
             this.GyroSystem.Unregister(gyro);
         }
         MyCameraBlock camera = block as MyCameraBlock;
         if (camera != null)
         {
             this.CameraSystem.Unregister(camera);
         }
     }
     block.OnUnregisteredFromGridSystems();
 }
示例#7
0
 public virtual void RegisterInSystems(MyCubeBlock block)
 {
     if (block.GetType() != typeof(MyCubeBlock))
     {
         MyCubeBlock block1;
         if (this.ResourceDistributor != null)
         {
             MyResourceSourceComponent source = block.Components.Get <MyResourceSourceComponent>();
             if (source != null)
             {
                 this.ResourceDistributor.AddSource(source);
             }
             MyResourceSinkComponent sink = block.Components.Get <MyResourceSinkComponent>();
             if (!(block is MyThrust) && (sink != null))
             {
                 this.ResourceDistributor.AddSink(sink);
             }
             IMyRechargeSocketOwner owner = block as IMyRechargeSocketOwner;
             if (owner != null)
             {
                 owner.RechargeSocket.ResourceDistributor = this.ResourceDistributor;
             }
         }
         if (this.WeaponSystem != null)
         {
             IMyGunObject <MyDeviceBase> gun = block as IMyGunObject <MyDeviceBase>;
             if (gun != null)
             {
                 this.WeaponSystem.Register(gun);
             }
         }
         if (this.TerminalSystem != null)
         {
             MyTerminalBlock block6 = block as MyTerminalBlock;
             if (block6 != null)
             {
                 this.TerminalSystem.Add(block6);
             }
         }
         if ((block == null) || !block.HasInventory)
         {
             block1 = null;
         }
         else
         {
             block1 = block;
         }
         MyCubeBlock block2 = block1;
         if (block2 != null)
         {
             this.ConveyorSystem.Add(block2);
         }
         IMyConveyorEndpointBlock endpointBlock = block as IMyConveyorEndpointBlock;
         if (endpointBlock != null)
         {
             endpointBlock.InitializeConveyorEndpoint();
             this.ConveyorSystem.AddConveyorBlock(endpointBlock);
         }
         IMyConveyorSegmentBlock segmentBlock = block as IMyConveyorSegmentBlock;
         if (segmentBlock != null)
         {
             segmentBlock.InitializeConveyorSegment();
             this.ConveyorSystem.AddSegmentBlock(segmentBlock);
         }
         MyReflectorLight reflector = block as MyReflectorLight;
         if (reflector != null)
         {
             this.ReflectorLightSystem.Register(reflector);
         }
         if (block.Components.Contains(typeof(MyDataBroadcaster)))
         {
             MyDataBroadcaster broadcaster = block.Components.Get <MyDataBroadcaster>();
             this.RadioSystem.Register(broadcaster);
         }
         if (block.Components.Contains(typeof(MyDataReceiver)))
         {
             MyDataReceiver reciever = block.Components.Get <MyDataReceiver>();
             this.RadioSystem.Register(reciever);
         }
         if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT)
         {
             MyMotorSuspension motor = block as MyMotorSuspension;
             if (motor != null)
             {
                 this.WheelSystem.Register(motor);
             }
         }
         IMyLandingGear gear = block as IMyLandingGear;
         if (gear != null)
         {
             this.LandingSystem.Register(gear);
         }
         MyGyro gyro = block as MyGyro;
         if (gyro != null)
         {
             this.GyroSystem.Register(gyro);
         }
         MyCameraBlock camera = block as MyCameraBlock;
         if (camera != null)
         {
             this.CameraSystem.Register(camera);
         }
     }
     block.OnRegisteredToGridSystems();
 }
示例#8
0
 private bool IsUsed(MyGyro gyro)
 {
     return(gyro.Enabled && gyro.IsFunctional);
 }
示例#9
0
 public GyroWrapper(MySlimBlock block) : base(block)
 {
     Block  = (MyGyro)block.FatBlock;
     IBlock = Block;
 }
示例#10
0
 public MySyncGyro(MyGyro block)
 {
     m_block = block;
 }
示例#11
0
 public void Add(MyGyro gyro)
 {
     gyro.OnClose += Close;
     _gyros.Add(gyro);
     _gyros.ApplyAdditions();
 }