Ejemplo n.º 1
0
        //public void SetTickInterval(float tickInterval)
        //{
        //	for (int i = 0; i < vitalCount; ++i)
        //		vitalDefs[i].SetTickInterval(tickInterval);
        //}

        /// <summary>
        /// Do not use this in a hotpath please. Cache the Vital this returns.
        /// </summary>
        public Vital GetVital(VitalNameType vitalNameType)
        {
            if (!initialized)
            {
                Initialize();
            }

            Vital vital;

            vitalLookup.TryGetValue(vitalNameType.hash, out vital);
            return(vital);
        }
Ejemplo n.º 2
0
        //public VitalDefinition()
        //{
        //	_fullValue = 100;
        //	_maxValue = 125;
        //	startValue = 100;
        //	absorption = 1;
        //	regenDelay = 1;
        //	regenRate = 1;
        //	decayDelay = 1;
        //	decayRate = 1;
        //	vitalName = new VitalNameType(VitalType.None);
        //}

        public VitalDefinition(float fullValue, uint maxValue, float startValue, float absorbtion, float regenDelay, float regenRate, float decayDelay, float decayRate, string name)
        {
            this._fullValue = fullValue;
            this._maxValue  = maxValue;
            this.startValue = startValue;
            this.absorption = absorbtion;
            this.regenDelay = regenDelay;
            this.regenRate  = regenRate;
            this.decayDelay = decayDelay;
            this.decayRate  = decayRate;
            vitalName       = new VitalNameType(name);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Check if the ITriggeringComponent is an IVitalsComponent, and if so that it has the vital that matches the trigger.
        /// </summary>
        /// <param name="frameInt"></param>
        /// <param name="contactEvent"></param>
        /// <returns>Returns true if this triggerer is a IVitalsComponent, and contains the indicated vital type.</returns>
        public static Vital GetTriggeringVital(this ContactEvent contactEvent, VitalNameType vitalNameType)
        {
            var ivc = (contactEvent.itc as IVitalsComponent);

            if (ReferenceEquals(ivc, null))
            {
                return(null);
            }

            Vitals vitals = ivc.Vitals;
            Vital  vital  = vitals.GetVital(vitalNameType);

            return(vital);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Do not use this in a hotpath please. Cache the value this returns.
        /// </summary>
        public int GetIVitalIndex(VitalNameType vitalNameType)
        {
            if (vitalDefs == null)
            {
                return(-1);
            }

            /// TODO: There should be a fast lookup array for targetVital
            int cnt = vitalDefs.Count;

            for (int i = 0; i < cnt; ++i)
            {
                if (vitalDefs[i].VitalName.hash == vitalNameType.hash)
                {
                    return(i);
                }
            }

            return(-1);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns any unused portion of 'change'.
        /// </summary>
        public float ApplyChange(float change, VitalNameType vitalNameType, bool overloading)
        {
            var vital = GetVital(vitalNameType);

            return((vital == null) ? change : vital.ApplyChange(change, overloading));
        }