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


C# IMyEntity.GetObjectBuilder方法代码示例

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


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

示例1: RepairShip

        private void RepairShip(IMyEntity shipEntity)
        {
            // We SHOULD NOT make any changes directly to the prefab, we need to make a Value copy using Clone(), and modify that instead.
            var gridObjectBuilder = shipEntity.GetObjectBuilder().Clone() as MyObjectBuilder_CubeGrid;

            shipEntity.Physics.Deactivate();

            // This will Delete the entity and sync to all.
            // Using this, also works with player ejection in the same Tick.
            shipEntity.SyncObject.SendCloseRequest();

            gridObjectBuilder.EntityId = 0;

            if (gridObjectBuilder.Skeleton == null)
                gridObjectBuilder.Skeleton = new List<BoneInfo>();
            else
                gridObjectBuilder.Skeleton.Clear();

            foreach (var cube in gridObjectBuilder.CubeBlocks)
            {
                cube.IntegrityPercent = cube.BuildPercent;
                cube.DeformationRatio = 0;
                // No need to set bones for individual blocks like rounded armor, as this is taken from the definition within the game itself.
            }

            var tempList = new List<MyObjectBuilder_EntityBase>();
            tempList.Add(gridObjectBuilder);
            tempList.CreateAndSyncEntities();

            MyAPIGateway.Utilities.ShowMessage("repair", "Ship '{0}' has been repairded.", shipEntity.DisplayName);
        }
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:31,代码来源:CommandShipRepair.cs

示例2: ProtectedEntity

        private void ProtectedEntity(IMyEntity entity, ProtectedItem item)
        {
            //Logging.WriteLineAndConsole(string.Format("Protecting: {0}", entity.EntityId));
            //CubeGridEntity gridEntity = new CubeGridEntity((MyObjectBuilder_CubeGrid)entity.GetObjectBuilder(), entity);
            CubeGridEntity gridEntity = (CubeGridEntity)GameEntityManager.GetEntity(entity.EntityId);
            MyObjectBuilder_CubeGrid grid = (MyObjectBuilder_CubeGrid)entity.GetObjectBuilder();

            int count = 0;
            while (gridEntity.IsLoading)
            {
                if (count >= 20)
                    return;

                Thread.Sleep(100);
                count++;
            }

            bool found = false;
            /*
            foreach(CubeBlockEntity block in gridEntity.CubeBlocks)
            {
                if (block.IntegrityPercent != item.IntegrityIncrease || block.BuildPercent != item.IntegrityIncrease || block.BoneDamage > 0f)
                {
                    found = true;
                    block.FixBones(0, 100);
                    block.IntegrityPercent = item.IntegrityIncrease;
                    block.BuildPercent = item.IntegrityIncrease;
                }
            }
            */
            if(found)
             			Logging.WriteLineAndConsole(string.Format("Repaired Grid: {0}", gridEntity.EntityId));
        }
开发者ID:afinegan,项目名称:EssentialsPlugin,代码行数:33,代码来源:ProcessProtection.cs

示例3: SetDestructible

        public static void SetDestructible(IMyEntity shipEntity, bool destructible, ulong steamId = 0)
        {
            var gridObjectBuilder = shipEntity.GetObjectBuilder(true) as MyObjectBuilder_CubeGrid;
            if (gridObjectBuilder.DestructibleBlocks == destructible)
            {
                MyAPIGateway.Utilities.SendMessage(steamId, "destructible", "Ship '{0}' destructible is already set to {1}.", shipEntity.DisplayName, destructible ? "On" : "Off");
                return;
            }

            gridObjectBuilder.EntityId = 0;
            gridObjectBuilder.DestructibleBlocks = destructible;

            // This will Delete the entity and sync to all.
            // Using this, also works with player ejection in the same Tick.
            shipEntity.SyncObject.SendCloseRequest();

            var tempList = new List<MyObjectBuilder_EntityBase>();
            tempList.Add(gridObjectBuilder);
            tempList.CreateAndSyncEntities();

            MyAPIGateway.Utilities.SendMessage(steamId, "destructible", "Ship '{0}' destructible has been set to {1}.", shipEntity.DisplayName, destructible ? "On" : "Off");
        }
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:22,代码来源:MessageSyncSetDestructable.cs

示例4: GetCharacterDefinitionFrom

        private MyCharacterDefinition GetCharacterDefinitionFrom(IMyEntity ent)
        {
            if(ent != null)
            {
                var obj = ent.GetObjectBuilder(false) as MyObjectBuilder_Character;

                if(obj != null)
                {
                    MyCharacterDefinition def;
                    MyDefinitionManager.Static.Characters.TryGetValue(obj.CharacterModel, out def);
                    return def;
                }
            }

            return null;
        }
开发者ID:THDigi,项目名称:Ladder,代码行数:16,代码来源:Ladder.cs

示例5: ApplyBlockSubTypeFilter

        private static bool ApplyBlockSubTypeFilter( ulong userId, Dictionary<string, int> subTypeDict, Dictionary<string, int> blockSubTypes, bool debug, bool quiet, IMyEntity entity, bool found )
        {
            bool hasType = false;
            foreach ( KeyValuePair<string, int> pairBlockTypesInGrid in subTypeDict )
            {
                foreach ( KeyValuePair<string, int> pairBlockTypesFilter in blockSubTypes )
                {
                    if ( pairBlockTypesInGrid.Key.ToLower( ).Contains( pairBlockTypesFilter.Key.ToLower( ) ) )
                    {
                        if ( pairBlockTypesInGrid.Value >= pairBlockTypesFilter.Value )
                        {
                            if ( debug && !quiet )
                            {
                                Communication.SendPrivateInformation( userId,
                                                                      string.Format( "Found grid '{0}' ({1}) which contains at least {4} of block type {3} ({5}).  BlockCount={2}",
                                                                                     entity.DisplayName,
                                                                                     entity.EntityId,
                                                                                     ( (MyObjectBuilder_CubeGrid) entity.GetObjectBuilder( ) ).CubeBlocks.Count,
                                                                                     pairBlockTypesInGrid.Key,
                                                                                     pairBlockTypesFilter.Value,
                                                                                     pairBlockTypesInGrid.Value ) );
                            }

                            hasType = true;
                            break;
                        }
                    }
                }
            }

            if ( !hasType )
            {
                if ( debug && !quiet )
                {
                    Communication.SendPrivateInformation( userId,
                                                          string.Format( "Found grid '{0}' ({1}) which does not contain block type.  BlockCount={2}",
                                                                         entity.DisplayName,
                                                                         entity.EntityId,
                                                                         ( (MyObjectBuilder_CubeGrid) entity.GetObjectBuilder( ) ).CubeBlocks.Count ) );
                }

                found = false;
            }
            return found;
        }
开发者ID:Pingperfect,项目名称:EssentialsPlugin,代码行数:45,代码来源:CubeGrid.cs

示例6: ApplyBlockSubTypeExclusionFilter

        private static bool ApplyBlockSubTypeExclusionFilter( ulong userId, Dictionary<string, int> subTypeDict, Dictionary<string, int> blockSubTypes, bool found, bool quiet, bool debug, IMyEntity entity )
        {
            foreach ( KeyValuePair<string, int> pairBlockTypesInGrid in subTypeDict )
            {
                foreach ( KeyValuePair<string, int> pairBlockTypesFilter in blockSubTypes )
                {
                    if ( pairBlockTypesInGrid.Key.ToLower( ).Contains( pairBlockTypesFilter.Key.ToLower( ) ) )
                    {
                        if ( pairBlockTypesInGrid.Value >= pairBlockTypesFilter.Value )
                        {
                            if ( found )
                            {
                                found = false;
                            }

                            if ( !quiet && debug )
                            {
                                Communication.SendPrivateInformation( userId,
                                                                      string.Format( "Exclusion: Found grid '{0}' ({1}) which excludes block type of {3} at {4}.  BlockCount={2}",
                                                                                     entity.DisplayName,
                                                                                     entity.EntityId,
                                                                                     ( (MyObjectBuilder_CubeGrid) entity.GetObjectBuilder( ) ).CubeBlocks.Count,
                                                                                     pairBlockTypesFilter.Key,
                                                                                     pairBlockTypesInGrid.Value ) );
                            }

                            break;
                        }
                    }
                }
            }
            return found;
        }
开发者ID:Pingperfect,项目名称:EssentialsPlugin,代码行数:33,代码来源:CubeGrid.cs

示例7: TransportPlayer

        private void TransportPlayer( IMyEntity entityToTransport )
        {
            if ( entityToTransport is IMyCharacter )
            {
                MyObjectBuilder_Character c = (MyObjectBuilder_Character)entityToTransport.GetObjectBuilder( );
                if ( c.Health < 1 )
                    return;

                Thread.Sleep( 50 );
                BoundingSphereD sphere = new BoundingSphereD( entityToTransport.GetTopMostParent( ).GetPosition( ), 300 );
                List<IMyEntity> entities = MyAPIGateway.Entities.GetEntitiesInSphere( ref sphere );

                bool found = entities.Any( testEntity => testEntity != entityToTransport );

                if ( found )
                    return;

                MoveEntity( entityToTransport );
            }
            else if ( entityToTransport is IMyCubeGrid )
            {
                foreach ( string name in PluginSettings.Instance.NewUserTransportSpawnShipNames )
                {
                    if ( entityToTransport.DisplayName.ToLower( ).Contains( name.ToLower( ) ) )
                    {
                        if ( PluginSettings.Instance.DynamicClientConcealEnabled )
                        {
                            //ClientEntityManagement.SyncFix.Add(entityToTransport.EntityId, DateTime.Now);
                        }

                        MoveEntity( entityToTransport );
                        break;
                    }
                }
            }
        }
开发者ID:88tom,项目名称:EssentialsPlugin,代码行数:36,代码来源:ProcessNewUserTransport.cs

示例8: RunAllEntityComponentConstructorsOnAdded

        private void RunAllEntityComponentConstructorsOnAdded(IMyEntity entity)
        {
            Type entityBuilderType = entity.GetObjectBuilder().GetType();

            List<Action<IMyEntity>> registerActions =
                GetEntityComponentConstructors(entityBuilderType);

            //Log.Trace("Running " + registerActions.Count + " saved constructors " +
            //    " for entity " + entity.EntityId + " of type " + entityBuilderType,
            //    "RunAllEntityComponentConstructorsOnAdded");

            foreach (Action<IMyEntity> constructor in registerActions) {
                RunEntityComponentConstructorOnEntity(constructor, entity);
            }
        }
开发者ID:zrisher,项目名称:SEGarden,代码行数:15,代码来源:UpdateManager.cs


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