Ejemplo n.º 1
0
        protected virtual void SpawnSpecies(ComplexConcentration complexConcentration)
        {
            int amount = Mathf.RoundToInt(complexConcentration.concentration * container.volume * 6.022141e23f);

            if (amount < 1 || complexConcentration.moleculeCount < 1)
            {
                return;
            }

            MoleculeInitData initData = new MoleculeInitData(complexConcentration.complexPattern, CalculateMoleculeTransforms(complexConcentration.complexPattern),
                                                             GetRelevantBindReactions(complexConcentration.complexPattern),
                                                             GetRelevantCollisionFreeReactions(complexConcentration.complexPattern));

            Complex complex;

            for (int i = 0; i < amount; i++)
            {
                complex = new Complex(initData, this);

                //add all the new molecules as initial agents
                foreach (string moleculeName in complex.molecules.Keys)
                {
                    foreach (Molecule molecule in complex.molecules[moleculeName])
                    {
                        molecule.agentID = nextID;
                        agents.Add(molecule.agentID, new AgentData(moleculeName, molecule.position, molecule.rotation));
                        molecules.Add(molecule.agentID, molecule);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void SpawnMolecules(MoleculeInitData initData)
 {
     molecules = new Dictionary <string, List <Molecule> >();
     foreach (string moleculeName in initData.complexPattern.moleculePatterns.Keys)
     {
         if (!molecules.ContainsKey(moleculeName))
         {
             molecules.Add(moleculeName, new List <Molecule>());
         }
         for (int i = 0; i < initData.complexPattern.moleculePatterns[moleculeName].Count; i++)
         {
             molecules[moleculeName].Add(new Molecule(initData.complexPattern.moleculePatterns[moleculeName][i], initData.moleculeTransforms[moleculeName][i], this));
         }
     }
     ConnectBoundComponents();
     InitReactions(initData.relevantBindReactions, initData.relevantCollisionFreeReactions);
 }
Ejemplo n.º 3
0
 public Complex(MoleculeInitData initData, Reactor _reactor)
 {
     reactor = _reactor;
     SpawnMolecules(initData);
     Init(reactor.container.GetRandomPointInBounds(0.1f), Random.rotation);
 }