public override void StartTransfer(ushort vehicleID, ref Vehicle data, TransferManager.TransferReason material, TransferManager.TransferOffer offer) { if ((data.m_flags & Vehicle.Flags.TransferToTarget) != 0) { base.StartTransfer(vehicleID, ref data, material, offer); return; } Debug.Log("Starting Transfer"); try { districtNo[vehicleID] = Singleton <DistrictManager> .instance.GetDistrict(Singleton <BuildingManager> .instance.m_buildings.m_buffer[data.m_sourceBuilding].m_position); currentClaim[vehicleID] = DeathRegistry.GetDeathClaim(districtNo[vehicleID], data.GetLastFramePosition()); } catch (Exception E) { return; } if (currentClaim[vehicleID] == null) { return; } Debug.Log("Successful!"); TransferManager.TransferOffer betterOffer = new TransferManager.TransferOffer(); betterOffer.Active = true; betterOffer.Amount = 0; betterOffer.Building = currentClaim[vehicleID].buildingID; betterOffer.Citizen = currentClaim[vehicleID].citizenID; base.StartTransfer(vehicleID, ref data, material, betterOffer); }
public override void OnLevelLoaded(LoadMode mode) { DeathRegistry.Initialize(); AIOverwriter.OverwriteCitizenAI <ResidentAI, C_ResidentAI>(); AIOverwriter.OverwriteVehicleAI <HearseAI, C_HearseAI>(); }
public override void ReleaseVehicle(ushort vehicleID, ref Vehicle data) { //check if currentclaim is null try { if (currentClaim[vehicleID] != null) { DeathRegistry.SubmitDeathClaim(districtNo[vehicleID], currentClaim[vehicleID]); } } catch (Exception E) { } base.ReleaseVehicle(vehicleID, ref data); }
public override bool ArriveAtDestination(ushort vehicleID, ref Vehicle vehicleData) { try { if (currentClaim[vehicleID] != null) { DeathRegistry.RestClaim(currentClaim[vehicleID]); } } catch (Exception E) { } try { currentClaim[vehicleID] = null; } catch (Exception E) { } return(base.ArriveAtDestination(vehicleID, ref vehicleData)); }
private void ClearPhantoms() { CitizenManager CM = Singleton <CitizenManager> .instance; DeathClaim[] claims = GetArray(); count = 0; head = null; tail = null; for (int i = 0; i < claims.Length; i++) { switch (claims[i].location) { case Citizen.Location.Home: if (CM.m_citizens.m_buffer[claims[i].citizenID].m_homeBuilding != 0) { Add(claims[i]); } break; case Citizen.Location.Visit: if (CM.m_citizens.m_buffer[claims[i].citizenID].m_visitBuilding != 0) { Add(claims[i]); } break; case Citizen.Location.Work: if (CM.m_citizens.m_buffer[claims[i].citizenID].m_workBuilding != 0) { Add(claims[i]); } break; default: DeathRegistry.RestClaim(claims[i]); break; } } }
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; } } }