Exemple #1
0
 public static void OnChangeAuthority(IVitalsComponent ivc, bool isMine, bool asServer)
 {
     if (isMine)
     {
         if (!ownedVitalComponents.Contains(ivc))
         {
             ownedVitalComponents.Add(ivc);
             for (int i = 0; i < iOnChangeOwnedVitals.Count; ++i)
             {
                 iOnChangeOwnedVitals[i].OnChangeOwnedVitals(ivc, null);
             }
         }
     }
     else
     {
         if (ownedVitalComponents.Contains(ivc))
         {
             ownedVitalComponents.Remove(ivc);
             for (int i = 0; i < iOnChangeOwnedVitals.Count; ++i)
             {
                 iOnChangeOwnedVitals[i].OnChangeOwnedVitals(null, ivc);
             }
         }
     }
 }
Exemple #2
0
 private static IVitalsComponent FindIVitalComponentOnGameObj(GameObject go)
 {
     /// May be null because vitalsSource is a gameoject, need to turn that into a vitalcomp
     if (go)
     {
         IVitalsComponent ivitalcomp = go.GetComponentInParent <IVitalsComponent>();
         if (ivitalcomp == null)
         {
             ivitalcomp = go.GetComponentInChildren <IVitalsComponent>();
         }
         return(ivitalcomp);
     }
     return(null);
 }
 public override void OnChangeOwnedVitals(IVitalsComponent added, IVitalsComponent removed)
 {
     if (added != null)
     {
         vitalsSource = added as Component;
         Vitals       = added.Vitals;
     }
     else if (ReferenceEquals(removed.Vitals, vitals))
     {
         var lastitem = OwnedIVitals.LastItem;
         if (!ReferenceEquals(lastitem, null))
         {
             Vitals = lastitem.Vitals;
         }
     }
 }
        private void OnTrigger(Component otherCollider, ContactType triggerOn)
        {
            if (!IsMine)
            {
                return;
            }

            if ((this.triggerOn & triggerOn) == 0)
            {
                return;
            }

            IVitalsComponent ivc = otherCollider.GetComponentInParent <IVitalsComponent>();

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

            queueContactEvent.Enqueue(new ContactEvent(null, ivc, null, otherCollider, triggerOn));
        }
Exemple #5
0
 public abstract void OnChangeOwnedVitals(IVitalsComponent added, IVitalsComponent removed);