public static void SubmitDeathClaim(byte districtNo, DeathClaim claim) { districts[districtNo].Add(claim); claims[claim.buildingID] = claim; registeredBuildings[claim.buildingID] = true; registeredBuildingsDistrict[claim.buildingID] = districtNo; }
public static void RecallDeathClaim(byte districtNo, DeathClaim claim) { districts[districtNo].FindAndDelete(claim); claims[claim.buildingID] = null; registeredBuildings[claim.buildingID] = false; registeredBuildingsDistrict[claim.buildingID] = 0; }
public void FindAndDelete(DeathClaim claim) { if (count == 0) { return; //Possibly could be removed for optimization } if (claim == head.data) { DeleteHead(); return; } if (claim == tail.data) { DeleteTail(); return; } Node cursor = head; Node prevCursor = null; while (cursor.data != claim) { prevCursor = cursor; cursor = cursor.next; if (cursor == null) { return; } } prevCursor.next = null; //set the target to null cursor = cursor.next; //move the cursor forward prevCursor.next = cursor; //set the prevcursor next to the cursor count--; }
private DeathClaim[] GetArray() { DeathClaim[] arr = new DeathClaim[count]; Node cursor = head; for (int i = 0; i < count; i++) { arr[i] = cursor.data; cursor = cursor.next; } return(arr); }
public void Add(DeathClaim claim) { count++; Node n = new Node(claim); if (head == null) { head = n; tail = n; return; } tail.next = n; tail = n; return; }
public override void SimulationStep(uint citizenID, ref Citizen data) { base.SimulationStep(citizenID, ref data); /* TODO: * remove lock statements as they may not be useful * also refactor code */ switch (data.CurrentLocation) { case Citizen.Location.Home: if (data.m_homeBuilding == 0) { return; } break; case Citizen.Location.Moving: if (data.m_vehicle == 0) { return; } break; case Citizen.Location.Visit: if (data.m_visitBuilding == 0) { return; } break; case Citizen.Location.Work: if (data.m_workBuilding == 0) { return; } break; default: return; } ushort citizenBuilding = 0; switch (data.CurrentLocation) { case Citizen.Location.Home: citizenBuilding = data.m_homeBuilding; break; case Citizen.Location.Visit: citizenBuilding = data.m_visitBuilding; break; case Citizen.Location.Work: citizenBuilding = data.m_workBuilding; break; default: break; } Vector3 p = Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizenBuilding].m_position; byte currentDistrict = Singleton <DistrictManager> .instance.GetDistrict(p); if (data.Dead && (DeathRegistry.IsRegistered(citizenBuilding) == false)) { DeathRegistry.claims[citizenBuilding] = new DeathClaim(); DeathClaim claim = DeathRegistry.claims[citizenBuilding]; claim.buildingID = citizenBuilding; claim.citizenID = citizenID; claim.pos = p; claim.location = data.CurrentLocation; //Debug.Log("Died At : " + Singleton<BuildingManager>.instance.m_buildings.m_buffer[citizenBuilding].Info.name); DeathRegistry.SubmitDeathClaim(currentDistrict, claim); return; } if (data.Dead && DeathRegistry.IsRegistered(citizenBuilding) && DeathRegistry.GetBuildingDistrict(citizenBuilding) != currentDistrict) { DeathClaim claim = DeathRegistry.claims[citizenBuilding]; if (!claim.vehicleArriving) { DeathRegistry.RecallDeathClaim(DeathRegistry.GetBuildingDistrict(claim.buildingID), claim); DeathRegistry.claims[citizenBuilding] = new DeathClaim(); claim = DeathRegistry.claims[citizenBuilding]; claim.buildingID = citizenBuilding; claim.citizenID = citizenID; claim.pos = p; claim.location = data.CurrentLocation; DeathRegistry.SubmitDeathClaim(currentDistrict, claim); return; } } }
public static void RestClaim(DeathClaim claim) { registeredBuildings[claim.buildingID] = false; registeredBuildingsDistrict[claim.buildingID] = 0; claims[claim.buildingID] = null; }
internal Node(DeathClaim claim, Node node) { data = claim; next = node; }
internal Node(DeathClaim claim) { data = claim; }