Пример #1
0
        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(TickEngineSettings.netTickInterval);
                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 collision! Vitals cannot have more than one of each Vital Type in its list.");
                    }
                }
            }

            initialized = true;
        }
Пример #2
0
 public Vital(VitalDefinition vitalDef)
 {
     this.vitalDef = vitalDef;
 }