private static void ApplyStops(StopProtectLink[] links) { // Mark as Stopped any Skill that is the target of other Stop foreach (StopProtectLink link in links) { if (link.inspected) { continue; } // Go to the head of the queue int i = 0; StopProtectLink head = link; bool infiniteLoop = false; while (head.Prev != null) { head = head.Prev; if (i++ >= 2) // 4 stops loop was already checked with the initial IF, so the maximum loop is 3 stops { infiniteLoop = true; break; } } if (infiniteLoop) { for (i = 0; i < 3; i++) // 4 stops loop was already checked with the initial IF, so the maximum loop is 3 stops { head.Status = ActivationStatus.Stopped; head = head.Next; } } else { while (!(head == null || head.inspected)) { head.inspected = true; if (!head.Status.HasFlag(ActivationStatus.Stopped)) { if (head.Action.HasFlag(ActivationCases.Stop)) { head.Next.Status = ActivationStatus.Stopped; } } head = head.Next; } } } }
private static StopProtectLink[] GenerateInitialChainLinks(ActivationStatus[] initialActivationStatus, Skill leftAbility, Skill rightAbility, Skill leftBonus, Skill rightBonus) { StopProtectLink[] Links = new StopProtectLink[4]; for (int i = 0; i < 4; i++) { Links[i] = new StopProtectLink(); } Links[(int)SkillIndex.LA].isLeft = true; Links[(int)SkillIndex.LB].isLeft = true; // Store previous status for (int i = 0; i < 4; i++) { Links[i].Status = initialActivationStatus[i]; } // Store actions if (Links[(int)SkillIndex.LA].Status == ActivationStatus.Normal) { Links[(int)SkillIndex.LA].Action = DecodeActivationCases(leftAbility); } if (Links[(int)SkillIndex.RA].Status == ActivationStatus.Normal) { Links[(int)SkillIndex.RA].Action = DecodeActivationCases(rightAbility); } if (Links[(int)SkillIndex.LB].Status == ActivationStatus.Normal) { Links[(int)SkillIndex.LB].Action = DecodeActivationCases(leftBonus); } if (Links[(int)SkillIndex.RB].Status == ActivationStatus.Normal) { Links[(int)SkillIndex.RB].Action = DecodeActivationCases(rightBonus); } return(Links); }