Show More
Commit Description:
Update TODOs.
Commit Description:
Update TODOs.
File last commit:
Show/Diff file:
Action:
isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs
111 lines | 3.0 KiB | text/x-csharp | CSharpLexer
using System.Collections.Generic;
using Encompass;
using System.Linq;
using isometricparkfna.Messages;
using isometricparkfna.Components;
namespace isometricparkfna.Engines {
[Sends(typeof(ToggleWindowMessage),
typeof(ToggleWindowTypeMessage),
typeof(ChangeContractStatusMessage),
typeof(SelectMessage),
typeof(JumpCameraMessage),
typeof(GameStateMessage),
typeof(GameStateMessage),
typeof(SetResolutionMessage))]
[Reads(typeof(VisibilityComponent),
typeof(WindowTypeComponent)
//, typeof(SelectedComponent)
)]
// [Writes(typeof(SelectedComponent))]
public class ImGuiWindowBridgeEngine : Engine
{
public List<ToggleWindowMessage> messages;
public List<ToggleWindowTypeMessage> typeMessages;
public List<ChangeContractStatusMessage> contractStatusMessages;
public List<SelectMessage> selectedMessages;
public List<JumpCameraMessage> jumpCameraMessages;
public List<GameStateMessage> gameStateMessages;
public List<SetResolutionMessage> resolutionMessages;
bool showBudget {get;}
bool showForest {get;}
bool showNews {get;}
bool showGrid {get;}
bool showTrees {get;}
public Dictionary<Window, bool> windowStatuses {get;}
public ImGuiWindowBridgeEngine()
{
this.messages = new List<ToggleWindowMessage>();
this.typeMessages = new List<ToggleWindowTypeMessage>();
this.contractStatusMessages = new List<ChangeContractStatusMessage>();
this.selectedMessages = new List<SelectMessage>();
this.jumpCameraMessages = new List<JumpCameraMessage>();
this.gameStateMessages = new List<GameStateMessage>();
this.resolutionMessages = new List<SetResolutionMessage>();
this.windowStatuses = new Dictionary<Window, bool>();
//Prepopulate:
foreach(var type in System.Enum.GetValues(typeof(Window)))
{
windowStatuses.Add((Window)type, false);
}
}
public override void Update(double dt)
{
foreach(var message in this.messages)
{
SendMessage(message);
}
foreach(var message in this.typeMessages)
{
SendMessage(message);
}
foreach(var message in this.contractStatusMessages)
{
SendMessage(message);
}
foreach(var message in this.selectedMessages)
{
SendMessage(message);
// SetComponent<SelectedComponent>(message.Entity, new SelectedComponent { selected = true});
}
foreach(var message in this.jumpCameraMessages)
{
SendMessage(message);
}
foreach(var message in this.gameStateMessages)
{
SendMessage(message);
}
foreach(var message in this.resolutionMessages)
{
SendMessage(message);
}
foreach(var entity in ReadEntities<WindowTypeComponent>())
{
var type = GetComponent<WindowTypeComponent>(entity).type;
var visibility = GetComponent<VisibilityComponent>(entity).visible;
windowStatuses[type] = visibility;
}
this.messages.Clear();
this.typeMessages.Clear();
this.contractStatusMessages.Clear();
this.selectedMessages.Clear();
this.jumpCameraMessages.Clear();
this.gameStateMessages.Clear();
this.resolutionMessages.Clear();
}
}
}