Пример #1
0
        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);
            });
        }
Пример #2
0
 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);
 }
Пример #3
0
 protected override Settings Convert()
 {
     return(new Settings {
         ReplayEnabled = this.ReplayEnabled,
         LoggingEnabled = this.LoggingEnabled,
         LogFilter = StringStore.Store(String.Join(":", this.LogFilter)),
     });
 }
Пример #4
0
        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);
            });
        }