Skip to content

Commit

Permalink
Hopefully fixed duplicating build queue items (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekolis committed May 22, 2022
1 parent cd78ff3 commit 8d1d8ab
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions FrEee/Game/Interfaces/IOrderable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface IOrderable : IReferrable
/// <summary>
/// The queued orders.
/// </summary>
IList<IOrder> Orders { get; }
IEnumerable<IOrder> Orders { get; }

void AddOrder(IOrder order);

Expand All @@ -29,4 +29,4 @@ public interface IOrderable : IReferrable

void RemoveOrder(IOrder order);
}
}
}
7 changes: 4 additions & 3 deletions FrEee/Game/Objects/Civilization/ConstructionQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ public IList<IConstructionOrder> Orders
private set;
}

IEnumerable<IOrder> IOrderable.Orders
=> Orders;

public Empire Owner
{
get { return Container.Owner; }
Expand Down Expand Up @@ -289,8 +292,6 @@ public ResourceQuantity UpcomingSpending
}
}

IList<IOrder> IOrderable.Orders => Orders.Cast<IOrder>().ToList();

private ResourceQuantity rate;

public void AddOrder(IOrder order)
Expand Down Expand Up @@ -576,4 +577,4 @@ private ResourceQuantity ComputeSYAbilityRate()
return null;
}
}
}
}
7 changes: 5 additions & 2 deletions FrEee/Game/Objects/Space/Fleet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Game.Enumerations;
using FrEee.Game.Enumerations;
using FrEee.Game.Interfaces;
using FrEee.Game.Objects.Abilities;
using FrEee.Game.Objects.Civilization;
Expand Down Expand Up @@ -377,6 +377,9 @@ public int NormalShields

public IList<IOrder> Orders { get; private set; }

IEnumerable<IOrder> IOrderable.Orders
=> Orders;

public int OrganicsMaintenance
{
get { return MaintenanceCost[Resource.Organics]; }
Expand Down Expand Up @@ -915,4 +918,4 @@ private IEnumerable<string> GetImagePaths(string imagetype)

public bool FillsCombatTile => Vehicles.Any(q => q.FillsCombatTile);
}
}
}
3 changes: 3 additions & 0 deletions FrEee/Game/Objects/Space/Planet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ public double MerchantsRatio

public IList<IOrder> Orders { get; private set; }

IEnumerable<IOrder> IOrderable.Orders
=> Orders;

public int OrganicsIncome => this.GrossIncome()[Resource.Organics];

public double OrganicsValue => ResourceValue[Resource.Organics];
Expand Down
7 changes: 5 additions & 2 deletions FrEee/Game/Objects/Vehicles/SpaceVehicle.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Game.Enumerations;
using FrEee.Game.Enumerations;
using FrEee.Game.Interfaces;
using FrEee.Game.Objects.Civilization;
using FrEee.Game.Objects.Space;
Expand Down Expand Up @@ -130,6 +130,9 @@ public IList<IOrder> Orders
private set;
}

IEnumerable<IOrder> IOrderable.Orders
=> Orders;

public override IEnumerable<IAbilityObject> Parents
{
get
Expand Down Expand Up @@ -380,4 +383,4 @@ public virtual void SpendTime(double timeElapsed)
TimeToNextMove += timeElapsed;
}
}
}
}
6 changes: 3 additions & 3 deletions FrEee/Utility/Extensions/CommonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@ public static bool ExecuteMobileSpaceObjectOrders<T>(this T o)
runOrders.Add(order);
if (order.IsComplete && o.Orders.Contains(order))
{
o.Orders.RemoveAt(0);
o.RemoveOrder(o.Orders.First());
if (o.AreRepeatOrdersEnabled)
{
order.IsComplete = false;
o.Orders.Add(order);
if (runOrders.Count == o.Orders.Count)
o.AddOrder(order);
if (runOrders.Count == o.Orders.Count())
break; // don't get in an infinite loop of repeating orders
}
}
Expand Down

0 comments on commit 8d1d8ab

Please sign in to comment.