示例#1
0
 public void Add(Event e)
 {
     if(e.TimeToExecute() == turn){ //0-time action
         list.AddFirst(e); //this means that creating 0-delay events can put them in the wrong order. this hasn't been a problem yet.
     }
     else{
         if(list.First == null){
             list.AddFirst(e);
         }
         else{
             if(e >= list.Last.Value){
                 list.AddLast(e);
             }
             else{
                 if(e < list.First.Value){
                     list.AddFirst(e);
                 }
                 else{ //it's going between two events
                     LinkedListNode<Event> current = list.Last;
                     while(true){
                         if(e >= current.Previous.Value){
                             list.AddAfter(current.Previous,e);
                             return;
                         }
                         else{
                             current = current.Previous;
                         }
                     }
                 }
             }
         }
     }
 }
示例#2
0
 public void Pop()
 {
     current_event = list.First.Value;
     turn = current_event.TimeToExecute();
     cached_status = null;
     cached_lighting = null;
     current_event.Execute();
     list.Remove(current_event);
 }
		public void Add(Event e){
			if(e.TimeToExecute() == turn){ //0-time action
				list.Insert(0, e);
			}
			else{
				if(list.Count == 0 || (list.Count > 0 && list[0] == null)){
					list.Insert(0, e);
				}
				else{
                    if (list.Count > 0 && e >= list[list.Count - 1])
                    {
						list.Insert(list.Count, e);
					}
					else{
                        if (list.Count > 0 && e < list[0])
                        {
                            list.Insert(0, e);
						}
						else{ //it's going between two events
							Event current = list[list.Count - 1];
                            int cr = list.Count;
							while(true){
                                cr--;
                                if (e >= list[cr])
                                {
									list.Insert(cr + 1, e);
									return;
								}
								
							}
								/*if(e.TimeToExecute() == current.Value.TimeToExecute()){
									if(e.type != EventType.MOVE){
										list.AddAfter(current,e);
										return;
									}
									else{
										while(current.Value.type != EventType.MOVE){
											if(current == list.First){
												list.AddFirst(e);
												return;
											}
											else{
												if(e.TimeToExecute() != current.Previous.Value.TimeToExecute()){
													list.AddBefore(current,e);
													return;
												}
												else{
													current = current.Previous;
												}
											}
										}
										list.AddAfter(current,e);
										return;
									}
								}
								else{
									if(e < current.Value){
										if(e > current.Previous.Value){
											list.AddBefore(current,e);
											return;
										}
										else{
											current = current.Previous;
										}
									}
								}
							}*/
						}
					}
				}
			}
		}