コード例 #1
0
        /// <summary>
        /// Gibt eine tiefe Kopie dieses Objekts zurück.
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            // Erstmal alle Wert-Typen kopieren
            Research clone = (Research)this.MemberwiseClone();

            // Referenztypen kopieren
            clone.RequiredTechs = new List <short>(RequiredTechs);
            clone.ResourceCosts = new List <ResourceTuple <short, short, byte> >(ResourceCosts);          // Ressourcen-Kosten sind Strukturen und damit Werttypen

            // Fertig
            return(clone);
        }
コード例 #2
0
        /// <summary>
        /// Writes the modifications into the given genie research.
        /// </summary>
        /// <param name="researchData">The genie research to be modified.</param>
        public void WriteChangesToGenieResearch(DataElements.Research researchData)
        {
            // Apply all modified members
            if (ResearchTime?.Modified ?? false)
            {
                researchData.ResearchTime = ResearchTime;
            }
            if (Cost1?.Modified ?? false)
            {
                researchData.ResourceCosts[0] = new GenieLibrary.IGenieDataElement.ResourceTuple <short, short, byte>
                {
                    Amount = Cost1.Value.Amount,
                    Mode   = Cost1.Value.Paid,
                    Type   = Cost1.Value.ResourceType
                }
            }
            ;
            if (Cost2?.Modified ?? false)
            {
                researchData.ResourceCosts[1] = new GenieLibrary.IGenieDataElement.ResourceTuple <short, short, byte>
                {
                    Amount = Cost2.Value.Amount,
                    Mode   = Cost2.Value.Paid,
                    Type   = Cost2.Value.ResourceType
                }
            }
            ;
            if (Cost3?.Modified ?? false)
            {
                researchData.ResourceCosts[2] = new GenieLibrary.IGenieDataElement.ResourceTuple <short, short, byte>
                {
                    Amount = Cost3.Value.Amount,
                    Mode   = Cost3.Value.Paid,
                    Type   = Cost3.Value.ResourceType
                }
            }
            ;
        }

        #endregion
    }
}