// When will the mob spawn next? Returns 0 if not available. // TODO: optimize this, as it is called much more often than the mob is being updated public int SecondsUntilSpawn(DateTime now) { int checkTimer = 0; if (NextSpawnDT != DateTime.MinValue) { TimeSpan Diff = NextSpawnDT.Subtract(now); checkTimer = (Diff.Hours * 3600) + (Diff.Minutes * 60) + Diff.Seconds; if (checkTimer <= 0) { checkTimer = 0; } } return(checkTimer); }
public string GetDescription() { int countTime = 0; string countTimer = ""; if (NextSpawnDT != DateTime.MinValue) { TimeSpan Diff = NextSpawnDT.Subtract(DateTime.Now); countTimer = Diff.Hours.ToString("00") + ":" + Diff.Minutes.ToString("00") + ":" + Diff.Seconds.ToString("00"); countTime = (Diff.Hours * 3600) + (Diff.Minutes * 60) + Diff.Seconds; } if (countTime > 0) { // StringBuilder moved to new, common method, as equal for all paths. StringBuilder spawnTimer = StBuilder(); spawnTimer.Append("\n"); spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr); spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr); spawnTimer.AppendFormat("Next Spawn At: {0}\n", NextSpawnStr); spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", SpawnTimer); spawnTimer.AppendFormat("Spawning In: {0}\n", countTimer); spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount); spawnTimer.AppendFormat("Y: {0:f3} X: {1:f3} Z: {2:f3}", Y, X, Z); return(spawnTimer.ToString()); } else if (SpawnTimer > 0) { StringBuilder spawnTimer = StBuilder(); spawnTimer.Append("\n"); spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr); spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr); spawnTimer.AppendFormat("Next Spawn At: {0}\n", ""); spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", SpawnTimer); spawnTimer.AppendFormat("Spawning In: {0}\n", ""); spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount); spawnTimer.AppendFormat("Y: {0:f3} X: {1:f3} Z: {2:f3}", Y, X, Z); return(spawnTimer.ToString()); } else { StringBuilder spawnTimer = StBuilder(); spawnTimer.Append("\n"); spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr); spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr); spawnTimer.AppendFormat("Next Spawn At: {0}\n", ""); spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", "0"); spawnTimer.AppendFormat("Spawning In: {0}\n", ""); spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount); spawnTimer.AppendFormat("Y: {0:f3} X: {1:f3} Z: {2:f3}", Y, X, Z); return(spawnTimer.ToString()); } }
public String GetDescription() { String descr = null; int countTime = 0; string countTimer = ""; if (NextSpawnDT != DateTime.MinValue) { TimeSpan Diff = NextSpawnDT.Subtract(DateTime.Now); countTimer = Diff.Hours.ToString("00") + ":" + Diff.Minutes.ToString("00") + ":" + Diff.Seconds.ToString("00"); countTime = (Diff.Hours * 3600) + (Diff.Minutes * 60) + Diff.Seconds; } if (countTime > 0) { StringBuilder spawnTimer = new StringBuilder(); spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName); string names_to_add = "Names encountered: "; string[] names = AllNames.Split(','); int namecount = 0; foreach (string name in names) { string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim(); if (namecount == 0) { names_to_add += namet; } else { if ((namet.Length + names_to_add.Length + 2) < 45) { names_to_add += ", "; names_to_add += namet; } else { spawnTimer.Append(names_to_add); spawnTimer.Append("\n"); names_to_add = namet; } } namecount++; } if (names_to_add.Length > 0) { spawnTimer.Append(names_to_add); } spawnTimer.Append("\n"); spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr); spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr); spawnTimer.AppendFormat("Next Spawn At: {0}\n", NextSpawnStr); spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", SpawnTimer); spawnTimer.AppendFormat("Spawning In: {0}\n", countTimer); spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount); spawnTimer.AppendFormat("Y: {0:f3} X: {1:f3} Z: {2:f3}", Y, X, Z); descr = spawnTimer.ToString(); } else if (SpawnTimer > 0) { StringBuilder spawnTimer = new StringBuilder(); spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName); string names_to_add = "Names encountered: "; string[] names = AllNames.Split(','); int namecount = 0; foreach (string name in names) { string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim(); if (namecount == 0) { names_to_add += namet; } else { if ((namet.Length + names_to_add.Length + 2) < 45) { names_to_add += ", "; names_to_add += namet; } else { spawnTimer.Append(names_to_add); spawnTimer.Append("\n"); names_to_add = namet; } } namecount++; } if (names_to_add.Length > 0) { spawnTimer.Append(names_to_add); } spawnTimer.Append("\n"); spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr); spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr); spawnTimer.AppendFormat("Next Spawn At: {0}\n", ""); spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", SpawnTimer); spawnTimer.AppendFormat("Spawning In: {0}\n", ""); spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount); spawnTimer.AppendFormat("Y: {0:f3} X: {1:f3} Z: {2:f3}", Y, X, Z); descr = spawnTimer.ToString(); } else { StringBuilder spawnTimer = new StringBuilder(); spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName); string names_to_add = "Names encountered: "; string[] names = AllNames.Split(','); int namecount = 0; foreach (string name in names) { string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim(); if (namecount == 0) { names_to_add += namet; } else { if ((namet.Length + names_to_add.Length + 2) < 45) { names_to_add += ", "; names_to_add += namet; } else { spawnTimer.Append(names_to_add); spawnTimer.Append("\n"); names_to_add = namet; } } namecount++; } if (names_to_add.Length > 0) { spawnTimer.Append(names_to_add); } spawnTimer.Append("\n"); spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr); spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr); spawnTimer.AppendFormat("Next Spawn At: {0}\n", ""); spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", "0"); spawnTimer.AppendFormat("Spawning In: {0}\n", ""); spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount); spawnTimer.AppendFormat("Y: {0:f3} X: {1:f3} Z: {2:f3}", Y, X, Z); descr = spawnTimer.ToString(); } return(descr); }