forked from Shardstone/trail-into-darkness
some syntax and such and adde an editor tool for visualising logs
This commit is contained in:
@@ -4,10 +4,10 @@ using UnityEngine;
|
||||
|
||||
namespace Jovian.InGameLogging {
|
||||
public sealed class GameLogStore : IGameLogStore {
|
||||
readonly LogEntry[] buffer;
|
||||
readonly HashSet<LogChannel> disabledChannels = new();
|
||||
int head;
|
||||
int count;
|
||||
private readonly LogEntry[] buffer;
|
||||
private readonly HashSet<LogChannel> disabledChannels = new();
|
||||
private int head;
|
||||
private int count;
|
||||
|
||||
public int Count => count;
|
||||
public int Capacity => buffer.Length;
|
||||
@@ -55,7 +55,7 @@ namespace Jovian.InGameLogging {
|
||||
public void Clear(LogChannel channel) {
|
||||
var kept = new List<LogEntry>(count);
|
||||
var entries = GetEntries();
|
||||
for(int i = 0; i < entries.Length; i++) {
|
||||
for(var i = 0; i < entries.Length; i++) {
|
||||
if(entries[i].channel != channel) {
|
||||
kept.Add(entries[i]);
|
||||
}
|
||||
@@ -76,8 +76,8 @@ namespace Jovian.InGameLogging {
|
||||
return new ReadOnlySpan<LogEntry>(buffer, 0, count);
|
||||
}
|
||||
var result = new LogEntry[count];
|
||||
int start = head;
|
||||
for(int i = 0; i < count; i++) {
|
||||
var start = head;
|
||||
for(var i = 0; i < count; i++) {
|
||||
result[i] = buffer[(start + i) % buffer.Length];
|
||||
}
|
||||
return result;
|
||||
@@ -86,7 +86,7 @@ namespace Jovian.InGameLogging {
|
||||
public int GetEntries(LogChannel channel, List<LogEntry> results) {
|
||||
results.Clear();
|
||||
var entries = GetEntries();
|
||||
for(int i = 0; i < entries.Length; i++) {
|
||||
for(var i = 0; i < entries.Length; i++) {
|
||||
if(entries[i].channel == channel) {
|
||||
results.Add(entries[i]);
|
||||
}
|
||||
@@ -97,8 +97,8 @@ namespace Jovian.InGameLogging {
|
||||
public GameLogSaveData GetSaveData() {
|
||||
var entries = GetEntries();
|
||||
var list = new List<LogEntry>(entries.Length);
|
||||
for(int i = 0; i < entries.Length; i++) {
|
||||
list.Add(entries[i]);
|
||||
foreach(var t in entries) {
|
||||
list.Add(t);
|
||||
}
|
||||
return new GameLogSaveData(list);
|
||||
}
|
||||
@@ -110,8 +110,8 @@ namespace Jovian.InGameLogging {
|
||||
OnCleared?.Invoke();
|
||||
return;
|
||||
}
|
||||
int startIndex = Math.Max(0, data.entries.Count - buffer.Length);
|
||||
for(int i = startIndex; i < data.entries.Count; i++) {
|
||||
var startIndex = Math.Max(0, data.entries.Count - buffer.Length);
|
||||
for(var i = startIndex; i < data.entries.Count; i++) {
|
||||
buffer[count] = data.entries[i];
|
||||
count++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user