示例#1
0
 public ParticleLibrary(ResourceManager res, AleFile ale)
 {
     Resources = res;
     foreach (var effect in ale.FxLib.Effects)
     {
         var fx = new ParticleEffect(this);
         fx.CRC  = effect.CRC;
         fx.Name = effect.Name;
         Dictionary <uint, NodeReference> nodesByIndex = new Dictionary <uint, NodeReference>();
         foreach (var noderef in effect.Fx)
         {
             FxNode node = null;
             if (!noderef.IsAttachmentNode)
             {
                 var nd = ale.NodeLib.Nodes.FirstOrDefault((arg) => arg.CRC == noderef.CRC);
                 if (nd == null)
                 {
                     node = new FxNode("error node", "error node");
                     FLLog.Error("Fx", fx.Name + " bad node CRC 0x" + noderef.CRC.ToString("x"));
                 }
                 else
                 {
                     node = NodeFromAle(ale.NodeLib.Nodes.Where((arg) => arg.CRC == noderef.CRC).First());
                 }
             }
             var reference = new NodeReference();
             reference.Node             = node;
             reference.IsAttachmentNode = noderef.IsAttachmentNode;
             nodesByIndex.Add(noderef.Index, reference);
         }
         foreach (var noderef in effect.Fx)
         {
             var nd = nodesByIndex[noderef.Index];
             if (noderef.Parent != 32768)
             {
                 var parent = nodesByIndex[noderef.Parent];
                 parent.Children.Add(nd);
                 nd.Parent = parent;
             }
         }
         foreach (var pair in effect.Pairs)
         {
             var n1 = nodesByIndex[pair.Item1];
             var n2 = nodesByIndex[pair.Item2];
             n1.Paired.Add(n2);
         }
         fx.References = new List <NodeReference>(nodesByIndex.Values);
         Effects.Add(fx);
     }
 }
示例#2
0
 public ParticleLibrary(ResourceManager res, AleFile ale)
 {
     Resources = res;
     foreach (var effect in ale.FxLib.Effects)
     {
         var fx   = new ParticleEffect(this);
         var root = new FxRootNode();
         fx.CRC  = effect.CRC;
         fx.Name = effect.Name;
         List <FxNode>             nodes        = new List <FxNode>();
         Dictionary <uint, FxNode> nodesByIndex = new Dictionary <uint, FxNode>();
         foreach (var noderef in effect.Fx)
         {
             FxNode node;
             if (noderef.IsAttachmentNode)
             {
                 node = new FxNode("Attachment_0x" + noderef.CRC.ToString("X"), "Empty")
                 {
                     CRC = noderef.CRC
                 };
             }
             else
             {
                 node = NodeFromAle(ale.NodeLib.Nodes.Where((arg) => arg.CRC == noderef.CRC).First());
             }
             nodes.Add(node);
             nodesByIndex.Add(noderef.Index, node);
         }
         foreach (var noderef in effect.Fx)
         {
             var nd = nodesByIndex[noderef.Index];
             //var nd = FindNode(noderef.CRC);
             if (noderef.Parent != 32768)
             {
                 fx.Parents.Add(nd, nodesByIndex[noderef.Parent]);
             }
             else
             {
                 fx.Parents.Add(nd, root);
             }
             if (noderef.IsAttachmentNode)
             {
                 fx.AttachmentNodes.Add(nd);
             }
         }
         foreach (var pair in effect.Pairs)
         {
             var n1 = nodesByIndex[pair.Item1];
             var n2 = nodesByIndex[pair.Item2];
             List <Fx.FxNode> pairedTo;
             if (!fx.Pairs.TryGetValue(n1, out pairedTo))
             {
                 pairedTo = new List <FxNode>();
                 fx.Pairs.Add(n1, pairedTo);
             }
             pairedTo.Add(n2);
         }
         fx.SetNodes(nodes);
         Effects.Add(fx);
     }
 }