Property Code

v4.0
The Property Code feature will export a script, Properties.cs, which contains an easy-to-reference set of properties leading to the uid and scriptable object for Game Module "Object" objects. (Stat, Condition, ItemObject etc)
You can access the Property Code window via Windows/Game Modules/Property Code, or from the links on each of the edit windows for Item Objects, Item Attributes, Conditions, and Stats.
if "Yes, auto export" is toggled on, the properties.cs script will be automatically updated as you create and manage your Game Module objects. However, you can manually update the script by simply clicking the "Export Now" button.
Exporting means overwriting the existing script. Best practice is to not modify the Properties.cs script, to avoid any issues.
Each time you create a new Item Object, Item Attribute, Condition, or Stat, or if you change their name, "type", or uid (changing the uid is not advised), you will need to re-export the Properties.cs script if auto export is not true.
If you're using it in your project, and names or types change, you will need to update code where you used the old name.

Using the code

public class Properties
{
public class ItemObjects
{
public static ArmorObjects Armor = new ArmorObjects();
public class ArmorObjects
{
public string CuriassUid => "bed1f4ec-a21b-45fe-909e-05c7ddff1b3a";
public ItemObject Curiass => itemsRepository.GetItemObjectByUid(CuriassUid);
public string LeatherVestUid => "8063e757-b5c0-4450-8a43-9b36cebde478";
public ItemObject LeatherVest => itemsRepository.GetItemObjectByUid(LeatherVestUid);
}
public static ShieldObjects Shield = new ShieldObjects();
public class ShieldObjects
{
public string SmallShieldUid => "f9abc679-9250-4d25-a391-ea6e3e94e703";
public ItemObject SmallShield => itemsRepository.GetItemObjectByUid(SmallShieldUid);
}
// ... and so on ...
This is an example of how the script will look when exported. (It may not be formatted like this right away. Try deleting then adding the last "}" in the script to prompt Rider or your application to format it correctly). There are classes for ItemObjects, ItemAttributes, Conditions, and Stats. Each "type" has a static class, named the same as the type. Each object has a "Uid" variant which returns the string uid, and a variant of it's own name which returns the Scriptable Object associated with that object.
The "Repository" prefabs are required for this to work. Be sure to include those prefabs in your scene.
As a reminder, the Scriptable Objects should not be edited at runtime. Use the "Game" version of each module to manage runtime data.
The Properties Code makes it easier to stay in the zone when scripting your project. Here's an example of two ways of getting a Stat from the GameStatsList script. The second example uses the Properties Code.
// This works perfectly fine. Paste the UID of the stat, and no need to worry
// about name changes.
public float RangeDistance()
{
if (!stats.TryGet("1737f740-07a8-4580-9cd4-e789a21b3006", out GameStat found))
return 0f;
return found.FinalStat();
}
// This also works perfectly fine. No need to look up the stat and click the
// "copy" button by the uid. But if the name changes, this will need to be
// updated.
public float RangeDistance()
{
if (!stats.TryGet(Properties.Stats.HiddenStat.RangeDistanceUid, out GameStat found))
return 0f;
return found.FinalStat();
}
// More examples...
float Accuracy => stats.Get(Properties.Stats.BaseStat.AccuracyUid).FinalStat(); // Accuracy stat
private float GetRangeDamageMax()
{
return FinalStat(Properties.Stats.Stat.ShootUid)
* FinalStat(Properties.Stats.Stat.RangeDamageUid)
+ FinalStat(Properties.Stats.Stat.RangeBonusUid);
}