Update PlayerResources capacity from INotify* methods

This commit is contained in:
teinarss
2019-07-05 20:18:40 +02:00
committed by reaperrr
parent 8edd202b64
commit ce29dcad87
2 changed files with 19 additions and 8 deletions

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
public object Create(ActorInitializer init) { return new StoresResources(init.Self, this); }
}
public class StoresResources : IPips, INotifyOwnerChanged, INotifyCapture, IStoreResources, ISync, INotifyKilled
public class StoresResources : IPips, INotifyOwnerChanged, INotifyCapture, IStoreResources, ISync, INotifyKilled, INotifyAddedToWorld, INotifyRemovedFromWorld
{
readonly StoresResourcesInfo info;
PlayerResources player;
@@ -71,5 +71,15 @@ namespace OpenRA.Mods.Common.Traits
player.Resources * info.PipCount > i * player.ResourceCapacity
? info.PipColor : PipType.Transparent);
}
void INotifyAddedToWorld.AddedToWorld(Actor self)
{
player.AddStorage(info.Capacity);
}
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
{
player.RemoveStorage(info.Capacity);
}
}
}