public void AccumulateCelebrity(SimDescription sim, int value) { if (sim == null) { return; } if (sim.CelebrityManager == null) { return; } if (!AllowCelebrity(this, sim)) { return; } if (value > 0) { if (sim.CelebrityLevel >= CelebrityManager.HighestLevel) { //if (sim.CelebrityManager.Points + value > sim.CelebrityManager.GetGoalPointsForCurrentLevel()) //{ IncStat("Highest Celebrity Pre-Cutoff"); return; //} } int residents = Sims.GetResidentCount(CASAgeGenderFlags.Human); if (residents > 0) { uint nextLevel = sim.CelebrityLevel + 1; int celebRatio = (AddScoring("Celeb Count " + nextLevel, Sims.GetCelebrityCount(nextLevel)) * 100) / residents; if (AddScoring("Celeb Ratio " + nextLevel, celebRatio) > mCelebrityOptions[nextLevel - 1].Value) { IncStat("Celebrity Ratio Fail: " + nextLevel); return; } } AddScoring("Celebrity", value); try { sim.CelebrityManager.AddPoints((uint)value); } catch (Exception e) { Common.DebugException(sim, e); } if (sim.CelebrityLevel > CelebrityManager.HighestLevel) { sim.CelebrityManager.mLevel = CelebrityManager.HighestLevel; IncStat("Highest Celebrity Post-Cutoff"); } } else if (value != 0) { value = -value; if (sim.CelebrityManager.mPoints < value) { value -= (int)sim.CelebrityManager.mPoints; if (sim.CelebrityManager.Level > 0) { AddScoring("Celebrity", -value); IncStat("Celebrity Level Dropped"); sim.CelebrityManager.mLevel--; sim.CelebrityManager.mPoints = sim.CelebrityManager.GetGoalPointsForCurrentLevel() - (uint)value; if (sim.CelebrityManager.OwnerSim == null) { // Workaround for error in CelebrityManager:RemoveFreeStuffAlarm if (sim.CelebrityManager.mFreeStuffAlarmHandle != AlarmHandle.kInvalidHandle) { AlarmManager.Global.RemoveAlarm(sim.CelebrityManager.mFreeStuffAlarmHandle); sim.CelebrityManager.mFreeStuffAlarmHandle = AlarmHandle.kInvalidHandle; } } sim.CelebrityManager.OnLevelModified(sim.CelebrityManager.mLevel + 1, false); } else { sim.CelebrityManager.mPoints = 0; } } else { sim.CelebrityManager.mPoints -= (uint)value; AddScoring("Celebrity", -value); } } }