public void Initialize() { if (initialized) { return; } /// Create Vital for each VitalDefinition at runtime vitalCount = vitalDefs.Count; vitalArray = new Vital[vitalCount]; for (int i = 0; i < vitalCount; ++i) { VitalDefinition vdef = vitalDefs[i]; Vital vital = new Vital(vdef); vitalArray[i] = vital; vital.Initialize(Time.fixedDeltaTime * SimpleSyncSettings.SendEveryXTick); vital.AddIOnVitalChange(this); // add all of the vital types to the lookup. Customs use hash, enumerated are added both as hash and by their index int hash = vdef.VitalName.hash; if (vdef.VitalName.type != VitalType.None) { if (!vitalLookup.ContainsKey(hash)) { vitalLookup.Add(hash, vital); } else { Debug.LogWarning("VitalNameType hash collison! Vitals cannot have more than one of each Vital Type in its list."); } } } initialized = true; }
public Vital(VitalDefinition vitalDef) { this.vitalDef = vitalDef; }