using NTERA.Core.Interop; namespace NTERA.Core { public class GameInstance { public IConsole Console { get; protected set; } public IScriptEngine ScriptEngine { get; set; } public void Run(IConsole console, IScriptEngine scriptEngine) { Console = console; ScriptEngine = scriptEngine; if (!ScriptEngine.Initialize(Console)) return; ScriptEngine.Start(); } public void GiveInput(string input) { InputRequest currentRequest = Console.CurrentRequest; if (Console.CurrentRequest != null) { switch (currentRequest.InputType) { case InputType.IntValue: long inputValue; if (string.IsNullOrEmpty(input) && currentRequest.HasDefValue)// && !IsRunningTimer) { inputValue = currentRequest.DefIntValue; input = inputValue.ToString(); } else if (!long.TryParse(input, out inputValue)) { break; } if (currentRequest.IsSystemInput) ScriptEngine.InputSystemInteger(inputValue); else ScriptEngine.InputInteger(inputValue); break; case InputType.StrValue: if (string.IsNullOrEmpty(input) && currentRequest.HasDefValue)// && !IsRunningTimer) input = currentRequest.DefStrValue; ScriptEngine.InputString(input ?? ""); break; } } Console.GiveInput(input); } } }