// Make sure the correct transform is passed in public void FlipBits(FoundFlags _self, SmallWorldType _type) { //Debug.Log(_self.ToString() + " | " + _type.ToString()); switch (_type) { case SmallWorldType.NEO: if (!UserFlagExtensions.HasFlagQuick(LocatedBits[1], _self)) // Make sure it's not already in there { LocatedBits[1] += (int)_self; } //Debug.Log(LocatedBits[1].ToString()); break; case SmallWorldType.MAB: if (!UserFlagExtensions.HasFlagQuick(LocatedBits[2], _self)) // Make sure it's not already in there { LocatedBits[2] += (int)_self; } //Debug.Log(LocatedBits[2].ToString()); break; case SmallWorldType.KB: if (!UserFlagExtensions.HasFlagQuick(LocatedBits[3], _self)) // Make sure it's not already in there { LocatedBits[3] += (int)_self; } //Debug.Log(LocatedBits[3].ToString()); break; case SmallWorldType.Planet: if (!UserFlagExtensions.HasFlagQuick(LocatedBits[0], _self)) // Make sure it's not already in there { LocatedBits[0] += (int)_self; } //Debug.Log(LocatedBits[0].ToString()); break; default: Debug.Log("BAD WORLD PASSED INTO FLIP FUNCTION!"); break; } }
public static bool HasFlagQuick(this FoundFlags a, FoundFlags b) { return((a & b) == b); }
public static bool Contains(this FoundFlags keys, FoundFlags flag) { return((keys & flag) != 0); }
// Dependency checker private bool PathChecker(FoundFlags flag) { bool checkResult = false; switch (flag) { case FoundFlags.isToolsFound: string path = tbStarterPackagePath.Text.TrimEnd('/'); DirectoryInfo di = new DirectoryInfo(path); if (di.Exists) { bool isToolsFolder = false; foreach (DirectoryInfo subDir in di.GetDirectories()) { if (subDir.Name == "tools") { isToolsFolder = true; bool isPlayGame = false; bool isShowGame = false; foreach (FileInfo fi in subDir.GetFiles()) { if (fi.Name == "PlayGame.jar") isPlayGame = true; else if (fi.Name == "ShowGame.jar") isShowGame = true; } if ((isPlayGame) && (isShowGame)) { checkResult = true; } else { if (!isPlayGame) errorString += "Can't find PlayGame.jar in subfolder 'tools' in starter package folder.\n"; if (!isShowGame) errorString += "Can't find ShowGame.jar in subfolder 'tools' in starter package folder.\n"; } break; } } if (!isToolsFolder) errorString += "Can't find 'tools' folder in starter package folder.\n"; } else { errorString += "Can't find starter package folder.\n"; } break; case FoundFlags.isMapsFound: path = tbStarterPackagePath.Text.TrimEnd('/'); di = new DirectoryInfo(path); if (di.Exists) { bool isMapsFolder = false; foreach (DirectoryInfo subDir in di.GetDirectories()) { if (subDir.Name == "maps") { isMapsFolder = true; if (subDir.GetFiles().Length > 0) { checkResult = true; } else { errorString += "'maps' subfolder is empty in starter package folder.\n"; } break; } } if (!isMapsFolder) errorString += "Can't find 'maps' folder in starter package folder.\n"; } else { errorString += "Can't find starter package folder.\n"; } break; case FoundFlags.isExampleBotsFound: path = tbStarterPackagePath.Text.TrimEnd('/'); di = new DirectoryInfo(path); if (di.Exists) { bool isExampleBots = false; foreach (DirectoryInfo subDir in di.GetDirectories()) { if (subDir.Name == "example_bots") { isExampleBots = true; if (subDir.GetFiles().Length > 0) { checkResult = true; } else { errorString += "'example_bots' subfolder is empty in starter package folder.\n"; } break; } } if (!isExampleBots) errorString += "Can't find 'example_bots' folder in starter package folder.\n"; } else { errorString += "Can't find starter package folder.\n"; } break; case FoundFlags.isMyBotsFound: path = tbMyBotsPath.Text.TrimEnd('/'); di = new DirectoryInfo(path); if (di.Exists) { if (di.GetFiles().Length > 0) { checkResult = true; } else { errorString += "Folder with your bots is empty in starter package folder.\n"; } } else { errorString += "Can't find folder with your bots.\n"; } break; case FoundFlags.allFlags: default: checkResult = ((PathChecker(FoundFlags.isToolsFound)) && (PathChecker(FoundFlags.isMapsFound)) && (PathChecker(FoundFlags.isExampleBotsFound)) && (PathChecker(FoundFlags.isMyBotsFound))); break; } return checkResult; }