public static AddToObjList ( List |
||
list | List |
|
entity | FSO.SimAntics.VMEntity | |
Résultat | void |
public static void AddToObjList(List<VMEntity> list, VMEntity entity)
{
if (list.Count == 0) { list.Add(entity); return; }
int id = entity.ObjectID-1;
int max = list.Count-1;
int min = 0;
while (max-1>min)
{
int mid = (max+min) / 2;
int nid = list[mid].ObjectID;
if (id < nid) max = mid;
else min = mid;
}
list.Insert((list[min].ObjectID>id)?min:((list[max].ObjectID > id)?max:max+1), entity);
}
public void RegeneratePortalInfo() { RoomInfo = new VMRoomInfo[Architecture.RoomData.Count()]; for (int i = 0; i < RoomInfo.Length; i++) { RoomInfo[i].Entities = new List <VMEntity>(); RoomInfo[i].Portals = new List <VMRoomPortal>(); RoomInfo[i].Room = Architecture.RoomData[i]; RoomInfo[i].Light = new RoomLighting(); } foreach (var obj in VM.Entities) { var room = GetObjectRoom(obj); VM.AddToObjList(RoomInfo[room].Entities, obj); if (obj.EntryPoints[15].ActionFunction != 0) { //portal object AddRoomPortal(obj, room); } obj.SetRoom(room); } for (ushort i = 0; i < RoomInfo.Length; i++) { RefreshLighting(i, i == (RoomInfo.Length - 1)); } if (VM.UseWorld) { World.InvalidateZoom(); } }