本文整理汇总了C#中Vessel.GetHashes方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.GetHashes方法的具体用法?C# Vessel.GetHashes怎么用?C# Vessel.GetHashes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.GetHashes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveSubVesselInfo
/// <summary>
/// Saves all the sub-vessel information - breaking up the vessels into the smallest
/// pieces possible.
/// </summary>
/// <param name="vessel">The vessel to break up</param>
/// <param name="strength">The strength of the parameter</param>
/// <param name="completionTime">The completion time</param>
private void SaveSubVesselInfo(Vessel vessel, ParamStrength strength, double completionTime)
{
foreach (uint hash in vessel.GetHashes())
{
if (!dockedVesselInfo.ContainsKey(hash) ||
dockedVesselInfo[hash].Key < strength)
{
dockedVesselInfo[hash] = new KeyValuePair<ParamStrength, double>(strength, completionTime);
}
}
}
示例2: VesselInfo
public VesselInfo(Vessel v)
{
this.id = v.id;
this.hash = v.GetHashes().FirstOrDefault();
}
示例3: OnVesselCreate
protected virtual void OnVesselCreate(Vessel vessel)
{
if (IsIgnoredVesselType(vessel.vesselType) || HighLogic.LoadedScene != GameScenes.FLIGHT)
{
return;
}
LoggingUtil.LogVerbose(this, "OnVesselCreate(" + vessel.id + ")");
// Go through the hashes to try to set the parameters for this vessel
KeyValuePair<ParamStrength, double>? dockedInfo = null;
foreach (uint hash in vessel.GetHashes())
{
if (dockedVesselInfo.ContainsKey(hash))
{
if (dockedInfo == null)
{
dockedInfo = dockedVesselInfo[hash];
}
else
{
dockedInfo = dockedVesselInfo[hash].Key > dockedInfo.Value.Key ? dockedVesselInfo[hash] : dockedInfo;
}
}
}
// Found one
if (dockedInfo != null)
{
VesselInfo v = new VesselInfo(vessel.id, vessel);
v.strength = dockedInfo.Value.Key;
v.completionTime = dockedInfo.Value.Value;
v.state = ParameterState.Complete;
vesselInfo[vessel.id] = v;
}
CheckVessel(vessel);
}
示例4: OnVesselWasModified
protected virtual void OnVesselWasModified(Vessel vessel)
{
LoggingUtil.LogVerbose(this, "OnVesselWasModified: " + vessel.id);
vessel.GetHashes().Count();
// Check for a vessel creation after a part joint break
if (HighLogic.LoadedScene != GameScenes.FLIGHT || lastBreak == null || vessel == lastBreak)
{
return;
}
IEnumerable<uint> otherVesselHashes = lastBreak.GetHashes();
IEnumerable<uint> vesselHashes = vessel.GetHashes();
// OnVesselWasModified gets called twice, on the first call the vessels are still
// connected. Check for that case.
if (otherVesselHashes.Contains(vesselHashes.FirstOrDefault()))
{
// The second call will be for the original vessel. Swap over to check that one.
lastBreak = vessel;
return;
}
// Get the keys we will be looking at
List<string> vesselKeys = GetAssociatedKeys(vessel).ToList();
List<string> otherVesselKeys = GetAssociatedKeys(lastBreak).ToList();
// Check the lists and see if we need to do a switch
foreach (string key in vesselKeys)
{
// Check if we need to switch over to the newly created vessel
VesselInfo vi = vessels[key];
if (otherVesselHashes.Contains(vi.hash))
{
LoggingUtil.LogVerbose(this, "Moving association for '" + key + "' from " + vi.id + " to " + lastBreak.id);
vi.id = lastBreak.id;
OnVesselAssociation.Fire(new GameEvents.HostTargetAction<Vessel, string>(lastBreak, key));
}
}
foreach (string key in otherVesselKeys)
{
// Check if we need to switch over to the newly created vessel
VesselInfo vi = vessels[key];
if (vesselHashes.Contains(vi.hash))
{
LoggingUtil.LogVerbose(this, "Moving association for '" + key + "' from " + vi.id + " to " + vessel.id);
vi.id = vessel.id;
OnVesselAssociation.Fire(new GameEvents.HostTargetAction<Vessel, string>(vessel, key));
}
}
lastBreak = null;
}