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


C# IMyEntity.OnRemovedFromScene方法代码示例

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


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

示例1: RemoveChild

        /// <summary>
        /// Adds the child.
        /// </summary>
        /// <param name="child">The child.</param>
        /// <param name="preserveWorldPos">if set to <c>true</c> [preserve absolute position].</param>
        public void RemoveChild(IMyEntity child, bool preserveWorldPos = false)
        {
            MyHierarchyComponentBase childHierarchy = child.Components.Get<MyHierarchyComponentBase>();

            if (preserveWorldPos)
            {
                var tmpWorldMatrix = child.WorldMatrix;

                this.Children.Remove(childHierarchy);

                child.WorldMatrix = tmpWorldMatrix;
            }
            else
            {
                this.Children.Remove(childHierarchy);
            }

            childHierarchy.Parent = null;

            if (child.InScene)
                child.OnRemovedFromScene(this);
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:27,代码来源:MyHierarchyComponentBase.cs

示例2: ConcealEntity

		private static void ConcealEntity( IMyEntity entity )
		{
			int pos = 0;
            //RemovedGrids.Clear( );
            try
			{
				if ( !entity.InScene )
					return;

				MyObjectBuilder_CubeGrid builder = CubeGrids.SafeGetObjectBuilder( (IMyCubeGrid)entity );
				if ( builder == null )
					return;
                
                pos = 1;
                IMyCubeGrid grid = (IMyCubeGrid)entity;
				long ownerId;
				string ownerName = string.Empty;
                if ( CubeGrids.GetOwner( builder, out ownerId ) )
                {
                    //ownerId = grid.BigOwners.First();
                    ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId( ownerId ).Name;

                    if ( !PluginSettings.Instance.DynamicConcealPirates )
                    {
                        if ( ownerName.Contains( "Space Pirate" ) )
                        {
                            if ( PluginSettings.Instance.DynamicShowMessages )
                                Essentials.Log.Info( "Not concealing pirate owned grid {0} -> {1}.", grid.EntityId, grid.DisplayName );
                            return;
                        }
                    }
                }
                Essentials.Log.Info( grid.EntityId.ToString() + " " + ownerId.ToString() + " " + ownerName );

				pos = 2;
                if ( entity.Physics != null )
				{
					entity.Physics.LinearVelocity = Vector3.Zero;
					entity.Physics.AngularVelocity = Vector3.Zero;
				}

				/*
				entity.InScene = false;
				entity.CastShadows = false;
				entity.Visible = false;
				*/

				builder.PersistentFlags = MyPersistentEntityFlags2.None;
				MyAPIGateway.Entities.RemapObjectBuilder( builder );

				pos = 3;
                if ( RemovedGrids.Contains( entity.EntityId ) )
				{
					Essentials.Log.Info( "Concealing - Id: {0} DUPE FOUND - Display: {1} OwnerId: {2} OwnerName: {3}", entity.EntityId, entity.DisplayName, ownerId, ownerName );
                    BaseEntityNetworkManager.BroadcastRemoveEntity( entity, false );
                    MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( entity ) );
                pos = 4;
                }
				else
				{
					if ( !PluginSettings.Instance.DynamicConcealServerOnly )
					{
                        /*
						if (PluginSettings.Instance.DynamicBlockManagementEnabled)
						{
							bool enable = false;
							lock (BlockManagement.Instance.GridDisabled)
							{
								if(BlockManagement.Instance.GridDisabled.Contains(entity.EntityId))
									enable = true;
							}

							if(enable)
								BlockManagement.Instance.EnableGrid((IMyCubeGrid)entity);
						}
						*/
                        pos = 5;
                        IMyEntity newEntity = MyEntities.CreateFromObjectBuilder( builder );

                        if ( newEntity == null )
                        {
                            Essentials.Log.Warn( "CreateFromObjectBuilder failed: {0}", builder.EntityId );
                            return;
                        }

                        pos = 6;
                        RemovedGrids.Add( entity.EntityId );
                        entity.InScene = false;
                        entity.OnRemovedFromScene( entity );
						BaseEntityNetworkManager.BroadcastRemoveEntity( entity, false );
						MyAPIGateway.Entities.AddEntity( newEntity, false );
                        MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( newEntity ) );

                        pos = 7;
                        if ( PluginSettings.Instance.DynamicShowMessages )
							Essentials.Log.Info( "Concealed - Id: {0} -> {4} Display: {1} OwnerId: {2} OwnerName: {3}", entity.EntityId, entity.DisplayName, ownerId, ownerName, newEntity.EntityId );
					}
					else
					{
						entity.InScene = false;
//.........这里部分代码省略.........
开发者ID:dodexahedron,项目名称:EssentialsPlugin,代码行数:101,代码来源:EntityManagement.cs


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