riversong code showcase
This commit is contained in:
44
Source/Riversong/Game/World/Buildings/TentRemovalSystem.cs
Normal file
44
Source/Riversong/Game/World/Buildings/TentRemovalSystem.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace DanieleMarotta.RiversongCodeShowcase
|
||||
{
|
||||
public class TentRemovalSystem : GameSystem, IInitializable, IDisposable
|
||||
{
|
||||
[InjectService]
|
||||
private ISignalBus _signalBus;
|
||||
|
||||
[InjectService]
|
||||
private IDeleteBuildingService _deleteBuildingService;
|
||||
|
||||
[InjectService]
|
||||
private IEntityCache _entityCache;
|
||||
|
||||
public TentRemovalSystem(IServiceLocator serviceLocator) : base(serviceLocator)
|
||||
{
|
||||
}
|
||||
|
||||
public UniTask InitializeAsync()
|
||||
{
|
||||
_signalBus.Subscribe<DayStartedSignal>(OnDayStarted);
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_signalBus.Unsubscribe<DayStartedSignal>(OnDayStarted);
|
||||
}
|
||||
|
||||
private void OnDayStarted(DayStartedSignal signal)
|
||||
{
|
||||
var tents = _entityCache.GetTentBuildings();
|
||||
|
||||
for (var i = tents.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var tent = tents[i];
|
||||
_deleteBuildingService.Delete(tent, DeleteBuildingOptions.Silent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user