本文整理汇总了C#中ObjectManager.CreateOrRecycle方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectManager.CreateOrRecycle方法的具体用法?C# ObjectManager.CreateOrRecycle怎么用?C# ObjectManager.CreateOrRecycle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectManager
的用法示例。
在下文中一共展示了ObjectManager.CreateOrRecycle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Game
/// <summary>
/// Initializes a new instance of the <see cref="FreezingArcher.Content.Game"/> class.
/// </summary>
/// <param name="name">Name.</param>
/// <param name="objmnr">Object Manager.</param>
/// <param name="messageProvider">Message Manager.</param>
public Game (string name, ObjectManager objmnr, MessageProvider messageProvider, CompositorNodeScene scenenode, RendererContext rendererContext)
{
Logger.Log.AddLogEntry (LogLevel.Info, ClassName, "Creating new game '{0}'", name);
Name = name;
MessageProvider = messageProvider;
RendererContext = rendererContext;
SceneNode = scenenode;
GameStateGraph = objmnr.CreateOrRecycle<DirectedWeightedGraph<GameState, GameStateTransition>>();
GameStateGraph.Init();
}
示例2: BasicCompositor
public BasicCompositor(ObjectManager objm, RendererContext rc)
{
graphLock = new object();
_CompositorGraph = objm.CreateOrRecycle<DirectedWeightedGraph<CompositorNode, CompositorEdgeDescriptionListWrapper>>();
_CompositorGraph.Init();
_Nodes = new List<DirectedWeightedNode<CompositorNode, CompositorEdgeDescriptionListWrapper>>();
_Edges = new List<DirectedWeightedEdge<CompositorNode, CompositorEdgeDescriptionListWrapper>>();
DummyNode = _CompositorGraph.AddNode(null);
RendererContext = rc;
}
示例3: Test
/// <summary>
/// Test the graphs.
/// </summary>
public static void Test()
{
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "Starting graph tests...");
var objectManager = new ObjectManager();
// [1]---19--->[2]
// A \ A
// | \ |
// | \ |
// | \ |
// 42 1 12
// | \ |
// | \ |
// | \ |
// | _\ |
// [4]<---4----[3]
var graph = objectManager.CreateOrRecycle<DirectedWeightedGraph<string, uint>>();
graph.Init();
var node1 = graph.AddNode("Node 1");
var node2 = graph.AddNode("Node 2", null, new Pair<DirectedWeightedNode<string, uint>, uint>[] {
new Pair<DirectedWeightedNode<string, uint>, uint>(node1, 19)
});
var node3 = graph.AddNode("Node 3", new Pair<DirectedWeightedNode<string, uint>, uint>[] {
new Pair<DirectedWeightedNode<string, uint>, uint>(node2, 12)
}, new Pair<DirectedWeightedNode<string, uint>, uint>[] {
new Pair<DirectedWeightedNode<string, uint>, uint>(node1, 1)
});
graph.AddNode("Node 4", new Pair<DirectedWeightedNode<string, uint>, uint>[] {
new Pair<DirectedWeightedNode<string, uint>, uint>(node1, 42)
}, new Pair<DirectedWeightedNode<string, uint>, uint>[] {
new Pair<DirectedWeightedNode<string, uint>, uint>(node3, 4)
});
foreach (var node in graph.Nodes)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "{0} - outgoing: {1}, incoming {2}", node.Data,
node.OutgoingEdges.Count, node.IncomingEdges.Count);
foreach (var edge in graph.Edges)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "Edge from {0} to {1} with weight {2}",
edge.SourceNode.Data, edge.DestinationNode.Data, edge.Weight);
graph.BreadthFirstSearch(node1, n => {
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "BFS PREDICATE# {0}", n.Data);
return false;
});
graph.DepthFirstSearch(node1, n => {
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "DFS PREDICATE# {0}", n.Data);
return false;
});
foreach (var n in (IEnumerable<DirectedWeightedNode<string, uint>>) graph)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "FOR# Node: {0}", n.GetHashCode());
foreach (var s in (IEnumerable<string>) graph)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "FOR# Data: {0}", s);
foreach (var e in (IEnumerable<DirectedWeightedEdge<string, uint>>) graph)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "FOR# Weight: {0}", e.Weight);
foreach (var n in (IEnumerable<DirectedWeightedNode<string, uint>>) graph.AsBreadthFirstEnumerable)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "BFS# Node: {0}", n.GetHashCode());
foreach (var s in (IEnumerable<string>) graph.AsBreadthFirstEnumerable)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "BFS# Data: {0}", s);
foreach (var e in (IEnumerable<DirectedWeightedEdge<string, uint>>) graph.AsBreadthFirstEnumerable)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "BFS# Weight: {0}", e.Weight);
foreach (var n in (IEnumerable<DirectedWeightedNode<string, uint>>) graph.AsDepthFirstEnumerable)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "DFS# Node: {0}", n.GetHashCode());
foreach (var s in (IEnumerable<string>) graph.AsDepthFirstEnumerable)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "DFS# Data: {0}", s);
foreach (var e in (IEnumerable<DirectedWeightedEdge<string, uint>>) graph.AsDepthFirstEnumerable)
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "DFS# Weight: {0}", e.Weight);
Logger.Log.AddLogEntry(LogLevel.Debug, "GraphTest", "Graph tests finished!");
}