debug: F8 shows why a drone feeds a station or not, and what holds its fight
For the nearest worker drone F8 now lists the Eldividarkista and its wood, every station in the radius (operable, free slots, takes wood, penalty, claim, fuel, what a load would bring), and stations just past the edge with the distance. Each drone also reports the 12 m enemy sweep and how long the fight linger has left.
This commit is contained in:
parent
b16d1775d8
commit
9bd98c68c3
1 changed files with 66 additions and 1 deletions
|
|
@ -1664,10 +1664,22 @@ namespace RacesOfValheim
|
||||||
lines.Add($"[RoV drone] {distance:0}m: '{drone.Status}' job {(drone.m_job != null ? drone.m_job.Kind : "none")} " +
|
lines.Add($"[RoV drone] {distance:0}m: '{drone.Status}' job {(drone.m_job != null ? drone.m_job.Kind : "none")} " +
|
||||||
$"carry {drone.PayloadCount()} fight {drone.m_fighting} vanilla target {targetText} " +
|
$"carry {drone.PayloadCount()} fight {drone.m_fighting} vanilla target {targetText} " +
|
||||||
$"alerted {drone.m_ai.IsAlerted()} flying {drone.m_character.IsFlying()} owner {drone.m_nview.IsOwner()}");
|
$"alerted {drone.m_ai.IsAlerted()} flying {drone.m_character.IsFlying()} owner {drone.m_nview.IsOwner()}");
|
||||||
|
|
||||||
|
// The other half of what holds a fight: the 12 m sweep, and how long the linger has left.
|
||||||
|
Character near = BaseAI.FindClosestEnemy(drone.m_character, drone.transform.position, FightRange);
|
||||||
|
string nearText = near != null
|
||||||
|
? $"{Utils.GetPrefabName(near.gameObject)} {Vector3.Distance(near.transform.position, drone.transform.position):0}m"
|
||||||
|
: "none";
|
||||||
|
lines.Add($"[RoV drone] fight left {Mathf.Max(0f, drone.m_fightUntil - Time.time):0.0}s, " +
|
||||||
|
$"closest enemy {nearText}, in reach {(target != null && drone.InFightReach(target))}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nearest == null) lines.Add("[RoV drone] no worker drone within 60m");
|
if (nearest == null) lines.Add("[RoV drone] no worker drone within 60m");
|
||||||
else lines.AddRange(nearest.SortReport());
|
else
|
||||||
|
{
|
||||||
|
lines.AddRange(nearest.SortReport());
|
||||||
|
lines.AddRange(nearest.StationReport());
|
||||||
|
}
|
||||||
|
|
||||||
foreach (string line in lines)
|
foreach (string line in lines)
|
||||||
{
|
{
|
||||||
|
|
@ -1676,6 +1688,59 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Why a station is (or is not) fed: what the last scan saw, the wood chest, and every
|
||||||
|
/// smelter, hearth or fermenter within the radius - and the ones just past it, by how much.</summary>
|
||||||
|
private IEnumerable<string> StationReport()
|
||||||
|
{
|
||||||
|
Vector3? anchor = Anchor;
|
||||||
|
if (anchor == null) { yield return "[RoV station] no anchor"; yield break; }
|
||||||
|
|
||||||
|
float radius = AlfarNexusConfig.NexusRadius.Value + m_radiusBonus;
|
||||||
|
yield return $"[RoV station] anchor {Vector3.Distance(transform.position, anchor.Value):0}m from drone, " +
|
||||||
|
$"radius {radius:0}, scanned {Time.time - m_scannedAt:0}s ago, {m_stations.Count} stations, {m_chests.Count} chests";
|
||||||
|
|
||||||
|
if (m_wood == null) yield return "[RoV station] no Eldividarkista in range (or it is open, or holds the sigil)";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var wood = new List<string>();
|
||||||
|
Inventory inventory = m_wood.GetInventory();
|
||||||
|
if (inventory != null)
|
||||||
|
{
|
||||||
|
foreach (ItemDrop.ItemData item in inventory.GetAllItems())
|
||||||
|
{
|
||||||
|
wood.Add(item.m_dropPrefab != null ? $"{item.m_dropPrefab.name}x{item.m_stack}" : $"{item.m_shared.m_name}(no prefab)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yield return $"[RoV station] Eldividarkista {Vector3.Distance(m_wood.transform.position, anchor.Value):0}m from anchor, " +
|
||||||
|
$"open {m_wood.IsInUse()}, penalty {IsPenalised(ZdoOf(m_wood))}, holds [{string.Join(", ", wood.ToArray())}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ButlerStation station in m_stations)
|
||||||
|
{
|
||||||
|
if (!station.Alive) { yield return "[RoV station] (a station that is gone)"; continue; }
|
||||||
|
|
||||||
|
Container chest;
|
||||||
|
string material = FindMaterialFor(station, out chest);
|
||||||
|
string from = material == null ? "nothing" : $"{material} from {(chest == m_wood ? "Eldividarkista" : "entry")}";
|
||||||
|
yield return $"[RoV station] {Utils.GetPrefabName(station.Behaviour.gameObject)} " +
|
||||||
|
$"{Vector3.Distance(station.Position, anchor.Value):0}m: operable {station.Operable} free {station.FreeSlots} " +
|
||||||
|
$"work {station.HasWork} wood {station.Accepts("Wood")} penalty {IsPenalised(station.Id)} " +
|
||||||
|
$"claimed {ClaimedByOther(station.Id)} fuel {station.FuelPrefab ?? "-"}/{station.FuelWanted} | load: {from}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// A station the scan cannot see because it stands past the edge.
|
||||||
|
List<Piece> pieces = AllPiecesField != null ? AllPiecesField.GetValue(null) as List<Piece> : null;
|
||||||
|
if (pieces == null) yield break;
|
||||||
|
foreach (Piece piece in pieces)
|
||||||
|
{
|
||||||
|
if (piece == null) continue;
|
||||||
|
float distance = Vector3.Distance(piece.transform.position, anchor.Value);
|
||||||
|
if (distance <= radius || distance > radius + 15f) continue;
|
||||||
|
if (ButlerStation.From(piece.gameObject) == null) continue;
|
||||||
|
yield return $"[RoV station] {Utils.GetPrefabName(piece.gameObject)} {distance:0}m: OUTSIDE the radius by {distance - radius:0.0}m";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private IEnumerable<string> SortReport()
|
private IEnumerable<string> SortReport()
|
||||||
{
|
{
|
||||||
if (m_entry == null) { yield return "[RoV sort] no entry chest in range"; yield break; }
|
if (m_entry == null) { yield return "[RoV sort] no entry chest in range"; yield break; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue