Skip to content

Commit

Permalink
Merge pull request #2474 from DFIronman/Raise-an-event-when-a-crime-i…
Browse files Browse the repository at this point in the history
…s-committed

Raise an event when a crime is committed
  • Loading branch information
Interkarma committed Dec 16, 2022
2 parents 9dbf581 + 255b5b5 commit e5b40df
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Assets/Scripts/Game/Entities/PlayerEntity.cs
Expand Up @@ -2346,6 +2346,22 @@ void SetCrimeCommitted(Crimes crime)
bool suppressCrime = racialOverride != null && racialOverride.SuppressCrime;

crimeCommitted = (!suppressCrime) ? crime : Crimes.None;

RaiseOnCrimeUpdateEvent(crimeCommitted);
}

// Allows modders to easily detect if a crime has been committed
// This will raise when the player's crime is set to None!
// Make sure to account for that when necessary.
public delegate void OnCrimeUpdateHandler(Crimes crime);
public event OnCrimeUpdateHandler OnCrimeUpdate;
protected void RaiseOnCrimeUpdateEvent(Crimes crime)
{
if (SaveLoadManager.Instance.LoadInProgress)
return;

if (OnCrimeUpdate != null)
OnCrimeUpdate(crime);
}

#endregion
Expand Down

0 comments on commit e5b40df

Please sign in to comment.