本文整理汇总了C#中Vessel.GetActiveResources方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.GetActiveResources方法的具体用法?C# Vessel.GetActiveResources怎么用?C# Vessel.GetActiveResources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.GetActiveResources方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Triggered
public override bool Triggered(Vessel currentVessel)
{
foreach (Vessel.ActiveResource res in currentVessel.GetActiveResources())
{
if (res.info.name.ToUpper() == ResourceString.ToUpper())
{
if (res.amount < res.maxAmount * (Percentage * 0.01))
{
return true;
}
}
}
return false;
}
示例2: networkResourceStats
public static void networkResourceStats(Vessel v, string resource, out double available, out double capacity)
{
if (v.loaded)
{
var resourceDef = v.GetActiveResources().Find(res => res.info.name == resource);
if (resourceDef != null)
{
available = resourceDef.amount;
capacity = resourceDef.maxAmount;
return ; //use this for LAN ships
}
else
{
available = 0;
capacity = 0;
return;
}
}
else
{
available = 0;
capacity = 0;
double count = 0;
foreach (var part in v.protoVessel.protoPartSnapshots)
{
foreach (var res in part.resources)
{
if (res.resourceName == resource)
{
//print(res.resourceName + " " + res.resourceValues.GetValue("amount") + " " + res.resourceValues.GetValue("maxAmount"));
available += double.Parse(res.resourceValues.GetValue("amount"));
capacity += double.Parse(res.resourceValues.GetValue("maxAmount"));
//aggregateDictionary(res.resourceName, available, ref resources.amounts);
//aggregateDictionary(res.resourceName, capacity, ref resources.capcity);
count++;
}
}
}
}
}