コード例 #1
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);
        }
コード例 #2
0
        public bool TryTrigger(IOnTrigger trigger, ref ContactEvent contactEvent, int compatibleMounts)
        {
            if (!useHitGroups || validHitGroups != 0)
            {
                var hga         = contactEvent.contacted.GetComponent <HitGroupAssign>();
                int triggermask = hga ? hga.Mask : 0;
                if ((validHitGroups.Mask & triggermask) == 0)
                {
#if UNITY_EDITOR
                    Debug.Log(name + " SyncVitals.TryTrigger() HitGroup Mismatch. Cannot pick up '" + hga.transform.root.name + "' because its has a non-matching HitGroupAssign.");
#endif
                    return(false);
                }
            }

            ///TODO: Make this into an interface rather than this component type
            var otherVitalNameType = (trigger as IVitalsAffector);

            Vital vital = vitals.GetVital(otherVitalNameType.VitalNameType);
            if (vital == null)
            {
                return(false);
            }

            /// If both are set to 0 (Root) then consider that a match, otherwise zero for one but not the other is a mismatch (for now)
            if ((compatibleMounts == defaultMountingMask) || (compatibleMounts & defaultMountingMask) != 0)
            {
                contactEvent = new ContactEvent(contactEvent)
                {
                    triggeringObj = vital
                };
                return(true);
            }
            else
            {
                return(false);
            }
        }