本文整理汇总了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);
}
示例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;
//.........这里部分代码省略.........