Exemple #1
0
        /// <summary>
        /// Adds a requirement to the given <see cref="global::Tech"/>
        /// </summary>
        /// <param name="unlocked">The tech that will be unlocked</param>
        /// <param name="required">The tech that is required</param>
        public static void AddRequirement(global::Tech unlocked, global::Tech required)
        {
            required.unlockedTech.Add(unlocked);
            unlocked.requiredTech.Add(required);

            SetTier(unlocked, required.tier + 1);

            var unlockedNode = GetNode(unlocked);
            var requiredNode = GetNode(required);
            var edge         = new ResourceTreeNode.Edge(requiredNode, unlockedNode, ResourceTreeNode.Edge.EdgeType.GenericEdge);

            unlockedNode.edges.Add(edge);
            requiredNode.edges.Add(edge);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new <see cref="global::Tech"/> with the given ID
        /// </summary>
        /// <param name="id">The ID to create with</param>
        /// <returns>The newly created tech</returns>
        public static global::Tech CreateTech(string id)
        {
            string locname      = LOCNAME_TECH + id.ToUpper();
            var    existingTech = Instance.Techs.TryGet(id);

            if (existingTech != null)
            {
                return(existingTech);
            }
            else
            {
                var tech = new global::Tech(id, Instance.Techs, Strings.Get(locname + ".NAME"), Strings.Get(locname + ".DESC"), new ResourceTreeNode()
                {
                    nodeX  = ORIGIN.nodeX,
                    nodeY  = ORIGIN.nodeY,
                    width  = ORIGIN.width,
                    height = ORIGIN.height
                });
                Techs.TECH_GROUPING.Add(id, new string[0]);
                return(tech);
            }
        }
Exemple #3
0
 private int GetCol(global::Tech tech)
 {
     return(tech.tier);
 }
Exemple #4
0
 private int GetRow(global::Tech tech, Dictionary <string, int> rows)
 {
     return(tech.requiredTech.Count > 0
         ? GetRow(tech.requiredTech[0], rows)
         : rows[tech.Id]);
 }
Exemple #5
0
 private static ResourceTreeNode GetNode(global::Tech tech)
 {
     return((ResourceTreeNode)Harmony.Traverse.Create(tech).Field("node").GetValue());
 }
Exemple #6
0
 /// <summary>
 /// Overrides the tier of a given <see cref="global::Tech"/> to the given value
 /// </summary>
 /// <param name="tech">The tech</param>
 /// <param name="tier">The tier to set</param>
 public static void SetTier(global::Tech tech, int tier)
 {
     tech.tier = tier;
     tech.costsByResearchTypeID = GetTierCosts(tier);
 }