mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace ET.Server
|
|
{
|
|
[EntitySystemOf(typeof(Cell))]
|
|
[FriendOf(typeof(Cell))]
|
|
public static partial class CellSystem
|
|
{
|
|
[EntitySystem]
|
|
private static void Awake(this ET.Server.Cell self)
|
|
{
|
|
|
|
}
|
|
|
|
[EntitySystem]
|
|
private static void Destroy(this Cell self)
|
|
{
|
|
self.AOIUnits.Clear();
|
|
|
|
self.SubsEnterEntities.Clear();
|
|
|
|
self.SubsLeaveEntities.Clear();
|
|
}
|
|
|
|
public static void Add(this Cell self, AOIEntity aoiEntity)
|
|
{
|
|
self.AOIUnits.Add(aoiEntity.Id, aoiEntity);
|
|
}
|
|
|
|
public static void Remove(this Cell self, AOIEntity aoiEntity)
|
|
{
|
|
self.AOIUnits.Remove(aoiEntity.Id);
|
|
}
|
|
|
|
public static string CellIdToString(this long cellId)
|
|
{
|
|
int y = (int)(cellId & 0xffffffff);
|
|
int x = (int)((ulong)cellId >> 32);
|
|
return $"{x}:{y}";
|
|
}
|
|
|
|
public static string CellIdToString(this HashSet<long> cellIds)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (long cellId in cellIds)
|
|
{
|
|
sb.Append(cellId.CellIdToString());
|
|
sb.Append(",");
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
}
|
|
} |