using System.Collections.Generic; using System.Linq; using EscapeRoomEngine.Engine.Runtime.Modules; using EscapeRoomEngine.Engine.Runtime.Utilities; namespace EscapeRoomEngine.Engine.Runtime.Requirements { public abstract class OrientationRequirement : Requirement { protected abstract override IEnumerable GenerateCandidates(Module module, Space space); public static bool TryOrienting(Module module, Space space) { if (module.description.orientationRequirements.Count == 0) { // don't evaluate requirements if there are none return true; } var orientationCandidates = Candidates( Module.EveryOrientation, module.description.orientationRequirements, module, space); Logger.Log($"orientation candidates: {string.Join(",", orientationCandidates.ToList().ConvertAll(c => c.ToString()))}", LogType.RequirementResolution); if (orientationCandidates.Count > 0) { module.orientation = orientationCandidates.RandomElement(); return true; } // ReSharper disable once RedundantIfElseBlock else { Logger.Log("Could not find suitable orientation for module", LogType.ModulePlacement); return false; } } } }