public Func <Message, IResult <Message, Reason> > Apply( Func <Message, IResult <Message, Reason> > next, EntityCommandBuffer commandBuffer ) { return((message) => { if (GlobalSettings.ReplayEnabled && !message.IsReplayTarget) { return new Error <Message, Reason>(Reason.Canceled); } if (GlobalSettings.ReplayEnabled && message.IsReplayTarget) { return next(message); } message.Frame = MessageHistorySystem.Frame; var entity = commandBuffer.CreateEntity(); commandBuffer.AddComponent(entity, new MessageHistoryRecord { Record = StringStore.Store(message.Serialize()), }); return next(message); }); }
public void Execute(Entity entity, int index, [ReadOnly] ref Settings settings) { GlobalSettings.Initialized = true; GlobalSettings.ReplayEnabled = settings.ReplayEnabled; GlobalSettings.LoggingEnabled = settings.LoggingEnabled; GlobalSettings.LogFilter = StringStore.Retrieve(settings.LogFilter).Split(':'); CommandBuffer.DestroyEntity(entity); }
protected override Settings Convert() { return(new Settings { ReplayEnabled = this.ReplayEnabled, LoggingEnabled = this.LoggingEnabled, LogFilter = StringStore.Store(String.Join(":", this.LogFilter)), }); }
private void Record() { if (writer == null) { writer = new StreamWriter(Path.Combine(Application.persistentDataPath, "MessageHistory.txt")); } Entities.ForEach((Entity entity, ref MessageHistoryRecord messageHistoryRecord) => { var record = StringStore.Retrieve(messageHistoryRecord.Record); writer.WriteLine(record); PostUpdateCommands.DestroyEntity(entity); }); }