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


C# Entities.MyCubeGrid类代码示例

本文整理汇总了C#中Sandbox.Game.Entities.MyCubeGrid的典型用法代码示例。如果您正苦于以下问题:C# MyCubeGrid类的具体用法?C# MyCubeGrid怎么用?C# MyCubeGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            InitializeSinkComponent();
            base.Init(objectBuilder, cubeGrid);
            if (CubeGrid.CreatePhysics)
            {
            	// Put on my fake, because it does performance issues
                if (MyFakes.ENABLE_GRAVITY_PHANTOM)
                {
                        var shape = CreateFieldShape();
                        Physics = new Sandbox.Engine.Physics.MyPhysicsBody(this, RigidBodyFlag.RBF_KINEMATIC);
                        Physics.IsPhantom = true;
                        Physics.CreateFromCollisionObject(shape, PositionComp.LocalVolume.Center, WorldMatrix, null, Sandbox.Engine.Physics.MyPhysics.CollisionLayers.GravityPhantomLayer);
                        shape.Base.RemoveReference();
                        Physics.Enabled = IsWorking;
                }
                NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;

                SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
                ResourceSink.Update();
            }
            m_soundEmitter = new MyEntity3DSoundEmitter(this, true);
            m_baseIdleSound.Init("BlockGravityGen");
			
        }
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:25,代码来源:MyGravityGeneratorBase.cs

示例2: MyGridJumpDriveSystem

        public MyGridJumpDriveSystem(MyCubeGrid grid)
        {
            m_grid = grid;

            SyncObject = new MySyncJumpDriveSystem(m_grid);
            m_soundEmitter = new MyEntity3DSoundEmitter(m_grid);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:7,代码来源:MyGridJumpDriveSystem.cs

示例3: Init

 public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
 {
     base.Init(builder, cubeGrid);
     this.NeedsUpdate = MyEntityUpdateEnum.EACH_100TH_FRAME;
     m_emissivitySet = false;
     AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorSegment(m_segment));
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyConveyorConnector.cs

示例4: Init

        public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
        {
            ResourceSink = new MyResourceSinkComponent();
            ResourceSink.Init(
                MyStringHash.GetOrCompute(BlockDefinition.ResourceSinkGroup),
                BlockDefinition.PowerConsumptionMoving,
                UpdatePowerInput);

            base.Init(builder, cubeGrid);

            var ob = (MyObjectBuilder_AirtightDoorGeneric)builder;
            m_open.Value = ob.Open;
            m_currOpening = ob.CurrOpening;

            m_openingSpeed = BlockDefinition.OpeningSpeed;
            m_sound = new MySoundPair(BlockDefinition.Sound);
            m_subpartMovementDistance = BlockDefinition.SubpartMovementDistance;
	
			if (!Enabled || !ResourceSink.IsPoweredByType(MyResourceDistributorComponent.ElectricityId))
                UpdateDoorPosition();

            OnStateChange();

            ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink.Update();
            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
			ResourceSink.Update();
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:28,代码来源:MyAirtightDoorGeneric.cs

示例5: Init

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

            m_cargoDefinition = (MyCargoContainerDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
            var cargoBuilder = (MyObjectBuilder_CargoContainer)objectBuilder;
            m_containerType = cargoBuilder.ContainerType;

            if (MyFakes.ENABLE_INVENTORY_FIX)
            {
                FixSingleInventory();
            }

            // Backward compatibility - inventory component not defined in definition files and in entity container
            if (this.GetInventory() == null)
            {
                MyInventory inventory = new MyInventory(m_cargoDefinition.InventorySize.Volume, m_cargoDefinition.InventorySize, MyInventoryFlags.CanSend | MyInventoryFlags.CanReceive);
                Components.Add<MyInventoryBase>(inventory);
                
                if (m_containerType != null && MyFakes.RANDOM_CARGO_PLACEMENT && (cargoBuilder.Inventory == null || cargoBuilder.Inventory.Items.Count == 0))
                    SpawnRandomCargo();
            }

            //Backward compatibility
            if (cargoBuilder.Inventory != null && cargoBuilder.Inventory.Items.Count > 0)
                this.GetInventory().Init(cargoBuilder.Inventory);

            Debug.Assert(this.GetInventory().Owner == this, "Ownership was not set!");
            this.GetInventory().SetFlags(MyInventoryFlags.CanSend | MyInventoryFlags.CanReceive);
            m_conveyorEndpoint = new MyMultilineConveyorEndpoint(this);
            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint));
            UpdateIsWorking();
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:33,代码来源:MyCargoContainer.cs

示例6: GetMasterGrid

        /// <summary>
        /// Returns master grid
        /// </summary>
        public static MyCubeGrid GetMasterGrid(MyCubeGrid grid)
        {
            // Biggest grid does the sync
            var group = MyCubeGridGroups.Static.PhysicalDynamic.GetGroup(grid);

            if (group == null)
            {
                return grid;
            }

            float maxRadius = 0;
            MyCubeGrid biggestGrid = null;
            foreach (var node in group.Nodes)
            {
                // Static in never master
                if (node.NodeData.IsStatic)
                    continue;

                // Sort by radius, then by EntityId (to make stable sort of two same-size grids)
                var rad = node.NodeData.PositionComp.LocalVolume.Radius;
                if (rad > maxRadius || (rad == maxRadius && (biggestGrid == null || grid.EntityId > biggestGrid.EntityId)))
                {
                    maxRadius = rad;
                    biggestGrid = node.NodeData;
                }
            }

            return biggestGrid; // Only biggest grid does the sync
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:32,代码来源:MyGridPhysicsStateGroup.cs

示例7: CheckPlayerExempt

        public bool CheckPlayerExempt(ProtectedItem.ProtectionSettings settings, MyCubeGrid grid, ulong remoteUserId )
        {
            if ( settings.AllExempt )
                return true;

            if (settings.AdminExempt && PlayerManager.Instance.IsUserAdmin(remoteUserId))
                return true;

            long playerId = PlayerMap.Instance.GetFastPlayerIdFromSteamId( remoteUserId );

            if (settings.BigOwnerExempt)
            {
                //fast check to see if the player's current live identity is an owner
                if (grid.BigOwners.Contains(playerId))
                    return true;

                //check old, dead identities. this is much slower
                var playerIds = PlayerMap.Instance.GetPlayerIdsFromSteamId(remoteUserId, false);

                foreach (var owner in grid.BigOwners)
                    if (playerIds.Contains(owner))
                        return true;
            }

            if ( settings.SmallOwnerExempt )
            {
                //fast check to see if the player's current live identity is an owner
                if ( grid.SmallOwners.Contains( playerId ) )
                    return true;

                //check old, dead identities. this is much slower
                var playerIds = PlayerMap.Instance.GetPlayerIdsFromSteamId( remoteUserId, false );

                foreach ( var owner in grid.SmallOwners )
                    if ( playerIds.Contains( owner ) )
                        return true;
            }

            if ( settings.FactionExempt && grid.BigOwners.Count > 0)
            {
                var fac = MySession.Static.Factions.GetPlayerFaction( grid.BigOwners[0] );
                if ( fac != null && fac.IsMember( playerId ) )
                    return true;
            }

            if (settings.Factions == null)
                return false;

            foreach ( var facId in settings.Factions )
            {
                var fac = MySession.Static.Factions.TryGetFactionById( facId );
                if ( fac != null && fac.IsMember( playerId ) )
                    return true;
            }

            //if ( settings.ExemptSteamIds.Contains( remoteUserId.ToString() ) )
            //    return true;

            return false;
        }
开发者ID:rexxar-tc,项目名称:EssentialsPlugin,代码行数:60,代码来源:Protection.cs

示例8: Init

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

            PowerReceiver = new MyPowerReceiver(
                MyConsumerGroupEnum.Utility,
                false,
                BlockDefinition.RequiredPowerInput,
                this.CalculateRequiredPowerInput);
            PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged;
            PowerReceiver.Update();

            if (Physics != null)
            {
                Physics.Close();
            }

            var detectorShape = new HkBoxShape(new Vector3(cubeGrid.GridSize / 3.0f));
            var massProperties = HkInertiaTensorComputer.ComputeBoxVolumeMassProperties(detectorShape.HalfExtents, BlockDefinition.VirtualMass);
            Physics = new Engine.Physics.MyPhysicsBody(this, RigidBodyFlag.RBF_DEFAULT);
            Physics.IsPhantom = false;
            Physics.CreateFromCollisionObject(detectorShape, Vector3.Zero, WorldMatrix, massProperties, MyPhysics.VirtualMassLayer);
            Physics.Enabled = IsWorking && cubeGrid.Physics != null && cubeGrid.Physics.Enabled;
            Physics.RigidBody.Activate();
            detectorShape.Base.RemoveReference();

            UpdateText();

            NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME;

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:33,代码来源:MyVirtualMass.cs

示例9: grid_OnBlockOwnershipChanged

 void grid_OnBlockOwnershipChanged(MyCubeGrid obj)
 {
     bool playerOwner = false;
     foreach(var owner in obj.BigOwners)
     {
         var faction = MySession.Static.Factions.GetPlayerFaction(owner);
         if(faction != null && !faction.IsEveryoneNpc())
         {
             playerOwner = true;
             break;
         }
     }
     foreach(var owner in obj.SmallOwners)
     {
         var faction = MySession.Static.Factions.GetPlayerFaction(owner);
         if (faction != null && !faction.IsEveryoneNpc())
         {
             playerOwner = true;
             break;
         }
     }
     if (playerOwner)
     {
         obj.Components.Remove<MyUpdateTriggerComponent>();
         obj.OnBlockOwnershipChanged -= grid_OnBlockOwnershipChanged;
     }
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:27,代码来源:MyUpdateTriggerComponent.cs

示例10: Init

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

            m_cargoDefinition = (MyCargoContainerDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
            var cargoBuilder = (MyObjectBuilder_CargoContainer)objectBuilder;
            m_containerType = cargoBuilder.ContainerType;

            if (!Components.Has<MyInventoryBase>())
            {
                m_inventory = new MyInventory(m_cargoDefinition.InventorySize.Volume, m_cargoDefinition.InventorySize, MyInventoryFlags.CanSend | MyInventoryFlags.CanReceive, this);
				if(MyFakes.ENABLE_MEDIEVAL_INVENTORY)
					Components.Add<MyInventoryBase>(m_inventory);

                if (m_containerType != null && MyFakes.RANDOM_CARGO_PLACEMENT && (cargoBuilder.Inventory == null || cargoBuilder.Inventory.Items.Count == 0))
                    SpawnRandomCargo();
                else
                    m_inventory.Init(cargoBuilder.Inventory);
            }
            else
            {
                m_inventory = Components.Get<MyInventoryBase>() as MyInventory;
				Debug.Assert(m_inventory != null);
                //m_inventory.Owner = this;
            }

            if(MyPerGameSettings.InventoryMass)
                m_inventory.ContentsChanged += Inventory_ContentsChanged;

            m_conveyorEndpoint = new MyMultilineConveyorEndpoint(this);
            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint));
            UpdateIsWorking();
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:33,代码来源:MyCargoContainer.cs

示例11: MyGridReflectorLightSystem

 public MyGridReflectorLightSystem(MyCubeGrid grid)
 {
     m_reflectors = new HashSet<MyReflectorLight>();
     m_reflectorsEnabled = MyMultipleEnabledEnum.NoObjects;
     m_grid = grid;
     m_grid.SyncObject.ReflectorStateChanged += SyncObject_ReflectorStateChanged;
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:7,代码来源:MyGridReflectorLightSystem.cs

示例12: GridGroup

        public GridGroup( MyCubeGrid grid, GridLinkTypeEnum linkType = GridLinkTypeEnum.Logical )
        {
            _linkType = linkType;

            if ( grid.InScene )
            {
                List<MyCubeGrid> tmpList = new List<MyCubeGrid>( );

                //find the group containing this grid with the given link type
                Wrapper.GameAction( ( ) => tmpList = MyCubeGridGroups.Static.GetGroups( linkType ).GetGroupNodes( grid ) );

                _grids.UnionWith( tmpList );
            }
            //manually create a group for out of scene grids because they have a null group (yay Dusan fixed the crash)
            else
            {
                //use the old method to filter out grids with pistons or rotors, for safety
                HashSet<IMyEntity> thisEntity = new HashSet<IMyEntity>();
                HashSet<IMyEntity> returnSet = new HashSet<IMyEntity>();
                thisEntity.Add( (IMyEntity)grid );
                CubeGrids.GetGridsUnconnected( returnSet, thisEntity );

                if ( returnSet.Count > 0 )
                    _grids.Add( grid );
                else
                    return;
            }

            //populate our internal lists
            ComputeParent( );
            ComputeCubeBlocks( );
            ComputeFatBlocks( );
            ComputeSmallOwners( );
            ComputeBigOwners( );
        }
开发者ID:rexxar-tc,项目名称:EssentialsPlugin,代码行数:35,代码来源:GridGroup.cs

示例13: Init

        internal void Init(Graphics.GUI.MyGuiControlTabPage infoPage, MyCubeGrid grid)
        {
            m_grid = grid;
            m_infoPage = infoPage;
            Debug.Assert(m_infoPage != null);

            RecreateControls();

            if (grid == null)
                return;
            grid.OnBlockAdded += grid_OnBlockAdded;
            grid.OnBlockRemoved += grid_OnBlockRemoved;
            grid.OnPhysicsChanged += grid_OnPhysicsChanged;
            grid.OnBlockOwnershipChanged += grid_OnBlockOwnershipChanged;

            if (MyFakes.ENABLE_TERMINAL_PROPERTIES)
            {
                var renameShipBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("RenameShipButton");
                if (renameShipBtn != null)
                    renameShipBtn.ButtonClicked += renameBtn_ButtonClicked;
            }

            var convertBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("ConvertBtn");
            if (convertBtn != null)
            {
                convertBtn.ButtonClicked += convertBtn_ButtonClicked;
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:28,代码来源:MyTerminalInfoController.cs

示例14: Init

 public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
 {
     base.Init(objectBuilder, cubeGrid);
     MyObjectBuilder_UserControllableGun builder = (objectBuilder as MyObjectBuilder_UserControllableGun);
     m_shootingSaved = builder.IsLargeTurret ? builder.IsShootingFromTerminal : builder.IsShooting;
     NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;      
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MyUserControllableGun.cs

示例15: Init

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

            MyDebug.AssertDebug(BlockDefinition.Id.TypeId == typeof(MyObjectBuilder_Reactor));
            m_reactorDefinition = BlockDefinition as MyReactorDefinition;
            MyDebug.AssertDebug(m_reactorDefinition != null);

            CurrentPowerOutput = 0;
            m_inventory = new MyInventory(m_reactorDefinition.InventoryMaxVolume, m_reactorDefinition.InventorySize, MyInventoryFlags.CanReceive, this);

            var obGenerator = (MyObjectBuilder_Reactor)objectBuilder;
            m_inventory.Init(obGenerator.Inventory);
            m_inventory.ContentsChanged += inventory_ContentsChanged;
            m_inventory.Constraint = m_reactorDefinition.InventoryConstraint;
            RefreshRemainingCapacity();

            UpdateText();

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
            //if (MyFakes.SHOW_DAMAGE_EFFECTS && IsWorking)
            //    NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;

            m_baseIdleSound = BlockDefinition.PrimarySound;

            m_useConveyorSystem = obGenerator.UseConveyorSystem;

            if (IsWorking)
                OnStartWorking();
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:32,代码来源:MyReactor.cs


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