/// <summary> /// Add temporary effect to the listOfOngoingEffects. Returns true if successful (eg. not a duplicate) /// </summary> /// <param name="ongoing"></param> /// <returns></returns> public bool AddOngoingEffect(EffectDataOngoing ongoing) { bool isNotDuplicate = true; if (ongoing != null) { //check to see if an identical ongoingID not already present if (listOfOngoingEffects.Count == 0) { listOfOngoingEffects.Add(ongoing); } else { //check list for dupes for (int i = 0; i < listOfOngoingEffects.Count; i++) { if (listOfOngoingEffects[i].ongoingID == ongoing.ongoingID) { isNotDuplicate = false; break; } } if (isNotDuplicate == true) { listOfOngoingEffects.Add(ongoing); //add to register & create message GameManager.i.dataScript.AddOngoingEffectToDict(ongoing, connID); } } } else { Debug.LogError("Invalid EffectDataOngoing (Null)"); } return(isNotDuplicate); }
/// <summary> /// checks listOfOngoingEffects for any matching ongoingID and deletes them /// NOTE: there are no checks for not finding the uniqueID or having no entries in list as ConnectionManager.cs loops through all connections looking for the right ones. /// </summary> /// <param name="uniqueID"></param> public void RemoveOngoingEffect(int uniqueID) { if (listOfOngoingEffects.Count > 0) { //reverse loop, deleting as you go for (int i = listOfOngoingEffects.Count - 1; i >= 0; i--) { EffectDataOngoing ongoing = listOfOngoingEffects[i]; if (ongoing.ongoingID == uniqueID) { //amount to reverse security level Debug.LogFormat("Connection, ID {0}, Ongoing Effect ID {1}, \"{2}\", REMOVED{3}", connID, ongoing.ongoingID, ongoing.description, "\n"); //remove from register & create message GameManager.i.dataScript.RemoveOngoingEffectFromDict(ongoing); //remove from list listOfOngoingEffects.RemoveAt(i); //reset material of connection. Note that you are simply redoing the same security level without the additional ongoing effect (which will be at a lower level) SetMaterial(SecurityLevel); } } } }