Esempio n. 1
0
 private bool loadInstantReactionProducts(XmlNode node, InstantReaction ir)
 {
     foreach (XmlNode attr in node)
       if (attr.Name == "product")
     loadInstantReactionProduct(attr, ir);
     return true;
 }
Esempio n. 2
0
    /*!
     * \brief Build an Instant reaction with a InstantReactionProperties class
     * \param props The properties
     * \return Return a new reaction or null if it fail.
     */
    public static IReaction       buildInstantReactionFromProps(InstantReactionProperties props)
    {
        if (props == null)
        {
            return(null);
        }

        InstantReaction reaction = new InstantReaction();

        reaction.setName(props.name);
        reaction.setEnergyCost(props.energyCost);
        Product newReactant;

        foreach (Product r in props.reactants)
        {
            newReactant = new Product(r);
            reaction.addReactant(newReactant);
        }
        Product newProd;

        foreach (Product p in props.products)
        {
            newProd = new Product(p);
            reaction.addProduct(newProd);
        }
        return(reaction);
    }
Esempio n. 3
0
    public bool loadInstantReactions(XmlNode node, LinkedList<IReaction> reactions)
    {
        XmlNodeList IReactionsList = node.SelectNodes("instantReaction");
        bool b = true;

        foreach (XmlNode IReaction in IReactionsList)
          {
        InstantReaction ir = new InstantReaction();
        foreach (XmlNode attr in IReaction)
          {
            switch (attr.Name)
              {
              case "name":
                ir.setName(attr.InnerText);
                break;
              case "reactants":
                loadInstantReactionReactants(attr, ir);
                break;
              case "products":
                loadInstantReactionProducts(attr, ir);
                break;
              }
          }
        reactions.AddLast(ir);
          }
        return b;
    }
Esempio n. 4
0
    /* !
     * \brief Checks that two reactions have the same InstantReaction field values.
     * \param reaction The reaction that will be compared to 'this'.
     */
    protected override bool PartialEquals(IReaction reaction)
    {
        InstantReaction instant = reaction as InstantReaction;

        return((instant != null) &&
               base.PartialEquals(reaction) &&
               _reactants.Equals(instant._reactants));
    }
 /*!
 \brief Parse and load the energy cost of an InstantReaction
 \param value The value string
 \param ir the InstantReaction to initialize
 \return return always true
   */
 private bool loadEnergyCost(string value, InstantReaction ir)
 {
     if (String.IsNullOrEmpty(value))
       {
     Debug.Log("Error: Empty EnergyCost field. default value = 0");
     ir.setEnergyCost(0f);
       }
     else
       ir.setEnergyCost(float.Parse(value.Replace(",", ".")));
     return true;
 }
Esempio n. 6
0
    public static IReaction buildInstantReactionFromProps(InstantReactionProprieties props)
    {
        InstantReaction reaction = new InstantReaction();

        reaction.setName(props.name);
        Product newReactant;
        foreach (Product r in props.reactants)
          {
        newReactant = new Product(r);
        reaction.addReactant(newReactant);
          }
        Product newProd;
        foreach (Product p in props.products)
          {
        newProd = new Product(p);
        reaction.addProduct(newProd);
          }
        return reaction;
    }
Esempio n. 7
0
 private bool loadInstantReactionReactant(XmlNode node, InstantReaction ir)
 {
     Product prod = new Product();
     foreach (XmlNode attr in node)
       {
     if (attr.Name == "name")
       {
         if (String.IsNullOrEmpty(attr.InnerText))
           Debug.Log("Warning : Empty name field in instant reaction reactant definition");
         prod.setName(attr.InnerText);
       }
     else if (attr.Name == "quantity")
       {
         if (String.IsNullOrEmpty(attr.InnerText))
           Debug.Log("Warning : Empty quantity field in instant reaction reactant definition");
         prod.setQuantityFactor(float.Parse(attr.InnerText.Replace(",", ".")));
       }
       }
     ir.addReactant(prod);
     return true;
 }
Esempio n. 8
0
  /*!
    \brief Build an Instant reaction with a InstantReactionProperties class
    \param props The properties
    \return Return a new reaction or null if it fail.
   */
  public static IReaction       buildInstantReactionFromProps(InstantReactionProperties props)
  {
    if (props == null)
      return null;

    InstantReaction reaction = new InstantReaction();

    reaction.setName(props.name);
    reaction.setEnergyCost(props.energyCost);
    Product newReactant;
    foreach (Product r in props.reactants)
      {
        newReactant = new Product(r);
        reaction.addReactant(newReactant);
      }
    Product newProd;
    foreach (Product p in props.products)
      {
        newProd = new Product(p);
        reaction.addProduct(newProd);
      }
    return reaction;
  }
Esempio n. 9
0
 //! Default constructor
 public InstantReaction(InstantReaction r)
     : base(r)
 {
     _reactants = r._reactants;
 }
Esempio n. 10
0
 //! Default constructor
 public InstantReaction(InstantReaction r) : base(r)
 {
     _reactants = r._reactants;
 }