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


C# MyToolbar.GetItemAtIndex方法代码示例

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


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

示例1: 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

示例2: Toolbar_ItemChanged

        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            if(m_syncing)
            {
                return;
            }
            Debug.Assert(self == Toolbar);

            var tItem = ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex));
            var oldItem = m_items[index.ItemIndex];
            if ((tItem.EntityID == 0 && oldItem.EntityID == 0 || (tItem.EntityID != 0 && oldItem.EntityID != 0 && tItem.Equals(oldItem))))
                return;
            m_items.RemoveAt(index.ItemIndex);
            m_items.Insert(index.ItemIndex, tItem);
            MyMultiplayer.RaiseEvent(this, x => x.SendToolbarItemChanged, tItem, index.ItemIndex);

            if (m_shouldSetOtherToolbars)
            {
                m_shouldSetOtherToolbars = false;

                foreach (var toolbar in m_openedToolbars)
                {
                    if (toolbar != self)
                    {
                        toolbar.SetItemAtIndex(index.ItemIndex, self.GetItemAtIndex(index.ItemIndex));
                    }
                }
                m_shouldSetOtherToolbars = true;
            }
        }
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:30,代码来源:MySensorBlock.cs

示例3: Toolbar_ItemChanged

 private void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
 {
     if (m_syncing)
     {
         return;
     }
     MyMultiplayer.RaiseEvent(this,x => x.SendToolbarItemChanged,ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex)), index.ItemIndex);
 }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:8,代码来源:MyAirVent.cs

示例4: Toolbar_ItemChanged

 void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
 {
     if (m_selectedWaypoints.Count == 1)
     {
         SendToolbarItemChanged(ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex)), index.ItemIndex, m_waypoints.IndexOf(m_selectedWaypoints[0]));
     }
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyRemoteControl.cs

示例5: Toolbar_ItemChanged

        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            if(m_syncing)
            {
                return;
            }
            Debug.Assert(self == Toolbar);
            
            var tItem = ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex));
            UpdateButtonEmissivity(index.ItemIndex);
            MyMultiplayer.RaiseEvent(this, x => x.SendToolbarItemChanged, tItem, index.ItemIndex);

            if (m_shouldSetOtherToolbars)
            {
                m_shouldSetOtherToolbars = false;

                foreach (var toolbar in m_openedToolbars)
                {
                    if (toolbar != self)
                    {
                        toolbar.SetItemAtIndex(index.ItemIndex, self.GetItemAtIndex(index.ItemIndex));
                    }
                }
                m_shouldSetOtherToolbars = true;
            }

            var slot = Toolbar.GetItemAtIndex(index.ItemIndex);
            if (slot != null)
            {
                string name = slot.DisplayName.ToString();
                MyMultiplayer.RaiseEvent(this, x => x.SetButtonName, name, index.ItemIndex);
            }
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:33,代码来源:MyButtonPanel.cs

示例6: CurrentToolbar_SlotActivated

 private void CurrentToolbar_SlotActivated(MyToolbar toolbar, MyToolbar.SlotArgs args)
 {
     if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemVoxelHand))
     {
         if (Enabled)
             Enabled = false;
     }
 }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:8,代码来源:MySessionComponentVoxelHand.cs

示例7: Toolbar_ItemChanged

        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            if (m_syncing)
            {
                return;
            }

            Debug.Assert(self == Toolbar);

            var tItem = ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex));
            MyMultiplayer.RaiseEvent(this, x => x.SendToolbarItemChanged, tItem, index.ItemIndex);

            if (m_shouldSetOtherToolbars)
            {
                m_shouldSetOtherToolbars = false;

                foreach (var toolbar in m_openedToolbars)
                {
                    if (toolbar != self)
                    {
                        toolbar.SetItemAtIndex(index.ItemIndex, self.GetItemAtIndex(index.ItemIndex));
                    }
                }
                m_shouldSetOtherToolbars = true;
            }
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:26,代码来源:MyTimerBlock.cs

示例8: Toolbar_ItemChanged

        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            Debug.Assert(self == Toolbar);
            
            var tItem = ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex));
            UpdateButtonEmissivity(index.ItemIndex);
            (SyncObject as MySyncButtonPanel).SendToolbarItemChanged(tItem, index.ItemIndex);

            if (m_shouldSetOtherToolbars)
            {
                m_shouldSetOtherToolbars = false;
                if (!(SyncObject as MySyncButtonPanel).IsSyncing)
                {
                    foreach (var toolbar in m_openedToolbars)
                    {
                        if (toolbar != self)
                        {
                            toolbar.SetItemAtIndex(index.ItemIndex, self.GetItemAtIndex(index.ItemIndex));
                        }
                    }
                }
                m_shouldSetOtherToolbars = true;
            }

            var slot = Toolbar.GetItemAtIndex(index.ItemIndex);
            if (slot != null)
            {
                string name = slot.DisplayName.ToString();
                SetButtonName(name, index.ItemIndex);
                (SyncObject as MySyncButtonPanel).SendCustonNameChanged(name, index.ItemIndex);
            }
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:32,代码来源:MyButtonPanel.cs

示例9: Toolbar_ItemChanged

        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            if (m_syncing)
            {
                return;
            }

            Debug.Assert(self == Toolbar);

            var tItem = ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex));
            MyMultiplayer.RaiseEvent(this, x => x.SendToolbarItemChanged, tItem, index.ItemIndex);     
        }
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:12,代码来源:MyShipController.cs

示例10: Toolbar_ItemChanged

        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            if (m_syncing)
            {
                return;
            }

            Debug.Assert(self == Toolbar);

            MyToolbarItem item = self.GetItemAtIndex(index.ItemIndex);
            if (item != null)
            {
                MyMultiplayer.RaiseEvent(this, x => x.SendToolbarItemChanged, item.GetObjectBuilder(), index.ItemIndex);
            }
            else
            {
                MyMultiplayer.RaiseEvent(this, x => x.SendToolbarItemRemoved, index.ItemIndex);
            }
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:19,代码来源:MyShipController.cs

示例11: CurrentToolbar_SlotActivated

 private void CurrentToolbar_SlotActivated(MyToolbar toolbar, MyToolbar.SlotArgs args)
 {
     if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemPrefabThrower))
         Enabled = false;
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:5,代码来源:MyThrowerSessionComponent.cs

示例12: Toolbar_ItemChanged

        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            Debug.Assert(self == Toolbar);

            var tItem = ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex));
            var oldItem = m_items[index.ItemIndex];
            if ((tItem.EntityID == 0 && oldItem.EntityID == 0 || (tItem.EntityID != 0 && oldItem.EntityID != 0 && tItem.Equals(oldItem))))
                return;
            m_items.RemoveAt(index.ItemIndex);
            m_items.Insert(index.ItemIndex, tItem);
            (SyncObject as MySyncSensorBlock).SendToolbarItemChanged(tItem, index.ItemIndex);

            if (m_shouldSetOtherToolbars)
            {
                m_shouldSetOtherToolbars = false;
                if (!(SyncObject as MySyncSensorBlock).IsSyncing)
                {
                    foreach (var toolbar in m_openedToolbars)
                    {
                        if (toolbar != self)
                        {
                            toolbar.SetItemAtIndex(index.ItemIndex, self.GetItemAtIndex(index.ItemIndex));
                        }
                    }
                }
                m_shouldSetOtherToolbars = true;
            }
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:28,代码来源:MySensorBlock.cs

示例13: Toolbar_ItemChanged

        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            Debug.Assert(self == Toolbar);

            var tItem = ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex));
            (SyncObject as MySyncTimerBlock).SendToolbarItemChanged(tItem, index.ItemIndex);
            
            if (m_shouldSetOtherToolbars)
            {
                m_shouldSetOtherToolbars = false;
                if (!(SyncObject as MySyncTimerBlock).IsSyncing)
                {
                    foreach (var toolbar in m_openedToolbars)
                    {
                        if (toolbar != self)
                        {
                            toolbar.SetItemAtIndex(index.ItemIndex, self.GetItemAtIndex(index.ItemIndex));
                        }
                    }
                }
                m_shouldSetOtherToolbars = true;
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:23,代码来源:MyTimerBlock.cs

示例14: Toolbar_ItemChanged

 void Toolbar_ItemChanged(MyToolbar toolbar, MyToolbar.IndexArgs index)
 {
     var item = toolbar.GetItemAtIndex(index.ItemIndex);
     if (item != null)
     {
         var def = item as MyToolbarItemDefinition;
         if (def != null)
         {
             var defId = def.Definition.Id;
             if (defId != null)
             {
                 if (defId.TypeId != typeof(MyObjectBuilder_PhysicalGunObject))
                     MyToolBarCollection.RequestChangeSlotItem(MySession.Static.LocalHumanPlayer.Id, index.ItemIndex, defId);
                 else
                     MyToolBarCollection.RequestChangeSlotItem(MySession.Static.LocalHumanPlayer.Id, index.ItemIndex, item.GetObjectBuilder());
             }
         }
     }
     else if (MySandboxGame.IsGameReady)
     {
         MyToolBarCollection.RequestClearSlot(MySession.Static.LocalHumanPlayer.Id, index.ItemIndex);
     }
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:23,代码来源:MyCharacter.cs

示例15: CurrentToolbar_SlotActivated

 private void CurrentToolbar_SlotActivated(MyToolbar toolbar, MyToolbar.SlotArgs args)
 {
     if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemBot))
         BotToSpawn = null;
     if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemAiCommand))
         CommandDefinition = null;
 }
开发者ID:avivbeeri,项目名称:SpaceEngineers,代码行数:7,代码来源:MyAIComponent.cs


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