本文整理汇总了C#中Logger.SetAsActive方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.SetAsActive方法的具体用法?C# Logger.SetAsActive怎么用?C# Logger.SetAsActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger.SetAsActive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
/**
* Generates the system prefab from the configuration
* @return System prefab object
**/
public PSystem Generate()
{
// Dictionary of bodies generated
Dictionary<string, Body> bodies = new Dictionary<string, Body> ();
// Retrieve the root config node
ConfigNode rootConfig = GameDatabase.Instance.GetConfigs (rootNodeName) [0].config;
if (rootConfig.HasValue("Epoch"))
double.TryParse(rootConfig.GetValue("Epoch"), out Templates.instance.epoch);
if(rootConfig.HasValue("useOnDemand"))
bool.TryParse(rootConfig.GetValue("useOnDemand"), out OnDemand.OnDemandStorage.useOnDemand);
if (rootConfig.HasValue("onDemandLoadOnMissing"))
bool.TryParse(rootConfig.GetValue("onDemandLoadOnMissing"), out OnDemand.OnDemandStorage.onDemandLoadOnMissing);
if (rootConfig.HasValue("onDemandLogOnMissing"))
bool.TryParse(rootConfig.GetValue("onDemandLogOnMissing"), out OnDemand.OnDemandStorage.onDemandLogOnMissing);
if (rootConfig.HasValue("onDemandForceCollect"))
bool.TryParse(rootConfig.GetValue("onDemandForceCollect"), out OnDemand.OnDemandStorage.onDemandForceCollect);
if (rootConfig.HasNode("Finalize"))
foreach (ConfigNode n in rootConfig.GetNode("Finalize").GetNodes(bodyNodeName))
if (n.HasValue("name"))
Templates.instance.finalizeBodies.Add(n.GetValue("name"));
// Stage 1 - Load all of the bodies
foreach (ConfigNode bodyNode in rootConfig.GetNodes(bodyNodeName))
{
// Create a logger for this body
Logger bodyLogger = new Logger (bodyNode.GetValue ("name") + ".Body");
bodyLogger.SetAsActive ();
// Attempt to create the body
try
{
Body body = Parser.CreateObjectFromConfigNode<Body> (bodyNode);
bodies.Add (body.name, body);
Logger.Default.Log ("[Kopernicus]: Configuration.Loader: Loaded Body: " + body.name);
}
catch (Exception e)
{
bodyLogger.LogException (e);
Logger.Default.Log ("[Kopernicus]: Configuration.Loader: Failed to load Body: " + bodyNode.GetValue ("name"));
}
// Restore default logger
bodyLogger.Flush ();
Logger.Default.SetAsActive ();
}
// Stage 2 - create a new planetary system object
GameObject gameObject = new GameObject ("Kopernicus");
gameObject.transform.parent = Utility.Deactivator;
PSystem system = gameObject.AddComponent<PSystem> ();
// Set the planetary system defaults (pulled from PSystemManager.Instance.systemPrefab)
system.systemName = "Kopernicus";
system.systemTimeScale = 1.0;
system.systemScale = 1.0;
system.mainToolbarSelected = 2; // initial value in stock systemPrefab. Unknown significance.
// Stage 3 - Glue all the orbits together in the defined pattern
foreach (KeyValuePair<string, Body> body in bodies)
{
// If this body is in orbit around another body
if(body.Value.referenceBody != null)
{
// Get the Body object for the reference body
Body parent = null;
if(!bodies.TryGetValue(body.Value.referenceBody, out parent))
{
throw new Exception("\"" + body.Value.referenceBody + "\" not found.");
}
// Setup the orbit of the body
parent.generatedBody.children.Add(body.Value.generatedBody);
body.Value.generatedBody.orbitDriver.referenceBody = parent.generatedBody.celestialBody;
body.Value.generatedBody.orbitDriver.orbit.referenceBody = parent.generatedBody.celestialBody;
}
// Parent the generated body to the PSystem
body.Value.generatedBody.transform.parent = system.transform;
}
// Stage 4 - elect root body
system.rootBody = bodies.First(p => p.Value.referenceBody == null).Value.generatedBody;
// Stage 4.5, get the new Menu-body / Home body
if (rootConfig.HasValue("mainMenuBody"))
{
Templates.menuBody = rootConfig.GetValue("mainMenuBody");
}
else
{
Templates.menuBody = Utility.FindHomeBody(system.rootBody).name;
}
//.........这里部分代码省略.........
示例2: foreach
// Generates the system prefab from the configuration
void IParserEventSubscriber.PostApply(ConfigNode node)
{
// Dictionary of bodies generated
Dictionary<string, Body> bodies = new Dictionary<string, Body>();
// Load all of the bodies
foreach (ConfigNode bodyNode in node.GetNodes(bodyNodeName))
{
// Create a logger for this body
Logger bodyLogger = new Logger(bodyNode.GetValue("name") + ".Body");
bodyLogger.SetAsActive();
// Attempt to create the body
try
{
currentBody = new Body();
Parser.LoadObjectFromConfigurationNode(currentBody, bodyNode);
bodies.Add(currentBody.name, currentBody);
Logger.Default.Log("[Kopernicus]: Configuration.Loader: Loaded Body: " + currentBody.name);
}
catch (Exception e)
{
bodyLogger.LogException(e);
Logger.Default.Log("[Kopernicus]: Configuration.Loader: Failed to load Body: " + bodyNode.GetValue("name"));
}
// Restore default logger
bodyLogger.Flush ();
Logger.Default.SetAsActive ();
}
// Load all of the asteroids
foreach (ConfigNode asteroidNode in node.GetNodes(asteroidNodeName))
{
// Create a logger for this asteroid
Logger logger = new Logger(asteroidNode.GetValue("name") + ".Asteroid");
logger.SetAsActive();
// Attempt to create the Asteroid
try
{
Asteroid asteroid = Parser.CreateObjectFromConfigNode<Asteroid>(asteroidNode);
DiscoverableObjects.asteroids.Add(asteroid);
Logger.Default.Log("[Kopernicus]: Configuration.Loader: Loaded Asteroid: " + asteroid.name);
}
catch (Exception e)
{
logger.LogException(e);
Logger.Default.Log("[Kopernicus]: Configuration.Loader: Failed to load Asteroid: " + asteroidNode.GetValue("name"));
}
// Restore default logger
logger.Flush();
Logger.Default.SetAsActive();
}
// Glue all the orbits together in the defined pattern
foreach (KeyValuePair<string, Body> body in bodies)
{
// If this body is in orbit around another body
if(body.Value.orbit != null)
{
// Get the Body object for the reference body
Body parent = null;
if(!bodies.TryGetValue(body.Value.orbit.referenceBody, out parent))
{
throw new Exception("\"" + body.Value.orbit.referenceBody + "\" not found.");
}
// Setup the orbit of the body
parent.generatedBody.children.Add(body.Value.generatedBody);
body.Value.generatedBody.orbitDriver.referenceBody = parent.generatedBody.celestialBody;
body.Value.generatedBody.orbitDriver.orbit.referenceBody = parent.generatedBody.celestialBody;
}
// Parent the generated body to the PSystem
body.Value.generatedBody.transform.parent = systemPrefab.transform;
}
// Elect root body
systemPrefab.rootBody = bodies.First(p => p.Value.orbit == null).Value.generatedBody;
// Sort by distance from parent (discover how this effects local bodies)
RecursivelySortBodies (systemPrefab.rootBody);
// Fix doubled flightGlobals
List<int> numbers = new List<int>() { 0 };
int index = bodies.Sum(b => b.Value.generatedBody.flightGlobalsIndex);
PatchFGI(ref numbers, ref index, systemPrefab.rootBody);
// Main Menu bodies
if (randomMainMenuBodies.Any())
Templates.menuBody = randomMainMenuBodies[new System.Random().Next(0, randomMainMenuBodies.Count)];
}