{"id":2332,"date":"2025-11-16T12:15:34","date_gmt":"2025-11-16T12:15:34","guid":{"rendered":"https:\/\/golemitegames.com\/?post_type=docs&#038;p=2332"},"modified":"2025-11-21T08:27:13","modified_gmt":"2025-11-21T08:27:13","password":"","slug":"stat","status":"publish","type":"docs","link":"https:\/\/golemitegames.com\/index.php\/docs\/stat\/","title":{"rendered":"Stat"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" style=\"font-size:22px;text-transform:capitalize\">Introduction<\/h2>\n\n\n\n<p>Stat is a utility class used on a few of the other components in the system. It generally represents things like Hp and Limits.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px;text-transform:capitalize\">Setting up<\/h2>\n\n\n\n<p>Stat does not inherit from MonoBehaviour therefor there is no setup required. <br>However if you wanted to use this utility class for yourself, simply add a Stat field to your scripts. You will then see something like this.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"745\" height=\"94\" src=\"https:\/\/golemitegames.com\/wp-content\/uploads\/2025\/11\/image-28.png\" alt=\"\" class=\"wp-image-2334\" style=\"width:400px\" srcset=\"https:\/\/golemitegames.com\/wp-content\/uploads\/2025\/11\/image-28.png 745w, https:\/\/golemitegames.com\/wp-content\/uploads\/2025\/11\/image-28-300x38.png 300w\" sizes=\"(max-width: 745px) 100vw, 745px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px;text-transform:capitalize\">Settings<\/h2>\n\n\n\n<p><strong>Current<\/strong><br>The Current value of the Stat, this is the value that is most often changed and cannot go above Max or below 0. Generally this is started at 0 for limits, or set to the Max value for things like Hp or Mp. You can also drag the progress bar to change the Current value.<br><br><strong>Max<\/strong><br>The Maximum value of the Stat. Cannot be less than Current.<br><br><strong>Infinite<\/strong><br>If set to Infinite, any changes to Current or Max are ignored. However the Events will still trigger. <br><br><strong>StatBar<\/strong><br><a href=\"https:\/\/golemitegames.com\/index.php\/docs\/stat-bar\/\" title=\"Stat Bar\">StatBar<\/a> is another component that displays the Stat in a visual bar or Dial. You can assign one here in the top left of the Stat to automatically update the <a href=\"https:\/\/golemitegames.com\/index.php\/docs\/stat-bar\/\" title=\"Stat Bar\">StatBar<\/a> when any changes are made.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px;text-transform:capitalize\">Scripting<\/h2>\n\n\n\n<p>There are a few public methods available for Stat below<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\" data-show-lang=\"0\"><code>\/\/Action\n\n\/\/Triggers when any changes are made to the Stat\npublic Action&lt;float, float, float&gt; OnValueModified;\n\n\/\/Example \npublic void Start()\n{\n    stat.OnValueModified += (current, max, previous) =&gt; DoSomething(current, max, previous); \n}\n\n\/\/\/ &lt;summary&gt;\n\/\/\/ Initialise the Stat bar with a custom current and max value, seperate to what is set in the editor - useful for loading\n\/\/\/ &lt;\/summary&gt;\n\/\/\/ &lt;param name=&quot;currentValue&quot;&gt;The current value to set, will clamp between 0 and the max value if outside those values&lt;\/param&gt;\n\/\/\/ &lt;param name=&quot;maxValue&quot;&gt;The maximum value to set, will not go lower than the current value&lt;\/param&gt;\npublic void InitStat(float currentValue, float maxValue)\n\n\/\/\/ &lt;summary&gt;\n\/\/\/ Initialise the Stat bar with randomized values for current and max,\n\/\/\/ ensuring currentValue is clamped between 0 and maxValue.\n\/\/\/ &lt;\/summary&gt;\n\/\/\/ &lt;param name=&quot;currentMin&quot;&gt;The minimum possible current value before clamping&lt;\/param&gt;\n\/\/\/ &lt;param name=&quot;currentMax&quot;&gt;The maximum possible current value before clamping&lt;\/param&gt;\n\/\/\/ &lt;param name=&quot;maxValueMin&quot;&gt;The minimum possible max value&lt;\/param&gt;\n\/\/\/ &lt;param name=&quot;maxValueMax&quot;&gt;The maximum possible max value&lt;\/param&gt;\n\/\/\/ &lt;param name=&quot;matchCurrentToMax&quot;&gt;If true, currentValue will equal the randomized maxValue&lt;\/param&gt;\npublic void InitStatRandom(float currentMin, float currentMax, float maxValueMin, float maxValueMax, bool matchCurrentToMax = true)\n\n\/\/\/ &lt;summary&gt;\n\/\/\/ Initialises the StatBar UI if assigned\n\/\/\/ &lt;\/summary&gt;\npublic void RefreshStatBar()\n\n\/\/\/ &lt;summary&gt;\n\/\/\/ Modify the current value using positive or negative values\n\/\/\/ &lt;\/summary&gt;\n\/\/\/ &lt;param name=&quot;amount&quot;&gt;The amount to modify by&lt;\/param&gt;\npublic void Modify(float amount)\n\n\/\/\/ &lt;summary&gt;\n\/\/\/ Modify the current value absolutely. The current value will equal the amount\n\/\/\/ &lt;\/summary&gt;\n\/\/\/ &lt;param name=&quot;amount&quot;&gt;The amount to make the current value&lt;\/param&gt;\npublic void ModifyAbsolute(float amount)\n\n\/\/\/ &lt;summary&gt;\n\/\/\/ Modify the max value absolutely. The max value will equal the amount\n\/\/\/ &lt;\/summary&gt;\n\/\/\/ &lt;param name=&quot;amount&quot;&gt;The amount to make the max value&lt;\/param&gt;\npublic void ModifyMaxAbsolute(float amount)<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Stat is a utility class used on a few of the other components in the system. It generally represents things like Hp and Limits. Setting up Stat does not inherit from MonoBehaviour therefor there is no setup required. However if you wanted to use this utility class for yourself, simply add a Stat field [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"doc_category":[46],"doc_tag":[],"class_list":["post-2332","docs","type-docs","status-publish","hentry","doc_category-resource-and-production"],"acf":[],"aioseo_notices":[],"year_month":"2026-04","word_count":562,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"rickitz5h","author_nicename":"rickitz5h","author_url":"https:\/\/golemitegames.com\/index.php\/author\/rickitz5h\/"},"doc_category_info":[{"term_name":"Resource And Production","term_url":"https:\/\/golemitegames.com\/index.php\/docs-category\/resource-and-production\/"}],"doc_tag_info":[],"_links":{"self":[{"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs\/2332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/comments?post=2332"}],"version-history":[{"count":6,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs\/2332\/revisions"}],"predecessor-version":[{"id":2542,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs\/2332\/revisions\/2542"}],"wp:attachment":[{"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/media?parent=2332"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/doc_category?post=2332"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/doc_tag?post=2332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}