当前位置: 首页>>代码示例>>C#>>正文


C# MyToolbar.Init方法代码示例

本文整理汇总了C#中Sandbox.Game.Screens.Helpers.MyToolbar.Init方法的典型用法代码示例。如果您正苦于以下问题:C# MyToolbar.Init方法的具体用法?C# MyToolbar.Init怎么用?C# MyToolbar.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sandbox.Game.Screens.Helpers.MyToolbar的用法示例。


在下文中一共展示了MyToolbar.Init方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;
            base.Init(objectBuilder, cubeGrid);

            //MyDebug.AssertDebug(objectBuilder.TypeId == typeof(MyObjectBuilder_ShipController));
            var def = MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
            m_enableFirstPerson = BlockDefinition.EnableFirstPerson || MySession.Static.Settings.Enable3rdPersonView == false;
            m_enableShipControl = BlockDefinition.EnableShipControl;


            m_rechargeSocket = new MyRechargeSocket();

            MyObjectBuilder_ShipController shipControllerOb = (MyObjectBuilder_ShipController)objectBuilder;

            // No need for backward compatibility of selected weapon, we just leave it alone
            //            m_selectedGunType = shipControllerOb.SelectedGunType;
            m_selectedGunId = shipControllerOb.SelectedGunId;

            m_controlThrusters = shipControllerOb.ControlThrusters;
            m_controlWheels = shipControllerOb.ControlWheels;

            if (shipControllerOb.IsMainCockpit)
            {
                IsMainCockpit = true;
            }

            Toolbar = new MyToolbar(ToolbarType);

            Toolbar.Init(shipControllerOb.Toolbar, this);

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            // TODO: Seems like overkill
            if (Sync.IsServer && false)
            {
                //Because of simulating thrusts
                NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;
            }

            CubeGrid.OnGridSplit += CubeGrid_OnGridSplit;
        }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:42,代码来源:MyShipController.cs

示例2: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;

            var sinkComp = new MyResourceSinkComponent();
            sinkComp.Init(
                BlockDefinition.ResourceSinkGroup,
                BlockDefinition.RequiredPowerInput,
                this.CalculateRequiredPowerInput);
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);

            m_items = new List<ToolbarItem>(2);
            for (int i = 0; i < 2; i++)
            {
                m_items.Add(new ToolbarItem() { EntityID = 0 });
            }
            Toolbar = new MyToolbar(MyToolbarType.ButtonPanel, 2, 1);
            Toolbar.DrawNumbers = false;

            var builder = (MyObjectBuilder_SensorBlock)objectBuilder;
            
            m_fieldMin.Value = Vector3.Clamp(builder.FieldMin, new Vector3(-MaxRange), -Vector3.One);
            m_fieldMax.Value = Vector3.Clamp(builder.FieldMax, Vector3.One, new Vector3(MaxRange));

            PlayProximitySound = builder.PlaySound;
            DetectPlayers = builder.DetectPlayers;
            DetectFloatingObjects = builder.DetectFloatingObjects;
            DetectSmallShips = builder.DetectSmallShips;
            DetectLargeShips = builder.DetectLargeShips;
            DetectStations = builder.DetectStations;
            DetectAsteroids = builder.DetectAsteroids;
            DetectOwner = builder.DetectOwner;
            DetectFriendly = builder.DetectFriendly;
            DetectNeutral = builder.DetectNeutral;
            DetectEnemy = builder.DetectEnemy;
            m_active.Value = builder.IsActive;

            Toolbar.Init(builder.Toolbar, this);

            for (int i = 0; i < 2; i++)
            {
                var item = Toolbar.GetItemAtIndex(i);
                if (item == null)
                    continue;
                m_items.RemoveAt(i);
                m_items.Insert(i, ToolbarItem.FromItem(item));
            }
            Toolbar.ItemChanged += Toolbar_ItemChanged;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME;

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

			
			ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
			ResourceSink.RequiredInputChanged += Receiver_RequiredInputChanged;
			ResourceSink.Update();

            m_fieldShape = GetHkShape();

            OnClose += delegate(MyEntity self)
            {
                m_fieldShape.RemoveReference();
            };

            m_gizmoColor = MySandboxGame.IsDirectX11 ? new Vector4(0.35f, 0, 0, 0.5f) : new Vector4(0.1f, 0, 0, 0.1f);

        }
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:70,代码来源:MySensorBlock.cs

示例3: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;

            base.Init(objectBuilder, cubeGrid);

            var builder = (MyObjectBuilder_AirVent)objectBuilder;

            InitializeConveyorEndpoint();
            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            SourceComp.Init(BlockDefinition.ResourceSourceGroup, new MyResourceSourceInfo { ResourceTypeId = m_oxygenGasId, DefinedOutput = BlockDefinition.VentilationCapacityPerSecond, ProductionToCapacityMultiplier = 1 });
            SourceComp.OutputChanged += Source_OutputChanged;
            FillSinkInfo();
            var sinkDataList = new List<MyResourceSinkInfo>
	        {
				new MyResourceSinkInfo {ResourceTypeId = MyResourceDistributorComponent.ElectricityId, MaxRequiredInput = BlockDefinition.OperationalPowerConsumption, RequiredInputFunc = ComputeRequiredPower},
	        };

            ResourceSink.Init(
                BlockDefinition.ResourceSinkGroup,
                sinkDataList);
			ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged;
            ResourceSink.CurrentInputChanged += Sink_CurrentInputChanged;

            m_lastOutputUpdateTime = MySession.Static.GameplayFrameCounter;
            m_lastInputUpdateTime = MySession.Static.GameplayFrameCounter;
            m_nextGasTransfer = 0f;

            m_actionToolbar = new MyToolbar(MyToolbarType.ButtonPanel, 2, 1);
            m_actionToolbar.DrawNumbers = false;
            m_actionToolbar.Init(null, this);

            if (builder.OnFullAction != null)
                m_onFullAction = MyToolbarItemFactory.CreateToolbarItem(builder.OnFullAction);

            if (builder.OnEmptyAction != null)
                m_onEmptyAction = MyToolbarItemFactory.CreateToolbarItem(builder.OnEmptyAction);

            UpdateEmissivity();
            UdpateTexts();

            AddDebugRenderComponent(new Sandbox.Game.Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint));

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
            IsWorkingChanged += MyAirVent_IsWorkingChanged;

            m_isDepressurizing.Value =  builder.IsDepressurizing;

            SetDepressurizing();
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:51,代码来源:MyAirVent.cs

示例4: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true; 
            var sinkComp = new MyResourceSinkComponent();
            sinkComp.Init(
                BlockDefinition.ResourceSinkGroup,
                m_powerNeeded,
                this.CalculateRequiredPowerInput);

           
            ResourceSink = sinkComp;
            base.Init(objectBuilder, cubeGrid);
            NeedsUpdate = MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME;

            var remoteOb = (MyObjectBuilder_RemoteControl)objectBuilder;
            m_savedPreviousControlledEntityId = remoteOb.PreviousControlledEntityId;

            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
            sinkComp.RequiredInputChanged += Receiver_RequiredInputChanged;
			
            sinkComp.Update();

            m_autoPilotEnabled.Value = remoteOb.AutoPilotEnabled;
            m_dockingModeEnabled.Value = remoteOb.DockingModeEnabled;
            m_currentFlightMode.Value = (FlightMode)remoteOb.FlightMode;
            m_currentDirection.Value = (Base6Directions.Direction)remoteOb.Direction;
            m_autopilotSpeedLimit.Value = remoteOb.AutopilotSpeedLimit;
            m_bindedCamera.Value = remoteOb.BindedCamera;
            m_waypointThresholdDistance.Value = remoteOb.WaypointThresholdDistance;
            m_currentAutopilotSpeedLimit = m_autopilotSpeedLimit;

            m_stuckDetection = new MyStuckDetection(0.03f, 0.01f, this.CubeGrid.PositionComp.WorldAABB);

            if (remoteOb.Coords == null || remoteOb.Coords.Count == 0)
            {
                if (remoteOb.Waypoints == null)
                {
                    m_waypoints = new List<MyAutopilotWaypoint>();
                    CurrentWaypoint = null;
                }
                else
                {
                    m_waypoints = new List<MyAutopilotWaypoint>(remoteOb.Waypoints.Count);
                    for (int i = 0; i < remoteOb.Waypoints.Count; i++)
                    {
                        m_waypoints.Add(new MyAutopilotWaypoint(remoteOb.Waypoints[i], this));
                    }
                }
            }
            else
            {
                m_waypoints = new List<MyAutopilotWaypoint>(remoteOb.Coords.Count);
                for (int i = 0; i < remoteOb.Coords.Count; i++)
                {
                    m_waypoints.Add(new MyAutopilotWaypoint(remoteOb.Coords[i], remoteOb.Names[i], this));
                }

                if (remoteOb.AutoPilotToolbar != null && m_currentFlightMode == FlightMode.OneWay)
                {
                    m_waypoints[m_waypoints.Count - 1].SetActions(remoteOb.AutoPilotToolbar.Slots);
                }
            }

            if (remoteOb.CurrentWaypointIndex == -1 || remoteOb.CurrentWaypointIndex >= m_waypoints.Count)
            {
                CurrentWaypoint = null;
            }
            else
            {
                CurrentWaypoint = m_waypoints[remoteOb.CurrentWaypointIndex];
            }

            UpdatePlanetWaypointInfo();

            m_actionToolbar = new MyToolbar(MyToolbarType.ButtonPanel, pageCount: 1);
            m_actionToolbar.DrawNumbers = false;
            m_actionToolbar.Init(null, this);

            m_selectedGpsLocations = new List<IMyGps>();
            m_selectedWaypoints = new List<MyAutopilotWaypoint>();
            UpdateText();

            AddDebugRenderComponent(new MyDebugRenderComponentRemoteControl(this));

            m_useCollisionAvoidance.Value = remoteOb.CollisionAvoidance;

            for (int i = 0; i < TERRAIN_HEIGHT_DETECTION_SAMPLES; i++)
            {
                m_terrainHeightDetection[i] = 0.0f;
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:91,代码来源:MyRemoteControl.cs

示例5: SetupPlayer

        private static void SetupPlayer(ref Args args)
        {
            var identity = Sync.Players.CreateNewIdentity(Sync.Clients.LocalClient.DisplayName);
            var player = Sync.Players.CreateNewPlayer(identity, Sync.Clients.LocalClient, Sync.MyName);
            var playerStarts = args.Scenario.PossiblePlayerStarts;
            if (playerStarts == null || playerStarts.Length == 0)
            {
                Sync.Players.RespawnComponent.SetupCharacterDefault(player, args);
            }
            else
            {
                var randomStart = playerStarts[MyUtils.GetRandomInt(playerStarts.Length)];
                randomStart.SetupCharacter(args);
            }

            // Setup toolbar
            if (args.Scenario.DefaultToolbar != null)
            {
                // TODO: JakubD fix this
                MyToolbar toolbar = new MyToolbar(MyToolbarType.Character);
                toolbar.Init(args.Scenario.DefaultToolbar, player.Character, true);

                MySession.Static.Toolbars.RemovePlayerToolbar(player.Id);
                MySession.Static.Toolbars.AddPlayerToolbar(player.Id, toolbar);
                MyToolbarComponent.InitToolbar(MyToolbarType.Character, args.Scenario.DefaultToolbar);
                MyToolbarComponent.InitCharacterToolbar(args.Scenario.DefaultToolbar);
            }
        }
开发者ID:avivbeeri,项目名称:SpaceEngineers,代码行数:28,代码来源:MyWorldGenerator.cs

示例6: Init

        public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true; 

            var sinkComp = new MyResourceSinkComponent();
            sinkComp.Init(
                BlockDefinition.ResourceSinkGroup,
                0.0001f,
                () => IsFunctional ? 0.0001f : 0);
            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
            sinkComp.IsPoweredChanged += ComponentStack_IsFunctionalChanged;
            ResourceSink = sinkComp;

            base.Init(builder, cubeGrid);
            m_emissiveNames = new List<string>(BlockDefinition.ButtonCount);
            for (int i = 1; i <= BlockDefinition.ButtonCount; i++) //button dummies have 1-based index
            {
                m_emissiveNames.Add(string.Format("Emissive{0}", i)); // because of modding
            }
            var ob = builder as MyObjectBuilder_ButtonPanel;
            Toolbar = new MyToolbar(MyToolbarType.ButtonPanel, Math.Min(BlockDefinition.ButtonCount, MyToolbar.DEF_SLOT_COUNT), (BlockDefinition.ButtonCount / MyToolbar.DEF_SLOT_COUNT) + 1);
            Toolbar.DrawNumbers = false;
            Toolbar.GetSymbol = (slot) =>
                {
                    var ret = new Sandbox.Graphics.GUI.MyGuiControlGrid.ColoredIcon();
                    if(Toolbar.SlotToIndex(slot) < BlockDefinition.ButtonCount) 
                    {
                        ret.Icon = BlockDefinition.ButtonSymbols[Toolbar.SlotToIndex(slot) % BlockDefinition.ButtonSymbols.Length];
                        var color = BlockDefinition.ButtonColors[Toolbar.SlotToIndex(slot) % BlockDefinition.ButtonColors.Length];
                        color.W = 1;
                        ret.Color = color;
                    }
                    return ret;
                };

            Toolbar.Init(ob.Toolbar, this);
            Toolbar.ItemChanged += Toolbar_ItemChanged;
            AnyoneCanUse = ob.AnyoneCanUse;

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
		
            ResourceSink.Update();

            if (ob.CustomButtonNames != null)
            {
                m_customButtonNames = ob.CustomButtonNames;
            }

            NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_FRAME;

            UseObjectsComponent.GetInteractiveObjects<MyUseObjectPanelButton>(m_buttonsUseObjects);
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:52,代码来源:MyButtonPanel.cs

示例7: LoadToolbars

 public void LoadToolbars(MyObjectBuilder_Checkpoint checkpoint)
 {
     if (checkpoint.AllPlayersData != null)
     {
         foreach (var item in checkpoint.AllPlayersData.Dictionary)
         {
             var playerId = new PlayerId(item.Key.ClientId, item.Key.SerialId);
             var toolbar = new MyToolbar(MyToolbarType.Character);
             toolbar.Init(item.Value.Toolbar, null, true);
             AddPlayerToolbar(playerId, toolbar);
         }
     }
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:13,代码来源:MyToolbarCollection.cs

示例8: CreateDefaultToolbar

 private void CreateDefaultToolbar(PlayerId playerId)
 {
     if (ContainsToolbar(playerId))
         return;
     var toolbar = new MyToolbar(MyToolbarType.Character);
     toolbar.Init(MySession.Static.Scenario.DefaultToolbar, null, true);
     AddPlayerToolbar(playerId, toolbar);
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:8,代码来源:MyToolbarCollection.cs

示例9: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;

            var timerBlockDefinition = BlockDefinition as MyTimerBlockDefinition;

            var sinkComp = new MyResourceSinkComponent();
            sinkComp.Init(
                timerBlockDefinition.ResourceSinkGroup,
                0.0000001f,
                () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInput : 0f);
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);

            var ob = objectBuilder as MyObjectBuilder_TimerBlock;

            Toolbar = new MyToolbar(MyToolbarType.ButtonPanel, 9, 10);
            Toolbar.Init(ob.Toolbar, this);
            Toolbar.ItemChanged += Toolbar_ItemChanged;

            if (ob.JustTriggered) NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;

            IsCountingDown = ob.IsCountingDown;
            m_countdownMsStart = ob.Delay;
            m_countdownMsCurrent = ob.CurrentTime;
            Silent = ob.Silent;

            if (m_countdownMsCurrent > 0)
                NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME;
            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink.Update();

            AddDebugRenderComponent(new Sandbox.Game.Components.MyDebugRenderComponentDrawPowerReciever(ResourceSink, this));

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            m_beepStart = new MySoundPair(timerBlockDefinition.TimerSoundStart);
            m_beepMid = new MySoundPair(timerBlockDefinition.TimerSoundMid);
            m_beepEnd = new MySoundPair(timerBlockDefinition.TimerSoundEnd);
            m_beepEmitter = new MyEntity3DSoundEmitter(this);
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:44,代码来源:MyTimerBlock.cs

示例10: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;
            base.Init(objectBuilder, cubeGrid);

            //MyDebug.AssertDebug(objectBuilder.TypeId == typeof(MyObjectBuilder_ShipController));
            var def = MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
            m_enableFirstPerson = BlockDefinition.EnableFirstPerson || MySession.Static.Settings.Enable3rdPersonView == false;
            m_enableShipControl = BlockDefinition.EnableShipControl;
            m_enableBuilderCockpit = BlockDefinition.EnableBuilderCockpit;


            m_rechargeSocket = new MyRechargeSocket();

            MyObjectBuilder_ShipController shipControllerOb = (MyObjectBuilder_ShipController)objectBuilder;

            // No need for backward compatibility of selected weapon, we just leave it alone
            //            m_selectedGunType = shipControllerOb.SelectedGunType;
            m_selectedGunId = shipControllerOb.SelectedGunId;

            ControlThrusters = shipControllerOb.ControlThrusters;
            ControlWheels = shipControllerOb.ControlWheels;

            if (shipControllerOb.IsMainCockpit)
            {
                IsMainCockpit = true;
            }

			HorizonIndicatorEnabled = shipControllerOb.HorizonIndicatorEnabled;
            m_toolbar = new MyToolbar(ToolbarType);
            m_toolbar.Init(shipControllerOb.Toolbar, this);
            m_toolbar.ItemChanged += Toolbar_ItemChanged;

            m_buildToolbar = new MyToolbar(MyToolbarType.BuildCockpit);
            m_buildToolbar.Init(shipControllerOb.BuildToolbar, this);


            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            // TODO: Seems like overkill
            if (Sync.IsServer && false)
            {
                //Because of simulating thrusts
                NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;
            }

			NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            m_baseIdleSound = BlockDefinition.PrimarySound;

            CubeGrid.OnGridSplit += CubeGrid_OnGridSplit;
            Components.ComponentAdded += OnComponentAdded;
            Components.ComponentRemoved += OnComponentRemoved;

            if(EntityThrustComponent != null)
            {
                m_dampenersEnabled.Value = EntityThrustComponent.Enabled;
            }
            UpdateShipInfo();
            if (BlockDefinition.GetInSound != null && BlockDefinition.GetInSound.Length > 0)
                GetInCockpitSound = new MySoundPair(BlockDefinition.GetInSound);
            if (BlockDefinition.GetOutSound != null && BlockDefinition.GetOutSound.Length > 0)
                GetOutOfCockpitSound = new MySoundPair(BlockDefinition.GetOutSound);
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:64,代码来源:MyShipController.cs

示例11: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;
            base.Init(objectBuilder, cubeGrid);

            var ob = objectBuilder as MyObjectBuilder_TimerBlock;

            Toolbar = new MyToolbar(MyToolbarType.ButtonPanel, 9, 10);
            Toolbar.Init(ob.Toolbar, this);
            Toolbar.ItemChanged += Toolbar_ItemChanged;

            if (ob.JustTriggered) NeedsUpdate |= Common.MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
            m_countdownMsStart = ob.Delay;
            m_countdownMsCurrent = ob.CurrentTime;
            if (m_countdownMsCurrent > 0)
                NeedsUpdate |= Common.MyEntityUpdateEnum.EACH_10TH_FRAME;

            PowerReceiver = new MyPowerReceiver(
                MyConsumerGroupEnum.Utility,
                false,
                0.0000001f,
                () => (Enabled && IsFunctional) ? PowerReceiver.MaxRequiredInput : 0f);
            PowerReceiver.Update();

            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawPowerReciever(PowerReceiver,this));

            PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged;
            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:30,代码来源:MyTimerBlock.cs

示例12: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;
            base.Init(objectBuilder, cubeGrid);
            NeedsUpdate = MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME;

            var remoteOb = (MyObjectBuilder_RemoteControl)objectBuilder;
            m_savedPreviousControlledEntityId = remoteOb.PreviousControlledEntityId;


            PowerReceiver = new MyPowerReceiver(
                MyConsumerGroupEnum.Utility,
                false,
                m_powerNeeded,
                this.CalculateRequiredPowerInput);

            PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged;
            PowerReceiver.RequiredInputChanged += Receiver_RequiredInputChanged;
            PowerReceiver.Update();

            m_autoPilotEnabled = remoteOb.AutoPilotEnabled;
            m_dockingModeEnabled = remoteOb.DockingModeEnabled;
            m_currentFlightMode = (FlightMode)remoteOb.FlightMode;
            m_currentDirection = (Base6Directions.Direction)remoteOb.Direction;

            if (remoteOb.Coords == null || remoteOb.Coords.Count == 0)
            {
                if (remoteOb.Waypoints == null)
                {
                    m_waypoints = new List<MyAutopilotWaypoint>();
                    CurrentWaypoint = null;
                }
                else
                {
                    m_waypoints = new List<MyAutopilotWaypoint>(remoteOb.Waypoints.Count);
                    for (int i = 0; i < remoteOb.Waypoints.Count; i++)
                    {
                        m_waypoints.Add(new MyAutopilotWaypoint(remoteOb.Waypoints[i], this));
                    }
                }
            }
            else
            {
                m_waypoints = new List<MyAutopilotWaypoint>(remoteOb.Coords.Count);
                for (int i = 0; i < remoteOb.Coords.Count; i++)
                {
                    m_waypoints.Add(new MyAutopilotWaypoint(remoteOb.Coords[i], remoteOb.Names[i], this));
                }

                if (remoteOb.AutoPilotToolbar != null && m_currentFlightMode == FlightMode.OneWay)
                {
                    m_waypoints[m_waypoints.Count - 1].SetActions(remoteOb.AutoPilotToolbar.Slots);
                }
            }

            if (remoteOb.CurrentWaypointIndex == -1 || remoteOb.CurrentWaypointIndex >= m_waypoints.Count)
            {
                CurrentWaypoint = null;
            }
            else
            {
                CurrentWaypoint = m_waypoints[remoteOb.CurrentWaypointIndex];
            }

            m_actionToolbar = new MyToolbar(MyToolbarType.ButtonPanel, pageCount: 1);
            m_actionToolbar.DrawNumbers = false;
            m_actionToolbar.Init(null, this);

            m_selectedGpsLocations = new List<IMyGps>();
            m_selectedWaypoints = new List<MyAutopilotWaypoint>();
            UpdateText();
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:72,代码来源:MyRemoteControl.cs

示例13: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;

            base.Init(objectBuilder, cubeGrid);

            var builder = (MyObjectBuilder_AirVent)objectBuilder;

            m_isDepressurizing = builder.IsDepressurizing;

            InitializeConveyorEndpoint();
            NeedsUpdate = MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;

            PowerReceiver = new MyPowerReceiver(
                MyConsumerGroupEnum.Factory,
                false,
                BlockDefinition.OperationalPowerConsumption,
                ComputeRequiredPower);
            PowerReceiver.IsPoweredChanged += PowerReceiver_IsPoweredChanged;
            PowerReceiver.Update();

            m_actionToolbar = new MyToolbar(MyToolbarType.ButtonPanel, 2, 1);
            m_actionToolbar.DrawNumbers = false;
            m_actionToolbar.Init(null, this);

            if (builder.OnFullAction != null)
            {
                m_onFullAction = MyToolbarItemFactory.CreateToolbarItem(builder.OnFullAction);
            }
            if (builder.OnEmptyAction != null)
            {
                m_onEmptyAction = MyToolbarItemFactory.CreateToolbarItem(builder.OnEmptyAction);
            }

            UpdateEmissivity();
            UdpateTexts();

            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint));

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:41,代码来源:MyAirVent.cs


注:本文中的Sandbox.Game.Screens.Helpers.MyToolbar.Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。