public void ProcessState()
{
// Only pulse state changes every 1.5s
if (DateTime.UtcNow.Subtract(_lastPulse).TotalMilliseconds < Time.Instance.QuestorPulse_milliseconds) //default: 1500ms
return;
_lastPulse = DateTime.UtcNow;
if (!Cache.Instance.InStation)
return;
if (Cache.Instance.InSpace)
return;
if (DateTime.UtcNow < Cache.Instance.LastInSpace.AddSeconds(20)) // we wait 20 seconds after we last thought we were in space before trying to do anything in station
return;
if (!string.IsNullOrEmpty(Settings.Instance.LootContainerName))
{
if (Cache.Instance.LootContainer == null)
{
if (Settings.Instance.DebugUnloadLoot) Logging.Log("UnloadLoot.ProcessState", "if (Cache.Instance.LootContainer == null)", Logging.Debug);
return;
}
PutLootHere = Cache.Instance.LootContainer;
PutLootHere_Description = "LootContainer Named: [" + Settings.Instance.LootContainerName + "]";
}
else if (!String.IsNullOrEmpty(Settings.Instance.LootHangarTabName) && Cache.Instance.LootHangar != null) //&& Cache.Instance.LootHangar.IsValid)
{
PutLootHere = Cache.Instance.LootHangar;
PutLootHere_Description = "LootHangar Named: [" + Settings.Instance.LootHangarTabName + "]";
}
else
{
PutLootHere = Cache.Instance.ItemHangar;
PutLootHere_Description = "ItemHangar";
}
switch (_States.CurrentUnloadLootState)
{
case UnloadLootState.Idle:
case UnloadLootState.Done:
break;
case UnloadLootState.Begin:
if (DateTime.UtcNow < _nextUnloadAction)
{
if (Settings.Instance.DebugUnloadLoot) Logging.Log("UnloadLoot", "will Continue in [ " + Math.Round(_nextUnloadAction.Subtract(DateTime.UtcNow).TotalSeconds, 0) + " ] sec", Logging.Debug);
break;
}
AmmoIsBeingMoved = false;
LootIsBeingMoved = false;
_lastUnloadAction = DateTime.UtcNow.AddSeconds(-10);
_States.CurrentUnloadLootState = UnloadLootState.MoveAmmo;
break;
case UnloadLootState.MoveAmmo:
if (!MoveAmmo()) return;
//_States.CurrentUnloadLootState = UnloadLootState.MoveLoot;
break;
case UnloadLootState.MoveLoot:
if (!MoveLoot()) return;
//_States.CurrentUnloadLootState = UnloadLootState.Done;
break;
}
}