moved ProductionItem into Traits.ProductionQueue's file
This commit is contained in:
@@ -111,7 +111,6 @@
|
|||||||
<Compile Include="Ore.cs" />
|
<Compile Include="Ore.cs" />
|
||||||
<Compile Include="PackageDownloader.cs" />
|
<Compile Include="PackageDownloader.cs" />
|
||||||
<Compile Include="PathSearch.cs" />
|
<Compile Include="PathSearch.cs" />
|
||||||
<Compile Include="ProductionItem.cs" />
|
|
||||||
<Compile Include="Shroud.cs" />
|
<Compile Include="Shroud.cs" />
|
||||||
<Compile Include="Smudge.cs" />
|
<Compile Include="Smudge.cs" />
|
||||||
<Compile Include="Sound.cs" />
|
<Compile Include="Sound.cs" />
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace OpenRa
|
|
||||||
{
|
|
||||||
class ProductionItem
|
|
||||||
{
|
|
||||||
public readonly string Item;
|
|
||||||
|
|
||||||
public readonly int TotalTime;
|
|
||||||
public readonly int TotalCost;
|
|
||||||
public int RemainingTime { get; private set; }
|
|
||||||
public int RemainingCost { get; private set; }
|
|
||||||
|
|
||||||
public bool Paused = false, Done = false;
|
|
||||||
public Action OnComplete;
|
|
||||||
|
|
||||||
int slowdown = 0;
|
|
||||||
|
|
||||||
public ProductionItem(string item, int time, int cost, Action onComplete)
|
|
||||||
{
|
|
||||||
if( time <= 0 )
|
|
||||||
time = 1;
|
|
||||||
Item = item;
|
|
||||||
RemainingTime = TotalTime = time;
|
|
||||||
RemainingCost = TotalCost = cost;
|
|
||||||
OnComplete = onComplete;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Tick(Player player)
|
|
||||||
{
|
|
||||||
if (Done)
|
|
||||||
{
|
|
||||||
if (OnComplete != null) OnComplete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Paused) return;
|
|
||||||
|
|
||||||
if (player.GetPowerState() != PowerState.Normal)
|
|
||||||
{
|
|
||||||
if (--slowdown <= 0)
|
|
||||||
slowdown = Rules.General.LowPowerSlowdown;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var costThisFrame = RemainingCost / RemainingTime;
|
|
||||||
if (costThisFrame != 0 && !player.TakeCash(costThisFrame)) return;
|
|
||||||
|
|
||||||
RemainingCost -= costThisFrame;
|
|
||||||
RemainingTime -= 1;
|
|
||||||
if (RemainingTime > 0) return;
|
|
||||||
|
|
||||||
Done = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -168,4 +168,57 @@ namespace OpenRa.Traits
|
|||||||
FinishProduction( newUnitType.Category );
|
FinishProduction( newUnitType.Category );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ProductionItem
|
||||||
|
{
|
||||||
|
public readonly string Item;
|
||||||
|
|
||||||
|
public readonly int TotalTime;
|
||||||
|
public readonly int TotalCost;
|
||||||
|
public int RemainingTime { get; private set; }
|
||||||
|
public int RemainingCost { get; private set; }
|
||||||
|
|
||||||
|
public bool Paused = false, Done = false;
|
||||||
|
public Action OnComplete;
|
||||||
|
|
||||||
|
int slowdown = 0;
|
||||||
|
|
||||||
|
public ProductionItem(string item, int time, int cost, Action onComplete)
|
||||||
|
{
|
||||||
|
if (time <= 0)
|
||||||
|
time = 1;
|
||||||
|
Item = item;
|
||||||
|
RemainingTime = TotalTime = time;
|
||||||
|
RemainingCost = TotalCost = cost;
|
||||||
|
OnComplete = onComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick(Player player)
|
||||||
|
{
|
||||||
|
if (Done)
|
||||||
|
{
|
||||||
|
if (OnComplete != null) OnComplete();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Paused) return;
|
||||||
|
|
||||||
|
if (player.GetPowerState() != PowerState.Normal)
|
||||||
|
{
|
||||||
|
if (--slowdown <= 0)
|
||||||
|
slowdown = Rules.General.LowPowerSlowdown;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var costThisFrame = RemainingCost / RemainingTime;
|
||||||
|
if (costThisFrame != 0 && !player.TakeCash(costThisFrame)) return;
|
||||||
|
|
||||||
|
RemainingCost -= costThisFrame;
|
||||||
|
RemainingTime -= 1;
|
||||||
|
if (RemainingTime > 0) return;
|
||||||
|
|
||||||
|
Done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user