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


C# IMyEntity.GetTopMostParent方法代码示例

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


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

示例1: HandleAddDecal

        /// <param name="damage">Not used for now but could be used as a multiplier instead of random decal size</param>
        public static void HandleAddDecal(IMyEntity entity, MyHitInfo hitInfo, MyStringHash source = default(MyStringHash), float damage = -1)
        {
            if (entity == null)
                DebugNullEntity();

            IMyDecalProxy proxy = entity as IMyDecalProxy;
            if (proxy != null)
            {
                AddDecal(proxy, ref hitInfo, damage, source);
                return;
            }

            MyCubeGrid grid = entity.GetTopMostParent() as MyCubeGrid;
            if (grid != null)
            {
                var block = grid.GetTargetedBlock(hitInfo.Position);
                if (block != null)
                {
                    var compoundBlock = block.FatBlock as MyCompoundCubeBlock;
                    if (compoundBlock == null)
                        proxy = block;
                    else
                        proxy = compoundBlock;
                }
            }

            if (proxy != null)
                AddDecal(proxy, ref hitInfo, damage, source);
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:30,代码来源:MyDecals.cs

示例2: Waypoint

        public Waypoint(Mover mover, AllNavigationSettings navSet, AllNavigationSettings.SettingsLevelName level, IMyEntity targetEntity, Vector3D worldOffset)
            : base(mover, navSet)
        {
            this.m_logger = new Logger(GetType().Name, m_controlBlock.CubeBlock);
            this.m_level = level;
            this.m_targetEntity = targetEntity;
            this.m_targetOffset = worldOffset;

            m_logger.debugLog(targetEntity != targetEntity.GetTopMostParent(), "targetEntity is not top-most", Logger.severity.FATAL);

            IMyCubeGrid asGrid = targetEntity as IMyCubeGrid;
            if (asGrid != null && Attached.AttachedGrid.IsGridAttached(asGrid, m_controlBlock.CubeGrid, Attached.AttachedGrid.AttachmentKind.Physics))
            {
                m_logger.debugLog("Cannot fly to entity, attached: " + targetEntity.getBestName() + ", creating GOLIS", Logger.severity.WARNING);
                new GOLIS(mover, navSet, TargetPosition, level);
                return;
            }
            if (targetEntity.Physics == null)
            {
                m_logger.debugLog("Target has no physics: " + targetEntity.getBestName() + ", creating GOLIS", Logger.severity.WARNING);
                new GOLIS(mover, navSet, TargetPosition, level);
                return;
            }

            var setLevel = navSet.GetSettingsLevel(level);
            setLevel.NavigatorMover = this;
            //setLevel.DestinationEntity = mover.Block.CubeBlock; // to force avoidance

            m_logger.debugLog("created, level: " + level + ", target: " + targetEntity.getBestName() + ", target position: " + targetEntity.GetPosition() + ", offset: " + worldOffset + ", position: " + TargetPosition, Logger.severity.DEBUG);
        }
开发者ID:Souper07,项目名称:Autopilot,代码行数:30,代码来源:Waypoint.cs

示例3: GetHitEntityAndPosition

        private void GetHitEntityAndPosition(LineD line, out IMyEntity entity, out Vector3D hitPosition, out Vector3 hitNormal, out bool hitHead)
        {
            entity = null;
            hitPosition = hitNormal = Vector3.Zero;
            hitHead = false;

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyEntities.GetIntersectionWithLine()");
            m_intersection = MyEntities.GetIntersectionWithLine(ref line, m_ignoreEntity, m_weapon, false, false, true, IntersectionFlags.ALL_TRIANGLES, MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * CHECK_INTERSECTION_INTERVAL);
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            if(m_intersection != null)
            { 
                entity = m_intersection.Value.Entity;
                hitPosition = m_intersection.Value.IntersectionPointInWorldSpace;
                hitNormal = m_intersection.Value.NormalInWorldSpace;
            }
            if (entity == null)
            {
                var hitInfo = MyPhysics.CastRay(line.From, line.To);
                if (hitInfo.HasValue)
                {
                    entity = hitInfo.Value.HkHitInfo.GetHitEntity() as MyEntity;
                    hitPosition = hitInfo.Value.Position;
                    hitNormal = hitInfo.Value.HkHitInfo.Normal;
                }
            }
            if (entity == null)
                return;

            if (m_projectileAmmoDefinition.HeadShot && entity is MyCharacter)
            {
                MyCharacter hitCharacter = entity as MyCharacter;
                MyIntersectionResultLineTriangleEx? t;
                hitCharacter.GetIntersectionWithLine(ref line, out t, out hitHead);
            }

            if (!(entity is MyCharacter))
                entity = entity.GetTopMostParent();
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:39,代码来源:MyProjectile.cs

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

示例5: GetHitEntityAndPosition

 private void GetHitEntityAndPosition(LineD line, out IMyEntity entity, out Vector3D hitPosition, out Vector3 hitNormal)
 {
     entity = null;
     hitPosition = hitNormal = Vector3.Zero;
     VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyEntities.GetIntersectionWithLine()");
     m_intersection = MyEntities.GetIntersectionWithLine(ref line, m_ignoreEntity, m_weapon, false, false, true, IntersectionFlags.ALL_TRIANGLES, MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * CHECK_INTERSECTION_INTERVAL);
     VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
     if(m_intersection != null)
     { 
         entity = m_intersection.Value.Entity;
         hitPosition = m_intersection.Value.IntersectionPointInWorldSpace;
         hitNormal = m_intersection.Value.NormalInWorldSpace;
     }
     if (entity == null)
     {
         var hitRigidBody = MyPhysics.CastRay(line.From, line.To, out hitPosition, out hitNormal);
         entity = hitRigidBody.GetEntity() as MyEntity;
     }
     if (entity == null)
         return;
     if (!(entity is MyCharacter))
         entity = entity.GetTopMostParent();
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:23,代码来源:MyProjectile.cs


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