Example #1
0
    public virtual bool Scan()                                                                                //THIS IS THE METHOD THAT SCANS TO SEE IF ANOTHER EFFECT HAS A MATCHING REACTOR
    {
        List <Affecter> allLists = (targetBody.GetAffecterList().Concat(targetBody.GetTraitList())).ToList(); //COMBINES EFFECTLIST AND TRAITLIST

        for (int i = 0; i < allLists.Count; i++)                                                              //FOR EACH AFFECTER IN THE COMBINED LIST
        {
            Affecter affecter = allLists.ElementAt(i);                                                        //FOR EACH AFFECTER IN THE COMBINED LIST
            if (combinable && affecter.GetType() == GetType())                                                //CHECK WHETHER AFFECTERS SHOULD COMBINE
            {
                Combine(affecter);                                                                            //COMBINE AFFECTERS
                return(false);
            }
            else //IF THEY SHOULDN'T COMBINE
            {
                for (int j = 0; j < reactorList.Count; j++)   //FOR EACH REACTOR IN THE REACTOR LIST
                {
                    Reactor reactor = reactorList.ElementAt(j);                                //FOR EACH REACTOR IN THE REACTOR LIST
                    if (reactor.FindMatches(affecter) && (!interactorList.Contains(affecter))) //IF THE AFFECTER FROM THE COMBINED HAS A MATCHING REACTOR
                    {
                        interactorList.Add(affecter);                                          //ADD THAT AFFECTER TO THE INTERACTOR LIST
                        affecter.AddToInteractorList(this);
                    }
                }
            }
        }
        return(true);
    }
Example #2
0
 public virtual void Dewit()                                                                       //THIS IS WHAT THE AFFECTER WILL PERFORM EVERY TURN, IF ACTIVE
 {
     vitality += vRate;                                                                            //UPDATE VITALITY
     for (int i = 0; i < interactorList.Count; i++)                                                //FOR EACH INTERACTOR IN THE LIST
     {
         Affecter interactor = interactorList.ElementAt(i);                                        //FOR EACH INTERACTOR IN THE LIST
         if (!(interactor).IsPresent())                                                            //IF THE INTERACTOR ISN'T ALIVE
         {
             interactorList.Remove(interactor);                                                    //DELET THIS
             continue;                                                                             //IGNORE THE REST OF THE POTENTIAL INTERACTION WITH THIS INTERACTOR
         }
         if (layered && interactor.IsLayered())                                                    //IF BOTH AFFECTERS ACT AS LAYERS
         {
             if (Mathf.Abs(targetBody.GetLayerVal(interactor) - targetBody.GetLayerVal(this)) > 1) //IF THE INTERACTOR ISN'T ONE LAYER BENEATH OR ABOVE
             {
                 continue;                                                                         //CEASE THE INTERACTION
             }
         }
         for (int j = 0; j < reactorList.Count; j++)     //FOR EACH REACTOR IN THE REACTOR LIST
         {
             Reactor reactor = reactorList.ElementAt(j); //FOR EACH REACTOR IN THE REACTOR LIST
             if (reactor.vitality <= 0)                  //IF THE REACTOR IS DEAD
             {
                 if (!reactor.IsImmortal())              //LIKE... DEAD
                 {
                     reactor.Deact();                    //DELETE REACTOR
                     if (reactor.IsVital())              //IF THE REACTOR IS VITAL
                     {
                         present = false;                //DESTROY THE AFFECTER TO WHICH THE REACTOR IS ATTACHED
                         return;
                     }
                 }
                 else //IF THE REACTOR IS STILL ALIVE
                 {
                     reactor.FindMatches(interactor); //HANDLE ANY INTERACTIONS IT MIGHT HAVE WITH THE INTERACTOR
                 }
             }
         }
     }
 }