本文整理汇总了C#中Renderer.Initialise方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.Initialise方法的具体用法?C# Renderer.Initialise怎么用?C# Renderer.Initialise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderer
的用法示例。
在下文中一共展示了Renderer.Initialise方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
/// <summary>
/// Runs this client instance.
/// </summary>
public bool Run()
{
// A logger must be set and this should be set as the current client in RwCore
if (RwCore.Client != this)
throw new InvalidOperationException("RwClient.Start: RwCore.Client must reference this client instance before calling Start().");
if (Logger == null)
throw new InvalidOperationException("RwClient.Start: An ILogger instance must be attached before calling Start().");
if (HasStarted)
throw new InvalidOperationException("RwClient.Start: Client is already started.");
Logger.Out("RozWorld client starting...", LogLevel.Info);
Logger.Out("Initialising directories...", LogLevel.Info);
FileSystem.MakeDirectory(DIRECTORY_RENDERERS);
// Load configs
Logger.Out("Setting configs...", LogLevel.Info);
if (!File.Exists(FILE_CONFIG))
MakeDefaultConfigs(FILE_CONFIG);
DisplayResolutions = new Dictionary<byte, Size>();
// Load defaults first then load the file on disk
LoadConfigs(Properties.Resources.DefaultConfigs.Split('\n'));
LoadConfigs(FileSystem.GetTextFile(FILE_CONFIG));
// Load renderers
Logger.Out("Loading renderers...", LogLevel.Info);
Renderers = new List<Type>();
foreach (string file in Directory.GetFiles(DIRECTORY_RENDERERS))
{
try
{
Assembly assembly = Assembly.LoadFrom(file);
Type[] detectedObjects = assembly.GetTypes();
foreach (var detectedObject in detectedObjects)
{
if (detectedObject.BaseType == typeof(Renderer))
Renderers.Add(detectedObject);
}
}
catch (ReflectionTypeLoadException reflectionEx)
{
Logger.Out("An error occurred trying to enumerate the types inside of the library \"" +
Path.GetFileName(file) + "\", renderers from this library cannot be loaded. It may " +
"have been built with a different version of the RozWorld API.", LogLevel.Error);
}
catch (Exception ex)
{
Logger.Out("An error occurred trying to load library \"" + Path.GetFileName(file) +
"\", renderers from this library cannot be loaded. The exception that occurred " +
"reported the following:\n" + ex.Message + "\nStack:\n" + ex.StackTrace, LogLevel.Error);
}
}
// TODO: Replace this bit so that renderer choice will be loaded from configs
if (Renderers.Count == 0)
{
Logger.Out("No renderers were loaded! Cannot continue.", LogLevel.Fatal);
return false;
}
ActiveRenderer = (Renderer)Activator.CreateInstance(Renderers[0]);
ActiveRenderer.Initialise();
//////////////////////////////////////////////////////////////////////////////
// Load the rest and then start/run the game
ActiveRenderer.Start();
while (true) { } // for now
return true;
}