本文整理汇总了C#中System.Collections.Dictionary.MoveNext方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.MoveNext方法的具体用法?C# Dictionary.MoveNext怎么用?C# Dictionary.MoveNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Dictionary
的用法示例。
在下文中一共展示了Dictionary.MoveNext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: update
//-------------update------------
/** 'update' the scheduler.
You should NEVER call this method, unless you know what you are doing.
*/
public void update(float dt){
if (_paused)
return;
updateHashLocked = true;
if (!FloatUtils.EQ(_timeScale , 1.0f))
dt *= _timeScale;
// Iterate all over the Updates selectors
// updates with priority < 0
{
for( utNode<tListEntry> tmp = updatesNeg.head; tmp != null ; tmp = tmp.next ) {
utNode<tListEntry> entry = tmp;
if(! entry.obj.paused && !entry.obj.markedForDeletion){
entry.obj.impMethod.Invoke(dt);
}
}
}
// updates with priority == 0
{
for( utNode<tListEntry> tmp = updates0.head; tmp != null ; tmp = tmp.next ) {
utNode<tListEntry> entry = tmp;
if(! entry.obj.paused && !entry.obj.markedForDeletion)
entry.obj.impMethod.Invoke(dt);
}
}
// updates with priority > 0
{
for( utNode<tListEntry> tmp = updatesPos.head; tmp != null ; tmp = tmp.next ) {
utNode<tListEntry> entry = tmp;
if(! entry.obj.paused && !entry.obj.markedForDeletion)
entry.obj.impMethod.Invoke(dt);
}
}
// Iterate all over the custom selectors (CCTimers)
if(hashForTimers.Any()){
var enumerator = new Dictionary<int, tHashTimerEntry>(hashForTimers).GetEnumerator();
while (enumerator.MoveNext()) {
var elt = enumerator.Current.Value;
currentTarget = elt;
currentTargetSalvaged = false;
if( ! currentTarget.paused){
for(elt.timerIndex = 0; elt.timerIndex < elt.timers.Count; elt.timerIndex ++ ){
elt.currentTimer = elt.timers[elt.timerIndex];
elt.currentTimerSalvaged = false;
elt.currentTimer.update(dt);
elt.currentTimer = null;
}
}
if(currentTargetSalvaged && currentTarget.timers.Count == 0)
removeHashElement(currentTarget);
}
}
for (utNode<tListEntry> tmp = updatesNeg.head; tmp != null; tmp = tmp.next) {
utNode<tListEntry> entry = tmp;
if(entry.obj.markedForDeletion){
removeUpdatesFromHash(entry);
}
}
for (utNode<tListEntry> tmp = updates0.head; tmp != null; tmp = tmp.next) {
utNode<tListEntry> entry = tmp;
if(entry.obj.markedForDeletion){
removeUpdatesFromHash(entry);
}
}
for (utNode<tListEntry> tmp = updatesPos.head; tmp != null; tmp = tmp.next) {
utNode<tListEntry> entry = tmp;
if(entry.obj.markedForDeletion){
removeUpdatesFromHash(entry);
}
}
updateHashLocked = false;
currentTarget = null;
}
示例2: CacheVessels
private void CacheVessels()
{
if (!isReady)
return;
if (!tfScenario.SettingsEnabled)
return;
// build a list of vessels to process based on setting
if (knownVessels == null)
knownVessels = new Dictionary<Guid, double>();
// iterate through our cached vessels and delete ones that are no longer valid
vesselsToDelete.Clear();
knownVesselsEnumerator = knownVessels.GetEnumerator();
while (knownVesselsEnumerator.MoveNext())
{
KeyValuePair<Guid, double> entry = knownVesselsEnumerator.Current;
Vessel vessel = null;
for (int i = 0; i < FlightGlobals.Vessels.Count; i++)
{
if (FlightGlobals.Vessels[i].id == entry.Key)
vessel = FlightGlobals.Vessels[i];
}
if (vessel == null)
vesselsToDelete.Add(entry.Key);
else
{
if (vessel.vesselType == VesselType.Debris)
vesselsToDelete.Add(entry.Key);
}
}
for (int i = 0; i < vesselsToDelete.Count; i++)
{
knownVessels.Remove(vesselsToDelete[i]);
}
// Build our cached list of vessels. The reason we do this is so that we can store an internal "missionStartTime" for each vessel because the game
// doesn't consider a vessel launched, and does not start the mission clock, until the player activates the first stage. This is fine except it
// makes things like engine test stands impossible, so we instead cache the vessel the first time we see it and use that time as the missionStartTime
if (!tfScenario.userSettings.processAllVessels)
{
if (FlightGlobals.ActiveVessel == null || knownVessels.ContainsKey(FlightGlobals.ActiveVessel.id))
return;
knownVessels.Add(FlightGlobals.ActiveVessel.id, Planetarium.GetUniversalTime());
InitializeParts(FlightGlobals.ActiveVessel);
}
else
{
for (int i = 0; i < FlightGlobals.Vessels.Count; i++)
{
Vessel vessel = FlightGlobals.Vessels[i];
if (vessel.vesselType != VesselType.Lander && vessel.vesselType != VesselType.Probe &&
vessel.vesselType != VesselType.Rover && vessel.vesselType != VesselType.Ship &&
vessel.vesselType != VesselType.Station) continue;
if (knownVessels.ContainsKey(vessel.id)) continue;
knownVessels.Add(vessel.id, Planetarium.GetUniversalTime());
InitializeParts(vessel);
}
}
}
示例3: VerifyMasterStatus
// This method simply scans through the Master Status list every now and then and removes vessels and parts that no longer exist
private void VerifyMasterStatus()
{
if (!isReady)
return;
if (!tfScenario.SettingsEnabled)
return;
// iterate through our cached vessels and delete ones that are no longer valid
vesselsToDelete.Clear();
masterStatusEnumerator = masterStatus.GetEnumerator();
while (masterStatusEnumerator.MoveNext())
{
KeyValuePair<Guid, MasterStatusItem> entry = masterStatusEnumerator.Current;
Vessel vessel = null;
for (int i = 0; i < FlightGlobals.Vessels.Count; i++)
{
if (FlightGlobals.Vessels[i].id == entry.Key)
vessel = FlightGlobals.Vessels[i];
}
if (vessel == null)
{
vesselsToDelete.Add(entry.Key);
}
else
{
if (vessel.vesselType == VesselType.Debris)
{
vesselsToDelete.Add(entry.Key);
}
}
}
for (int i = 0; i < vesselsToDelete.Count; i++)
{
masterStatus.Remove(vesselsToDelete[i]);
}
// iterate through the remaining vessels and check for parts that no longer exist
partsToDelete.Clear();
masterStatusEnumerator = masterStatus.GetEnumerator();
while (masterStatusEnumerator.MoveNext())
{
KeyValuePair<Guid, MasterStatusItem> entry = masterStatusEnumerator.Current;
Vessel vessel = null;
for (int i = 0; i < FlightGlobals.Vessels.Count; i++)
{
if (FlightGlobals.Vessels[i].id == entry.Key)
vessel = FlightGlobals.Vessels[i];
}
for (int i = 0; i < masterStatus[entry.Key].allPartsStatus.Count; i++)
{
PartStatus partStatus = masterStatus[entry.Key].allPartsStatus[i];
Part part = null;
for (int j = 0; j < vessel.Parts.Count; j++)
{
if (vessel.Parts[j].flightID == partStatus.partID)
part = vessel.Parts[j];
}
if (part == null)
{
partsToDelete.Add(partStatus);
}
}
for (int i = 0; i < partsToDelete.Count; i++)
{
PartStatus oldPartStatus = partsToDelete[i];
if (oldPartStatus.lastSeen < Planetarium.GetUniversalTime() - partDecayTime)
masterStatus[entry.Key].allPartsStatus.Remove(oldPartStatus);
}
}
}
示例4: Update
internal override void Update()
{
if (!isReady)
return;
if (!tfScenario.SettingsEnabled)
return;
if (masterStatus == null)
masterStatus = new Dictionary<Guid, MasterStatusItem>();
currentUTC = Planetarium.GetUniversalTime();
// ensure out vessel list is up to date
Profiler.BeginSample("CacheVessels");
CacheVessels();
Profiler.EndSample();
if (currentUTC >= lastMasterStatusUpdate + tfScenario.userSettings.masterStatusUpdateFrequency)
{
lastMasterStatusUpdate = currentUTC;
Profiler.BeginSample("VerifyMasterStatus");
VerifyMasterStatus();
Profiler.EndSample();
}
// process vessels
Profiler.BeginSample("ProcessVessels");
knownVesselsEnumerator = knownVessels.GetEnumerator();
while (knownVesselsEnumerator.MoveNext())
{
KeyValuePair<Guid, double> entry = knownVesselsEnumerator.Current;
Vessel vessel = null;
Profiler.BeginSample("FindVessel");
for (int i = 0; i < FlightGlobals.Vessels.Count; i++)
{
if (FlightGlobals.Vessels[i].id == entry.Key)
vessel = FlightGlobals.Vessels[i];
}
Profiler.EndSample();
if (vessel == null)
continue;
if (vessel.loaded)
{
Profiler.BeginSample("ProcessParts");
List<Part> parts = vessel.Parts;
for (int j = 0; j < parts.Count; j++)
{
// Each KSP part can be composed of N virtual parts
Profiler.BeginSample("Reset Core List");
cores.Clear();
Profiler.EndSample();
Profiler.BeginSample("Get Cores");
for (int k = 0; k < parts[j].Modules.Count; k++)
{
ITestFlightCore core = parts[j].Modules[k] as ITestFlightCore;
if (core != null && core.TestFlightEnabled)
cores.Add(core.Alias);
}
Profiler.EndSample();
//cores = TestFlightInterface.GetActiveCores(vessel.parts[j]);
if (cores == null || cores.Count <= 0)
continue;
Profiler.BeginSample("ProcessCores");
for (int k = 0; k < cores.Count; k++)
{
ITestFlightCore core = TestFlightUtil.GetCore(vessel.parts[j], cores[k]);
if (core == null) continue;
// Poll for flight data and part status
if (!(currentUTC >= lastDataPoll + tfScenario.userSettings.masterStatusUpdateFrequency))
continue;
// Update or Add part status in Master Status
if (masterStatus.ContainsKey(vessel.id))
{
Profiler.BeginSample("MasterStatus Existing Vessel");
// Vessel is already in the Master Status, so check if part is in there as well
int existingPartIndex = -1;
Profiler.BeginSample("Find Part");
for (int msIndex = 0; msIndex < masterStatus[vessel.id].allPartsStatus.Count; msIndex++)
{
if (masterStatus[vessel.id].allPartsStatus[msIndex].partID !=
vessel.parts[j].flightID) continue;
existingPartIndex = msIndex;
break;
}
Profiler.EndSample();
if (existingPartIndex > -1)
{
Profiler.BeginSample("Existing Part");
//PartStatus partStatus = masterStatus[vessel.id].allPartsStatus[existingPartIndex];
PartStatus partStatus = new PartStatus();
partStatus.lastSeen = currentUTC;
partStatus.flightCore = core;
partStatus.partName = core.Title;
partStatus.partID = vessel.parts[j].flightID;
Profiler.BeginSample("Part - GetPartStatus");
partStatus.partStatus = core.GetPartStatus();
Profiler.EndSample();
// get any failures
Profiler.BeginSample("Part - GetActiveFailures");
partStatus.failures = core.GetActiveFailures();
Profiler.EndSample();
//.........这里部分代码省略.........
示例5: Update
public void Update()
{
if (TestFlightManagerScenario.Instance == null)
return;
if (!TestFlightManagerScenario.Instance.SettingsEnabled)
return;
double currentTime = Planetarium.GetUniversalTime();
teamsToStop.Clear();
if (currentTime - lastUpdateTime >= updateFrequency)
{
float normalizedTime = (float)((currentTime - lastUpdateTime) / updateFrequency);
Log("Doing research update, normalized time " + normalizedTime);
lastUpdateTime = currentTime;
if (activeTeams == null || activeTeams.Count <= 0)
return;
teamsEnumerator = activeTeams.GetEnumerator();
KeyValuePair<string, TestFlightRnDTeam> entry;
while (teamsEnumerator.MoveNext())
{
entry = teamsEnumerator.Current;
if (entry.Value.PartInResearch != "" && entry.Value.ResearchActive)
{
float partCurrentData = tfScenario.GetFlightDataForPartName(entry.Value.PartInResearch);
if (partCurrentData >= entry.Value.MaxData)
{
Log("Part " + entry.Value.PartInResearch + " has reached maximum RnD data. Removing research automatically");
teamsToStop.Add(entry.Key);
}
else
{
float partData = entry.Value.UpdateResearch(normalizedTime, partCurrentData);
Log("Research tick for part " + entry.Value.PartInResearch + " yielded " + partData + "du");
if (partData > 0)
{
TestFlightManagerScenario.Instance.AddFlightDataForPartName(entry.Value.PartInResearch, partData);
}
}
}
}
if (teamsToStop.Count > 0)
{
for (int i = 0; i < teamsToStop.Count; i++)
{
activeTeams.Remove(teamsToStop[i]);
}
}
}
}
示例6: update
public void update(float dt){
if (!_targets.Any ()) {
return;
}
var enumerator = new Dictionary<int, tHashElement>(_targets).GetEnumerator();
while (enumerator.MoveNext()) {
var elt = enumerator.Current.Value;
_currentTarget = elt;
_currentTargetSavlvaged = false;
if(elt.target !=null && elt.actions != null && !elt.paused){
for( elt.actionIndex = 0; elt.actions!=null && elt.actionIndex < elt.actions.Count; elt.actionIndex++) {
elt.currentAction = elt.actions[elt.actionIndex];
elt.currentActionSalvaged = false;
elt.currentAction.step(dt);
if(!elt.currentActionSalvaged && elt.currentAction!=null && elt.currentAction.isDone()){
elt.currentAction.stop();
CCAction a = elt.currentAction;
elt.currentAction = null;
removeAction(a);
}
elt.currentAction = null;
}
}
if(_currentTargetSavlvaged && (elt.actions.Count ==0 || elt.target==null)){
deleteHashElement(elt);
}
}
_currentTarget = null;
}
示例7: SpawnChild
private void SpawnChild()
{
if (blockToSpawn != null)
{
if (blockToSpawn.GetBlockID() == 模块ID.Value)
{
return;
}
Destroy(blockToSpawn.gameObject);
}
if (!FunnyMode.IsActive)
{
blockToSpawn = Instantiate(PrefabMaster.BlockPrefabs[对应的IDs[模块ID.Value]].blockBehaviour);
blockToSpawn.gameObject.SetActive(false);
//blockToSpawn.transform.SetParent(this.transform);
}
else
{
funEnumerator = PrefabMaster.BlockPrefabs.GetEnumerator();
while (funEnumerator.MoveNext())
{
if (funEnumerator.Current.Value.ID == 对应的IDs[模块ID.Value])
{
return;
}
}
funEnumerator = PrefabMaster.BlockPrefabs.GetEnumerator();
funEnumerator.MoveNext();
}
}
示例8: OnSimulateFixedUpdate
protected override void OnSimulateFixedUpdate()
{
if (countdown > 0)
{
countdown -= Time.fixedDeltaTime;
}
if (Key1.IsDown && countdown <= 0)
{
GameObject Nlock;
if (FunnyMode.IsActive)
{
Nlock = (GameObject)Instantiate(funEnumerator.Current.Value.gameObject,
this.transform.position + this.transform.forward, this.transform.rotation);
if (!funEnumerator.MoveNext())
{
funEnumerator = PrefabMaster.BlockPrefabs.GetEnumerator();
funEnumerator.MoveNext();
}
}
else
{
if (blockToSpawn == null)
{
SpawnChild();
}
Nlock = (GameObject)Instantiate(blockToSpawn.gameObject,
transform.position + this.transform.forward, this.transform.rotation);
Nlock.SetActive(true);
XDataHolder xDataHolder = new XDataHolder { WasSimulationStarted = true };
blockToSpawn.OnSave(xDataHolder);
Nlock.GetComponent<BlockBehaviour>().OnLoad(xDataHolder);
}
Nlock.transform.localScale *= 生成大小.Value;
Nlock.GetComponent<Rigidbody>().isKinematic = false;
if (继承速度.IsActive) { Nlock.GetComponent<Rigidbody>().velocity = this.rigidbody.velocity; }
Nlock.transform.SetParent(Machine.Active().SimulationMachine);
Audio.volume = 0.05f * 10 / Vector3.Distance(this.transform.position, Camera.main.transform.position);
Audio.Play();
countdown = 生成间隔.Value;
}
}