Beispiel #1
0
        public override void PostSpawnSetup(bool respawningAfterLoad)
        {
            base.PostSpawnSetup(respawningAfterLoad);
            if (!respawningAfterLoad)
            {
                upgradeList = new List <UpgradeNode>();
                foreach (UpgradeNode node in Props.upgradesAvailable)
                {
                    UpgradeNode permanentNode = new UpgradeNode(node);
                    permanentNode.InitializeLists();
                    upgradeList.Add(permanentNode);
                }

                if (upgradeList.Select(x => x.upgradeID).GroupBy(y => y).Where(y => y.Count() > 1).Select(z => z.Key).Any())
                {
                    Log.Error(string.Format("Duplicate UpgradeID's detected on def {0}. This is not supported.", parent.def.defName));
                    if (Prefs.DevMode)
                    {
                        Log.Message("====== Duplicate UpgradeID's for this Boat ======");
                        foreach (UpgradeNode errorNode in upgradeList.GroupBy(grp => grp).SelectMany(n => n.Skip(1)))
                        {
                            Log.Message($"UpgradeID: {errorNode.upgradeID} UniqueID: {errorNode.GetUniqueLoadID()} Location: {errorNode.gridCoordinate}");
                        }
                        Log.Message("===========================================");
                    }
                }
            }
        }
Beispiel #2
0
        public UpgradeNode RootNode(UpgradeNode child)
        {
            UpgradeNode parentOfChild = child;

            while (parentOfChild.prerequisiteNodes.Any())
            {
                parentOfChild = upgradeList.Find(x => x.upgradeID == parentOfChild.prerequisiteNodes.First());
            }
            return(parentOfChild);
        }
Beispiel #3
0
        public UpgradeNode(UpgradeNode reference)
        {
            nodeID = Find.UniqueIDsManager.GetNextThingID();

            label                       = reference.label;
            upgradeID                   = reference.upgradeID;
            rootNodeLabel               = reference.rootNodeLabel;
            informationHighlighted      = reference.informationHighlighted;
            disableIfUpgradeNodeEnabled = reference.disableIfUpgradeNodeEnabled;
            upgradeCategory             = reference.upgradeCategory;
            values                      = reference.values;
            cannonsUnlocked             = reference.cannonsUnlocked;
            cost = reference.cost;
            researchPrerequisites = reference.researchPrerequisites;
            prerequisiteNodes     = reference.prerequisiteNodes;
            imageFilePath         = reference.imageFilePath;
            gridCoordinate        = reference.gridCoordinate;
            upgradeTime           = reference.upgradeTime;
        }
Beispiel #4
0
 public void StartUnlock(UpgradeNode node)
 {
     nodeUnlocking = upgradeList.Find(x => x.upgradeID == node.upgradeID);
     nodeUnlocking.ResetTimer();
 }
Beispiel #5
0
 public bool Disabled(UpgradeNode node)
 {
     return(!string.IsNullOrEmpty(node.disableIfUpgradeNodeEnabled) && upgradeList.FirstOrDefault(x => x.upgradeID == node.disableIfUpgradeNodeEnabled).upgradeActive);
 }
Beispiel #6
0
 public bool PrerequisitesMet(UpgradeNode node)
 {
     return(upgradeList.Where(x => node.prerequisiteNodes.Contains(x.upgradeID)).All(y => y.upgradeActive));
 }
Beispiel #7
0
 public bool Equals(UpgradeNode u)
 {
     return(upgradeID == u.upgradeID);
 }