public IGameState ToItem(AGSSerializationContext context) { TypedParameter viewParam = new TypedParameter(typeof(IViewport), Viewport.ToItem(context)); IGameState state = context.Resolver.Container.Resolve <IGameState>(viewParam); state.SecondaryViewports.Clear(); if (SecondaryViewports != null) { foreach (var viewport in SecondaryViewports) { state.SecondaryViewports.Add(viewport.ToItem(context)); } } state.Rooms.Clear(); if (Rooms != null) { foreach (var room in Rooms) { state.Rooms.Add(room.ToItem(context)); } } state.UI.Clear(); if (UI != null) { foreach (var ui in UI) { state.UI.Add(ui.ToItem(context)); } } state.GlobalVariables.CopyFrom(GlobalVariables.ToItem(context)); state.Cutscene.CopyFrom(Cutscene.ToItem(context)); ICharacter player = Player.ToItem(context); state.Player = player; state.Speed = GameSpeed; if (RepeatCounters == null) { RepeatCounters = new Dictionary <string, int> (); } Repeat.FromDictionary(RepeatCounters); return(state); }
public IGameState ToItem(AGSSerializationContext context) { IGameState state = context.Resolver.Container.Resolve <IGameState>(); state.Rooms.Clear(); if (Rooms != null) { foreach (var room in Rooms) { state.Rooms.Add(room.ToItem(context)); } } state.UI.Clear(); if (UI != null) { foreach (var ui in UI) { state.UI.Add(ui.ToItem(context)); } } state.GlobalVariables.CopyFrom(GlobalVariables.ToItem(context)); state.Cutscene.CopyFrom(Cutscene.ToItem(context)); ICharacter player = Player.ToItem(context); var updater = new ContainerBuilder(); updater.Update(context.Resolver.Container); state.Player = player; state.Speed = GameSpeed; if (RepeatCounters == null) { RepeatCounters = new Dictionary <string, int> (); } Repeat.FromDictionary(RepeatCounters); return(state); }