Esempio n. 1
0
 public void Init(ConveyorSystem cs)
 {
     conveyor    = cs;
     pointIndex  = -1;
     targetPoint = null;
     conveyor.SetTarget(this);
 }
Esempio n. 2
0
        public virtual void UpdateBeforeSimulation()
        {
            ProfilerShort.Begin("Thrusters and gyro");
            ThrustSystem.UpdateBeforeSimulation();
            GyroSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT)
            {
                ProfilerShort.Begin("Wheels");
                WheelSystem.UpdateBeforeSimulation();
                ProfilerShort.End();
            }

            ProfilerShort.Begin("Conveyors");
            ConveyorSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            ProfilerShort.Begin("Control");
            ControlSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            ProfilerShort.Begin("Cameras");
            CameraSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            if (MySession.Static.Settings.EnableOxygen)
            {
                ProfilerShort.Begin("Oxygen");
                OxygenSystem.UpdateBeforeSimulation();
                ProfilerShort.End();
            }
        }
        public virtual void GetObjectBuilder(MyObjectBuilder_CubeGrid ob)
        {
            ob.DampenersEnabled = ThrustSystem.DampenersEnabled;

            ConveyorSystem.SerializeLines(ob.ConveyorLines);
            if (ob.ConveyorLines.Count == 0)
            {
                ob.ConveyorLines = null;
            }

            if (WheelSystem != null)
            {
                ob.Handbrake = WheelSystem.HandBrake;
            }

            if (MySession.Static.Settings.EnableOxygen)
            {
                ob.OxygenAmount = OxygenSystem.GetOxygenAmount();
            }

            if (MyPerGameSettings.EnableJumpDrive)
            {
                ob.JumpDriveDirection = JumpSystem.GetJumpDriveDirection();
                ob.JumpElapsedTicks   = JumpSystem.GetJumpElapsedTicks();
            }
        }
        public virtual void GetObjectBuilder(MyObjectBuilder_CubeGrid ob)
        {
            var thrustComp = CubeGrid.Components.Get <MyEntityThrustComponent>();

            ob.DampenersEnabled = thrustComp == null || thrustComp.DampenersEnabled;

            ConveyorSystem.SerializeLines(ob.ConveyorLines);
            if (ob.ConveyorLines.Count == 0)
            {
                ob.ConveyorLines = null;
            }

            if (WheelSystem != null)
            {
                ob.Handbrake = WheelSystem.HandBrake;
            }

            if (MySession.Static.Settings.EnableOxygen && MySession.Static.Settings.EnableOxygenPressurization)
            {
                ob.OxygenAmount = GasSystem.GetOxygenAmount();
            }

            if (MyPerGameSettings.EnableJumpDrive)
            {
                ob.JumpDriveDirection = JumpSystem.GetJumpDriveDirection();
                ob.JumpRemainingTime  = JumpSystem.GetRemainingJumpTime();
            }
        }
 public virtual void AfterGridClose()
 {
     ConveyorSystem.AfterGridClose();
     if (MyPerGameSettings.EnableJumpDrive)
     {
         JumpSystem.AfterGridClose();
     }
     m_blocksRegistered = false;
 }
        public virtual void AfterGridClose()
        {
            ConveyorSystem.AfterGridClose();
            if (MyPerGameSettings.EnableJumpDrive)
            {
                JumpSystem.AfterGridClose();
            }
            m_blocksRegistered = false;

            // Clear out gas system
            GasSystem = null;
        }
        public virtual void OnBlockIntegrityChanged(MySlimBlock block)
        {
            IMyConveyorEndpointBlock conveyorEndpointBlock = block.FatBlock as IMyConveyorEndpointBlock;

            if (conveyorEndpointBlock != null)
            {
                ConveyorSystem.FlagForRecomputation();
            }

            IMyConveyorSegmentBlock conveyorSegmentBlock = block.FatBlock as IMyConveyorSegmentBlock;

            if (conveyorSegmentBlock != null)
            {
                ConveyorSystem.FlagForRecomputation();
            }
        }
Esempio n. 8
0
        public virtual void UpdateBeforeSimulation()
        {
            ProfilerShort.Begin("Thrusters and Gyro");
            MyEntityThrustComponent thrustComp;

            if (CubeGrid.Components.TryGet(out thrustComp))
            {
                thrustComp.UpdateBeforeSimulation();
            }

            GyroSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT)
            {
                ProfilerShort.Begin("Wheels");
                WheelSystem.UpdateBeforeSimulation();
                ProfilerShort.End();
            }

            ProfilerShort.Begin("Conveyors");
            ConveyorSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            ProfilerShort.Begin("Control");
            ControlSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            ProfilerShort.Begin("Cameras");
            CameraSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            if (MySession.Static.Settings.EnableOxygen)
            {
                ProfilerShort.Begin("Oxygen");
                GasSystem.UpdateBeforeSimulation();
                ProfilerShort.End();
            }

            if (MyPerGameSettings.EnableJumpDrive)
            {
                ProfilerShort.Begin("Jump");
                JumpSystem.UpdateBeforeSimulation();
                ProfilerShort.End();
            }
        }
        public virtual void DebugDraw()
        {
            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_TERMINAL_SYSTEMS)
            {
                MyRenderProxy.DebugDrawText3D(m_cubeGrid.WorldMatrix.Translation, TerminalSystem.GetHashCode().ToString(), Color.NavajoWhite, 1.0f, false);
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_CONVEYORS)
            {
                ConveyorSystem.DebugDraw(m_cubeGrid);
                ConveyorSystem.DebugDrawLinePackets();
            }

            if (MySession.Static.Settings.EnableOxygen && MySession.Static.Settings.EnableOxygenPressurization && MyDebugDrawSettings.DEBUG_DRAW_OXYGEN)
            {
                GasSystem.DebugDraw();
            }
        }
        private void Convey(ConveyorSystem system, ConveyorComponent comp, float frameTime)
        {
            // Use an event for conveyors to know what needs to run
            if (!system.CanRun(comp))
            {
                return;
            }

            var direction = system.GetAngle(comp).ToVec();
            var entMan    = IoCManager.Resolve <IEntityManager>();
            var ownerPos  = entMan.GetComponent <TransformComponent>(comp.Owner).WorldPosition;

            foreach (var(entity, physics) in EntitySystem.Get <ConveyorSystem>().GetEntitiesToMove(comp))
            {
                var itemRelativeToConveyor = entMan.GetComponent <TransformComponent>(entity).WorldPosition - ownerPos;
                physics.LinearVelocity += Convey(direction, comp.Speed, frameTime, itemRelativeToConveyor);
            }
        }
Esempio n. 11
0
        public virtual void GetObjectBuilder(MyObjectBuilder_CubeGrid ob)
        {
            ob.DampenersEnabled = ThrustSystem.DampenersEnabled;

            ConveyorSystem.SerializeLines(ob.ConveyorLines);
            if (ob.ConveyorLines.Count == 0)
            {
                ob.ConveyorLines = null;
            }

            if (WheelSystem != null)
            {
                ob.Handbrake = WheelSystem.HandBrake;
            }

            if (MySession.Static.Settings.EnableOxygen)
            {
                ob.OxygenAmount = OxygenSystem.GetOxygenAmount();
            }
        }
        public virtual void OnBlockRemoved(MySlimBlock block)
        {
            IMyConveyorEndpointBlock conveyorEndpointBlock = block.FatBlock as IMyConveyorEndpointBlock;

            if (conveyorEndpointBlock != null)
            {
                ConveyorSystem.FlagForRecomputation();
            }

            IMyConveyorSegmentBlock conveyorSegmentBlock = block.FatBlock as IMyConveyorSegmentBlock;

            if (conveyorSegmentBlock != null)
            {
                ConveyorSystem.FlagForRecomputation();
            }

            if (ShipSoundComponent != null && block.FatBlock as MyThrust != null)
            {
                ShipSoundComponent.ShipHasChanged = true;
            }
        }
 public virtual void UpdateBeforeSimulation10()
 {
     UpdatePower();
     CameraSystem.UpdateBeforeSimulation10();
     ConveyorSystem.UpdateBeforeSimulation10();
 }
        public virtual void UnregisterFromSystems(MyCubeBlock block)
        {
            // Note: ResourceDistributor, WeaponSystem and TemrminalSystem can be null on closing (they are not in the ship but in the logical group). That's why they are null-checked
            if (ResourceDistributor != null)
            {
                ProfilerShort.Begin("Unregister Power producer");
                var powerProducer = block.Components.Get <MyResourceSourceComponent>();
                if (powerProducer != null)
                {
                    ResourceDistributor.RemoveSource(powerProducer);
                }

                ProfilerShort.BeginNextBlock("Unregister Power consumer");
                var powerConsumer = block.Components.Get <MyResourceSinkComponent>();
                if (!(block is MyThrust) && powerConsumer != null)
                {
                    ResourceDistributor.RemoveSink(powerConsumer);
                }

                ProfilerShort.End();

                var socketOwner = block as IMyRechargeSocketOwner;
                if (socketOwner != null)
                {
                    socketOwner.RechargeSocket.ResourceDistributor = null;
                }
            }

            ProfilerShort.Begin("Unregister gun object");
            if (WeaponSystem != null)
            {
                var weapon = block as IMyGunObject <MyDeviceBase>;
                if (weapon != null)
                {
                    WeaponSystem.Unregister(weapon);
                }
            }

            ProfilerShort.BeginNextBlock("Unregister functional block");
            if (TerminalSystem != null)
            {
                var functionalBlock = block as MyTerminalBlock;
                if (functionalBlock != null)
                {
                    TerminalSystem.Remove(functionalBlock);
                }
            }

            // CH: We probably don't need to unregister controller blocks here. It's done in ShipController's OnUnregisteredFromGridSystems

            /*ProfilerShort.BeginNextBlock("Unregister controller block");
             * if (ControlSystem != null)
             * {
             *  var controllableBlock = block as MyShipController;
             *  if (controllableBlock != null && controllableBlock.ControllerInfo.Controller != null)
             *      ControlSystem.RemoveControllerBlock(controllableBlock);
             * }*/

            ProfilerShort.BeginNextBlock("Unregister inventory block");
            var inventoryBlock = (block != null && block.HasInventory) ? block : null;

            if (inventoryBlock != null && inventoryBlock.HasInventory)
            {
                ConveyorSystem.Remove(inventoryBlock);
            }

            ProfilerShort.BeginNextBlock("Unregister conveyor block");
            var conveyorBlock = block as IMyConveyorEndpointBlock;

            if (conveyorBlock != null)
            {
                ConveyorSystem.RemoveConveyorBlock(conveyorBlock);
            }

            ProfilerShort.BeginNextBlock("Unregister segment block");
            var segmentBlock = block as IMyConveyorSegmentBlock;

            if (segmentBlock != null)
            {
                ConveyorSystem.RemoveSegmentBlock(segmentBlock);
            }

            ProfilerShort.BeginNextBlock("Unregister Reflector light");
            var reflectorLight = block as MyReflectorLight;

            if (reflectorLight != null)
            {
                ReflectorLightSystem.Unregister(reflectorLight);
            }

            if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT)
            {
                ProfilerShort.BeginNextBlock("Unregister wheel");
                var wheel = block as MyMotorSuspension;
                if (wheel != null)
                {
                    WheelSystem.Unregister(wheel);
                }
            }

            ProfilerShort.BeginNextBlock("Unregister landing gear");
            var gear = block as IMyLandingGear;

            if (gear != null)
            {
                LandingSystem.Unregister(gear);
            }

            ProfilerShort.BeginNextBlock("Unregister gyro");
            var gyro = block as MyGyro;

            if (gyro != null)
            {
                GyroSystem.Unregister(gyro);
            }

            ProfilerShort.BeginNextBlock("Unregister camera");
            var camera = block as MyCameraBlock;

            if (camera != null)
            {
                CameraSystem.Unregister(camera);
            }

            ProfilerShort.BeginNextBlock("block.OnUnregisteredFromGridSystems()");
            block.OnUnregisteredFromGridSystems();

            ProfilerShort.End();
        }
Esempio n. 15
0
 public virtual void AfterBlockDeserialization()
 {
     ConveyorSystem.AfterBlockDeserialization();
     ConveyorSystem.PowerReceiver.Update();
 }
        public virtual void RegisterInSystems(MyCubeBlock block)
        {
            if (ResourceDistributor != null)
            {
                var powerProducer = block.Components.Get <MyResourceSourceComponent>();
                if (powerProducer != null)
                {
                    ResourceDistributor.AddSource(powerProducer);
                }

                var powerConsumer = block.Components.Get <MyResourceSinkComponent>();
                if (!(block is MyThrust) && powerConsumer != null)
                {
                    ResourceDistributor.AddSink(powerConsumer);
                }

                var socketOwner = block as IMyRechargeSocketOwner;
                if (socketOwner != null)
                {
                    socketOwner.RechargeSocket.ResourceDistributor = ResourceDistributor;
                }
            }

            if (WeaponSystem != null)
            {
                var weapon = block as IMyGunObject <MyDeviceBase>;
                if (weapon != null)
                {
                    WeaponSystem.Register(weapon);
                }
            }

            if (TerminalSystem != null)
            {
                var functionalBlock = block as MyTerminalBlock;
                if (functionalBlock != null)
                {
                    TerminalSystem.Add(functionalBlock);
                }
            }

            // CH: We probably don't need to register controller blocks here. Block that's being added to a grid should not have a controller set
            var controllableBlock = block as MyShipController;

            Debug.Assert(controllableBlock == null || controllableBlock.ControllerInfo.Controller == null, "Controller of added block is not null. Call Cestmir");

            /*if (ControlSystem != null)
             * {
             *  var controllableBlock = block as MyShipController;
             *  if (controllableBlock != null && controllableBlock.ControllerInfo.Controller != null)
             *      ControlSystem.AddControllerBlock(controllableBlock);
             * }*/

            var inventoryBlock = (block != null && block.HasInventory) ? block : null;

            if (inventoryBlock != null)
            {
                ConveyorSystem.Add(inventoryBlock);
            }

            var conveyorBlock = block as IMyConveyorEndpointBlock;

            if (conveyorBlock != null)
            {
                conveyorBlock.InitializeConveyorEndpoint();
                ConveyorSystem.AddConveyorBlock(conveyorBlock);
            }

            var segmentBlock = block as IMyConveyorSegmentBlock;

            if (segmentBlock != null)
            {
                segmentBlock.InitializeConveyorSegment();
                ConveyorSystem.AddSegmentBlock(segmentBlock);
            }

            var reflectorLight = block as MyReflectorLight;

            if (reflectorLight != null)
            {
                ReflectorLightSystem.Register(reflectorLight);
            }

            if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT)
            {
                var wheel = block as MyMotorSuspension;
                if (wheel != null)
                {
                    WheelSystem.Register(wheel);
                }
            }

            var landingGear = block as IMyLandingGear;

            if (landingGear != null)
            {
                LandingSystem.Register(landingGear);
            }

            var gyro = block as MyGyro;

            if (gyro != null)
            {
                GyroSystem.Register(gyro);
            }

            var camera = block as MyCameraBlock;

            if (camera != null)
            {
                CameraSystem.Register(camera);
            }

            block.OnRegisteredToGridSystems();
        }
 public virtual void BeforeBlockDeserialization(MyObjectBuilder_CubeGrid builder)
 {
     ConveyorSystem.BeforeBlockDeserialization(builder.ConveyorLines);
 }
 public virtual void AfterBlockDeserialization()
 {
     ConveyorSystem.AfterBlockDeserialization();
     ConveyorSystem.ResourceSink.Update();
 }
 public virtual void UpdateAfterSimulation100()
 {
     ConveyorSystem.UpdateAfterSimulation100();
 }
Esempio n. 20
0
 public void OnEnable()
 {
     target_CS = (ConveyorSystem)target;
 }
 public virtual void OnBlockOwnershipChanged(MyCubeGrid cubeGrid)
 {
     ConveyorSystem.FlagForRecomputation();
 }
 public virtual void PrepareForDraw()
 {
     ConveyorSystem.PrepareForDraw();
     CameraSystem.PrepareForDraw();
 }
Esempio n. 23
0
 public virtual void AfterGridClose()
 {
     ConveyorSystem.AfterGridClose();
     m_blocksRegistered = false;
 }