本文整理汇总了C#中Sandbox.Game.Entities.MyCubeBlock.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# MyCubeBlock.GetType方法的具体用法?C# MyCubeBlock.GetType怎么用?C# MyCubeBlock.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sandbox.Game.Entities.MyCubeBlock
的用法示例。
在下文中一共展示了MyCubeBlock.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessEnforcement
private static void ProcessEnforcement( MyCubeBlock newBlock = null)
{
if ( !PluginSettings.Instance.PlayerBlockEnforcementEnabled )
return;
if ( _processing )
return;
_processing = true;
if ( DateTime.Now - _lastRun < TimeSpan.FromMilliseconds( 100 ) )
{
_processing = false;
return;
}
_lastRun = DateTime.Now;
Task.Run( () =>
{
//Essentials.Log.Debug( "process enforcement" );
foreach ( var item in PluginSettings.Instance.PlayerBlockEnforcementItems )
{
string blockSearch;
bool searchSubType;
switch ( item.Mode )
{
case SettingsBlockEnforcementItem.EnforcementMode.Off:
continue;
case SettingsBlockEnforcementItem.EnforcementMode.BlockSubtypeId:
blockSearch = item.BlockSubtypeId;
searchSubType = true;
break;
case SettingsBlockEnforcementItem.EnforcementMode.BlockTypeId:
blockSearch = item.BlockTypeId;
searchSubType = false;
break;
default:
Essentials.Log.Debug( "exit" );
return;
}
if ( item.MaxPerGrid == 0 )
{
foreach ( var player in MySession.Static.Players.GetOnlinePlayers() )
{
if ( item.AdminExempt && player.IsAdmin )
continue;
Communication.DisableGMenu( player.Client.SteamUserId, blockSearch, searchSubType, false );
disabledPlayers[player.Client.SteamUserId].Add( blockSearch );
}
}
var ownedBlocks = new Dictionary<long, int>();
var entities = new HashSet<MyEntity>();
var razeBlocks = new HashSet<MyCubeBlock>();
Wrapper.GameAction( () => entities = MyEntities.GetEntities() );
MyEntity[] entitiesCopy = new MyEntity[entities.Count];
entities.CopyTo( entitiesCopy );
foreach ( var entity in entitiesCopy )
{
var grid = entity as MyCubeGrid;
if ( grid?.Physics == null || grid.Closed )
continue;
foreach ( var cubeBlock in grid.GetFatBlocks() )
{
if ( cubeBlock.Closed )
continue;
if ( ( searchSubType && cubeBlock.BlockDefinition.Id.SubtypeId.ToString().Contains( blockSearch ) )
|| ( !searchSubType && cubeBlock.BlockDefinition.Id.TypeId.ToString().Contains( blockSearch ) ) )
{
//Essentials.Log.Debug( $"found block: {cubeBlock.BlockDefinition.Id.SubtypeName}" );
if ( MySession.Static.Players.IdentityIsNpc( cubeBlock.OwnerId ) )
{
//Essentials.Log.Debug( "not processing NPC owned block" );
continue;
}
if ( ownedBlocks.ContainsKey( cubeBlock.OwnerId ) )
ownedBlocks[cubeBlock.OwnerId]++;
else
ownedBlocks.Add( cubeBlock.OwnerId, 1 );
foreach ( var entry in ownedBlocks )
{
if ( entry.Key != cubeBlock.OwnerId )
continue;
if ( entry.Value > item.MaxPerGrid )
{
if ( newBlock != null && newBlock.GetType() == cubeBlock.GetType() && !razeBlocks.Contains( newBlock ) )
razeBlocks.Add( newBlock );
//.........这里部分代码省略.........