Skip to content

Commit

Permalink
Adding OnUpdatedTotals callback to StatModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Cory Leach committed Jun 12, 2023
1 parent 08b244d commit 61b7df6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
</p>
<h1 align="center">Gameframe.StatSheet 👋</h1>
<!-- BADGE-START ->
<img align="center" src="https://raw.githubusercontent.com/coryleach/UnityPackages/master/Documentation/GameframeFace.gif" />
</p>
<h1 align="center">Gameframe.StatSheet 👋</h1>
<!-- BADGE-START -<!-- BADGE-END -->

Statsheet system for Role Playing Game style character stats
Expand All @@ -42,15 +47,15 @@ Statsheet system for Role Playing Game style character stats
#### Using UnityPackageManager (for Unity 2019.3 or later)
Open the package manager window (menu: Window > Package Manager)<br/>
Select "Add package from git URL...", fill in the pop-up with the following link:<br/>
https://github.com/coryleach/UnityStatSheet.git#0.2.5<br/>
https://github.com/coryleach/UnityStatSheet.git#0.2.6<br/>

#### Using UnityPackageManager (for Unity 2019.1 or later)

Find the manifest.json file in the Packages folder of your project and edit it to look like this:
```js
{
"dependencies": {
"com.gameframe.statsheet": "https://github.com/coryleach/UnityStatSheet.git#0.2.5",
"com.gameframe.statsheet": "https://github.com/coryleach/UnityStatSheet.git#0.2.6",
...
},
}
Expand Down
2 changes: 2 additions & 0 deletions Runtime/StatModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private set
public delegate void StatModelDelegate();

public event StatModelDelegate OnBecameDirty;
public event StatModelDelegate OnTotalsUpdated;

protected ListStatSet<TKey> _statTotals = new ListStatSet<TKey>();
public IStatSet<TKey> StatTotals => _statTotals;
Expand Down Expand Up @@ -119,6 +120,7 @@ public virtual void UpdateTotals(bool checkDirty = false)
}

IsDirty = false;
OnTotalsUpdated?.Invoke();
}

#region IReadonlyStatSet Implementation
Expand Down
19 changes: 18 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
{"githubUrl":"","name":"com.gameframe.statsheet","displayName":"Gameframe.StatSheet","repositoryName":"UnityStatSheet","version":"0.2.5","description":"Statsheet system for Role Playing Game style character stats","type":"library","keywords":[],"author":{"name":"Cory Leach","email":"cory.leach@gmail.com","url":"https://github.com/coryleach","twitter":"coryleach","github":"coryleach","kofi":""}}
{
"githubUrl": "",
"name": "com.gameframe.statsheet",
"displayName": "Gameframe.StatSheet",
"repositoryName": "UnityStatSheet",
"version": "0.2.6",
"description": "Statsheet system for Role Playing Game style character stats",
"type": "library",
"keywords": [],
"author": {
"name": "Cory Leach",
"email": "cory.leach@gmail.com",
"url": "https://github.com/coryleach",
"twitter": "coryleach",
"github": "coryleach",
"kofi": ""
}
}

0 comments on commit 61b7df6

Please sign in to comment.