public RuntimeTemplate(int templateId, GameEngine engine) { _defaultDataInstances = new SparseArray<Data.IData>(); _gameEngine = engine; TemplateId = templateId; PrettyName = ""; }
/// <summary> /// Creates a new game engine that can be used to simulate the game using the content from /// the given content database. The passed in snapshot will not be modified. /// </summary> /// <param name="snapshotJson">The serialized IGameSnapshot to use to create the /// engine.</param> /// <param name="templateJson">The serialized ITemplateGroup used to create the /// engine.</param> /// <returns>A game engine that can play the given content.</returns> public static Maybe<IGameEngine> CreateEngine(string snapshotJson, string templateJson) { try { IGameEngine engine = new GameEngine(snapshotJson, templateJson); return Maybe.Just(engine); } catch (Exception e) { Log.Get(typeof(GameEngineFactory)).Warn(string.Format("Failed to create engine " + "with snapshot={0}, template={1}, exception={2}", snapshotJson, templateJson, e)); } return Maybe<IGameEngine>.Empty; }