本文整理汇总了C#中Building.TryGetComp方法的典型用法代码示例。如果您正苦于以下问题:C# Building.TryGetComp方法的具体用法?C# Building.TryGetComp怎么用?C# Building.TryGetComp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Building
的用法示例。
在下文中一共展示了Building.TryGetComp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckBuilding
private bool CheckBuilding( Building b )
{
// Only check for power traders
var p = b.TryGetComp<CompPowerTrader>();
if( p == null )
return false;
// That are connected to a power network
if( p.PowerNet == null )
return false;
// Which aren't powered on
if( p.PowerOn == true )
return false;
// Which want to be powered on
if( p.DesirePowerOn == false )
return false;
/*
// Batteries on network, don't worry about it for now
if( p.PowerNet.CurrentStoredEnergy() >= 1 )
return false;
// Where the network power is too low
var netEnergy = p.PowerNet.CurrentEnergyGainRate() / CompPower.WattsToWattDaysPerTick;
if( netEnergy > -p.EnergyOutputPerTick )
return false;
*/
// And return this building is under powered
return true;
}
示例2: GetDurability
public static float GetDurability( Building building )
{
CompBreakdownable comp = building.TryGetComp<CompBreakdownable>();
if ( comp == null )
return 1f;
else
return GetDurability( comp );
}
示例3: NewAirNetStartingFrom
public static AirNet NewAirNetStartingFrom( Building root, NetLayer layer )
{
return new AirNet( ContiguousAirBuildings( root, layer ), layer, root.TryGetComp<CompAir>() );
}
示例4: SetDurability
public static void SetDurability( Building building, float durability )
{
CompBreakdownable comp = building.TryGetComp<CompBreakdownable>();
if ( comp != null )
SetDurability( comp, durability );
}