本文整理汇总了C#中ContractConfigurator.ConfiguredContract.Fail方法的典型用法代码示例。如果您正苦于以下问题:C# ConfiguredContract.Fail方法的具体用法?C# ConfiguredContract.Fail怎么用?C# ConfiguredContract.Fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContractConfigurator.ConfiguredContract
的用法示例。
在下文中一共展示了ConfiguredContract.Fail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequirementsMet
/// <summary>
/// Checks if all the given ContractRequirement meet the requirement.
/// </summary>
/// <param name="contract">Contract to check</param>
/// <param name="contractType">Contract type of the contract (in case the contract type has not yet been assigned).</param>
/// <param name="contractRequirements">The list of requirements to check</param>
/// <returns>Whether the requirement is met or not.</returns>
public static bool RequirementsMet(ConfiguredContract contract, ContractType contractType, IEnumerable<ContractRequirement> contractRequirements)
{
bool allReqMet = true;
try
{
LoggingUtil.LogVerbose(typeof(ContractRequirement), "Checking requirements for contract '" + contractType.name);
foreach (ContractRequirement requirement in contractRequirements)
{
if (requirement.enabled)
{
if (requirement.checkOnActiveContract || contract.ContractState != Contract.State.Active)
{
allReqMet = allReqMet && requirement.CheckRequirement(contract);
if (!allReqMet)
{
LoggingUtil.Log(contract.ContractState == Contract.State.Active ? LoggingUtil.LogLevel.INFO : LoggingUtil.LogLevel.VERBOSE,
requirement.GetType(), "Contract " + contractType.name + ": requirement " + requirement.name + " was not met.");
break;
}
}
}
}
// Force fail the contract if a requirement becomes unmet
if (contract.ContractState == Contract.State.Active && !allReqMet)
{
// Fail the contract - unfortunately, the player won't know why. :(
contract.Fail();
// Force the stock contracts window to refresh
GameEvents.Contract.onContractsLoaded.Fire();
}
}
catch (Exception e)
{
LoggingUtil.LogException(new Exception("ContractConfigurator: Exception checking requirements!", e));
return false;
}
return allReqMet;
}