Skip to main content

SoftKitty.CustomData

CustomData

CustomData is used to store customizable data on an Entity, allowing developers to adapt the system to different project needs.

Supported data types include:

  • float
  • int
  • bool
  • string
  • IntList (List<int>)
  • IdIntList (List<KeyValuePair<int, int>>)
  • IdFloatList (List<KeyValuePair<int, float>>)

Each CustomData entry consists of a unique string key paired with a value.

You can configure the CustomData set in the EntityManagerObject: Project Settings → SoftKitty → Entity Manager

Once configured, all Entity will share the same CustomData structure.


Code Example

float

float _damageMulti = GameManager.GetPlayer().GetCustomFloat("DamageMulti");
GameManager.GetPlayer().SetCustomFloat("DamageMulti", 10f);

int

int _damageMulti = GameManager.GetPlayer().GetCustomInt("DamageMulti");
GameManager.GetPlayer().SetCustomInt("DamageMulti", 10);

string

string _lastWord = GameManager.GetPlayer().GetCustomString("LastWord");
GameManager.GetPlayer().SetCustomString("LastWord", "Hello!");

bool

bool _hasTeam = GameManager.GetPlayer().GetCustomBool("HasTeam");
GameManager.GetPlayer().SetCustomBool("HasTeam", true);

IntList

var _skills = GameManager.GetPlayer().GetCustomIntList("Skills");
foreach(var obj in _skills.list){
Debug.Log("Skill:" + obj.ToString());
}
_skills.Add(12);
_skills.Remove(12);
_skills.RemoveAt(0);
_skills.SetValueByIndex(2,10);
_skills.Clear();

IdIntList

var _items = GameManager.GetPlayer().GetCustomIdIntList("Items");
foreach(var obj in _items.list){
Debug.Log("Item id:" + obj.id.ToString() + " num:" + obj.value.ToString());
}
_items.Add(new IdInt(2,1));
_items.Remove(new IdInt(2,1));
_items.RemoveAt(0);
_items.SetValueByIndex(2,new IdInt(2,1));
_items.SetValueById(12,5);
int _num = _items.GetValueById(12);
int _num2 = _items.GetValueByIndex(2);
_items.Clear();

IdFloatList

var _items = GameManager.GetPlayer().GetCustomIdFloatList("Items");
foreach(var obj in _items.list){
Debug.Log("Item id:" + obj.id.ToString() + " durability:" + obj.value.ToString());
}
_items.Add(new IdFloat(2,100F));
_items.Remove(new IdFloat(2,100F));
_items.RemoveAt(0);
_items.SetValueByIndex(2,new IdFloat(2,100F));
_items.SetValueById(12,5F);
int _num = _items.GetValueById(12);
int _num2 = _items.GetValueByIndex(2);
_items.Clear();