//continually dequeues results from outContainer //and dequeues containers out from resultContainers //until arrived at a point where it must wait private static void DelegateResultContainers() { if (!outContainer.IsFinished()) { while (true) { //push in as many tasks as possible DelegateOutContainer(); if (!outContainer.IsFinished()) { //if, after dequeueing as much as possible, there are still elements left, wait until next loop to try again break; } //in the end, due to all elements potentially being zero-frame results, //outContainer may be empty with the screen still ReadyForResults, and require another enqueue if (resultContainers.Count > 0) { outContainer = resultContainers.Dequeue(); } //after re-enqueue, the outContainer may or may not be empty now //if so, it means the choice queue has exhausted all and must wait until the next call //if not, we can try again to see if the next outContainer also contains only zero-frame results if (outContainer.IsFinished()) { break; } } } }
public static void BeginRunModeConcurrent(int id) { //do not end concurrent if currently in run mode //and run mode is ordered if (!(currentContainer is Results.MotionResultContainer)) { EndConcurrent(); currentContainer = new Results.MotionResultContainer(id); } }
public static void EndConcurrent() { if (currentContainer != null) { if (!currentContainer.Empty) { resultContainers.Enqueue(currentContainer); } currentContainer = null; } }
public static void Init() { miscResults = new List <Logic.Results.IResult>(); resultContainers = new Queue <Results.IResultContainer>(); outContainer = new Results.ResultContainer(); Map = new DisplayMap(); Players = new PlayerSprite[Gameplay.Processor.MAX_TEAM_SLOTS]; for (int i = 0; i < Gameplay.Processor.MAX_TEAM_SLOTS; i++) { Players[i] = new PlayerSprite(); } Npcs = new NpcSprite[BasicMap.MAX_NPC_SLOTS]; for (int i = 0; i < BasicMap.MAX_NPC_SLOTS; i++) { Npcs[i] = new NpcSprite(); } Items = new ItemAnim[BasicMap.MAX_ITEM_SLOTS]; for (int i = 0; i < BasicMap.MAX_ITEM_SLOTS; i++) { Items[i] = new ItemAnim(); } Effects = new Dictionary <EffectPriority, List <ISprite> >(); for (int n = (int)EffectPriority.Ground; n <= (int)EffectPriority.Overlay; n++) { Effects.Add((EffectPriority)n, new List <ISprite>()); } Emitters = new List <IEmitter>(); CurrentCharMoves = new int[Gameplay.Processor.MAX_MOVE_SLOTS]; for (int i = 0; i < Gameplay.Processor.MAX_MOVE_SLOTS; i++) { CurrentCharMoves[i] = -1; } Rand = new Random(); ShowDebug = true; //ShowGrid = true; ShowCoords = true; ShowSprites = true; Zoom = GameZoom.x1; //DebugSpeed = GameSpeed.Pause; }
public static void ProcessTaskQueue(bool askUp) { //unqueue all loose tasks DelegateResultContainers(); //if no tasks are queued, look for more if (outContainer.IsFinished()) { //if no choices are queued if (resultContainers.Count == 0 && askUp) { Gameplay.Processor.Process(); } //then do actual choice queue processing (if choices are now queued) if (resultContainers.Count > 0) { outContainer = resultContainers.Dequeue(); } } DelegateResultContainers(); }
//continually dequeues results from outContainer //and dequeues containers out from resultContainers //until arrived at a point where it must wait private static void DelegateResultContainers() { if (!outContainer.IsFinished()) { while (true) { //push in as many tasks as possible DelegateOutContainer(); if (!outContainer.IsFinished()) { //if, after dequeueing as much as possible, there are still elements left, wait until next loop to try again break; } //in the end, due to all elements potentially being zero-frame results, //outContainer may be empty with the screen still ReadyForResults, and require another enqueue if (resultContainers.Count > 0) outContainer = resultContainers.Dequeue(); //after re-enqueue, the outContainer may or may not be empty now //if so, it means the choice queue has exhausted all and must wait until the next call //if not, we can try again to see if the next outContainer also contains only zero-frame results if (outContainer.IsFinished()) break; } } }
public static void ProcessTaskQueue(bool askUp) { //unqueue all loose tasks DelegateResultContainers(); //if no tasks are queued, look for more if (outContainer.IsFinished()) { //if no choices are queued if (resultContainers.Count == 0 && askUp) Logic.Gameplay.Processor.Process(); //then do actual choice queue processing (if choices are now queued) if (resultContainers.Count > 0) outContainer = resultContainers.Dequeue(); } DelegateResultContainers(); }
public static void Init() { miscResults = new List<Logic.Results.IResult>(); resultContainers = new Queue<Results.IResultContainer>(); outContainer = new Results.ResultContainer(); Map = new DisplayMap(); Players = new PlayerSprite[Gameplay.Processor.MAX_TEAM_SLOTS]; for (int i = 0; i < Gameplay.Processor.MAX_TEAM_SLOTS; i++) { Players[i] = new PlayerSprite(); } Npcs = new NpcSprite[BasicMap.MAX_NPC_SLOTS]; for (int i = 0; i < BasicMap.MAX_NPC_SLOTS; i++) { Npcs[i] = new NpcSprite(); } Items = new ItemAnim[BasicMap.MAX_ITEM_SLOTS]; for (int i = 0; i < BasicMap.MAX_ITEM_SLOTS; i++) { Items[i] = new ItemAnim(); } Effects = new Dictionary<EffectPriority, List<ISprite>>(); for (int n = (int)EffectPriority.Ground; n <= (int)EffectPriority.Overlay; n++) { Effects.Add((EffectPriority)n, new List<ISprite>()); } Emitters = new List<IEmitter>(); CurrentCharMoves = new int[Gameplay.Processor.MAX_MOVE_SLOTS]; for (int i = 0; i < Gameplay.Processor.MAX_MOVE_SLOTS; i++) { CurrentCharMoves[i] = -1; } Rand = new Random(); ShowDebug = true; //ShowGrid = true; ShowCoords = true; ShowSprites = true; Zoom = GameZoom.x1; //DebugSpeed = GameSpeed.Pause; }
public static void BeginConcurrent() { EndConcurrent(); currentContainer = new Results.ResultContainer(); }