Skip to content

Commit

Permalink
add GetEntitySyncVarInfo for debug purposes. Add InternalEntity.IsSin…
Browse files Browse the repository at this point in the history
…gleton. Make InternalEntity IsClient and IsServer public
  • Loading branch information
RevenantX committed Jan 13, 2025
1 parent aeae449 commit c3bed67
Show file tree
Hide file tree
Showing 3 changed files with 369 additions and 340 deletions.
20 changes: 20 additions & 0 deletions LiteEntitySystem/EntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public enum MaxHistorySize : byte
Size64 = 64,
Size128 = 128
}

/// <summary>
/// Helper interface for printing entity syncVar names and values
/// </summary>
public interface IEntitySyncVarInfoPrinter
{
void PrintFieldInfo(string fieldName, string fieldValue);
}

/// <summary>
/// Base class for client and server manager
Expand Down Expand Up @@ -273,6 +281,18 @@ protected EntityManager(EntityTypesMap typesMap, InputProcessor inputProcessor,
/// <param name="classId"></param>
/// <returns></returns>
public Type GetEntityTypeFromClassId(ushort classId) => classId >= ClassDataDict.Length ? null : ClassDataDict[classId].Type;

/// <summary>
/// Prints names and values of entity syncVars using IEntitySyncVarInfoPrinter
/// </summary>
/// <param name="entity">entity to show</param>
/// <param name="resultPrinter">IEntitySyncVarInfoPrinter implementation</param>
public void GetEntitySyncVarInfo(InternalEntity entity, IEntitySyncVarInfoPrinter resultPrinter)
{
ref var classData = ref ClassDataDict[entity.ClassId];
foreach (EntityFieldInfo fi in classData.Fields)
resultPrinter.PrintFieldInfo(fi.Name, fi.TypeProcessor.ToString(entity, fi.Offset));
}

/// <summary>
/// Remove all entities and reset all counters and timers
Expand Down
Loading

0 comments on commit c3bed67

Please sign in to comment.