예제 #1
0
        private TreeNode CreateNode(TreeView parent, IMobileSpaceObject v)
        {
            var node = parent.AddItemWithImage(v.Name, v, v.Icon);

            if (v is Fleet)
            {
                foreach (var sub in ((Fleet)v).Vehicles)
                {
                    CreateNode(node, sub);
                }
            }
            return(node);
        }
예제 #2
0
        private void PopulateSomeoneHas(Empire emp, TreeView tree, Package package)
        {
            tree.Initialize(32);

            // treaty clauses
            var treatyNode = tree.AddItemWithImage("Treaty Clauses", "Treaty Clauses", emp.Icon);

            if (!package.TreatyClauses.OfType <AllianceClause>().Any())
            {
                var allianceNode = treatyNode.AddItemWithImage("Alliances", "Alliances", emp.Icon);
                foreach (AllianceLevel alliance in Enum.GetValues(typeof(AllianceLevel)))
                {
                    if (alliance != AllianceLevel.None)
                    {
                        var clause = new AllianceClause(package.Owner, package.Recipient, alliance);
                        allianceNode.AddItemWithImage(clause.BriefDescription, clause, null);
                    }
                }
            }
            if (!package.TreatyClauses.OfType <CooperativeResearchClause>().Any())
            {
                var clause = new CooperativeResearchClause(package.Owner, package.Recipient);
                treatyNode.AddItemWithImage(clause.BriefDescription, clause, null);
            }
            var freeTradeNode = treatyNode.AddItemWithImage("Free Trade", "Free Trade", Resource.Minerals.Icon);

            foreach (var res in Resource.All.Where(res => res.IsGlobal && !package.TreatyClauses.OfType <FreeTradeClause>().Any(c => c.Resource == res)))
            {
                var clause = new FreeTradeClause(package.Owner, package.Recipient, res);
                freeTradeNode.AddItemWithImage(res.Name, clause, res.Icon);
            }
            var abilNode = treatyNode.AddItemWithImage("Ability Sharing", "Ability Sharing", null);

            foreach (var abil in Mod.Current.AbilityRules.Where(abil =>
                                                                (abil.CanTarget(AbilityTargets.Sector) || abil.CanTarget(AbilityTargets.StarSystem) || abil.CanTarget(AbilityTargets.Galaxy)) &&
                                                                !package.TreatyClauses.OfType <ShareAbilityClause>().Any(c => c.AbilityRule == abil)))
            {
                var clause = new ShareAbilityClause(package.Owner, package.Recipient, abil, SharingPriority.Medium);
                abilNode.AddItemWithImage(abil.Name, clause, null);
            }
            if (!package.TreatyClauses.OfType <ShareCombatLogsClause>().Any())
            {
                var clause = new ShareCombatLogsClause(package.Owner, package.Recipient);
                treatyNode.AddItemWithImage(clause.BriefDescription, clause, null);
            }
            if (!package.TreatyClauses.OfType <ShareDesignsClause>().Any())
            {
                var clause = new ShareDesignsClause(package.Owner, package.Recipient);
                treatyNode.AddItemWithImage(clause.BriefDescription, clause, null);
            }
            if (!package.TreatyClauses.OfType <ShareVisionClause>().Any())
            {
                var clause = new ShareVisionClause(package.Owner, package.Recipient);
                treatyNode.AddItemWithImage(clause.BriefDescription, clause, null);
            }
            var tributeNode = treatyNode.AddItemWithImage("Tribute", "Tribute", Resource.Minerals.Icon);

            foreach (var res in Resource.All.Where(res => res.IsGlobal && !package.TreatyClauses.OfType <FreeTradeClause>().Any(c => c.Resource == res)))
            {
                var clause = new TributeClause(package.Owner, package.Recipient, res, 10, true);
                tributeNode.AddItemWithImage(res.Name, clause, res.Icon);
            }

            // sort planets alphabetically
            var planetsNode = tree.AddItemWithImage("Planets", "Planets", Pictures.GetGenericImage(typeof(Planet)));

            foreach (var p in emp.ColonizedPlanets.Where(p => !package.Planets.Contains(p)).OrderBy(p => p.Name))
            {
                planetsNode.AddItemWithImage(p.Name, p, p.Icon);
            }

            // sort vehicles descending by size, then alphabetically
            // no trading units that are in cargo
            var vehiclesNode = tree.AddItemWithImage("Vehicles", "Vehicles", Pictures.GetVehicleTypeImage(emp.ShipsetPath, VehicleTypes.Ship));

            foreach (var v in emp.OwnedSpaceObjects.OfType <SpaceVehicle>().Where(v => !package.Vehicles.Contains(v) && !(v is IUnit && ((IUnit)v).Container is ISpaceObject)).OrderByDescending(v => v.Design.Hull.Size).ThenBy(v => v.Name))
            {
                vehiclesNode.AddItemWithImage(v.Name, v, v.Icon);
            }

            // resources
            var resourcesNode = tree.AddItemWithImage("Resources", "Resources", Resource.Minerals.Icon);

            foreach (var r in Resource.All.Where(r => r.IsGlobal))
            {
                resourcesNode.AddItemWithImage(emp.StoredResources[r].ToUnitString(true) + " " + r, r, r.Icon);
            }

            // technology
            var techNode = tree.AddItemWithImage("Technology", "Technology", Resource.Research.Icon);

            foreach (var kvp in emp.ResearchedTechnologies.Where(kvp => kvp.Value > 0))
            {
                techNode.AddItemWithImage(kvp.Key.Name + " level " + kvp.Value, kvp.Key, kvp.Key.Icon);
            }

            // star charts
            var chartsNode = tree.AddItemWithImage("Star Charts", "Star Charts", Pictures.GetGenericImage(typeof(StarSystem)));

            foreach (var sys in emp.ExploredStarSystems.Where(sys => !package.StarCharts.Contains(sys)))
            {
                chartsNode.AddItemWithImage(sys.Name, sys, sys.Icon);
            }

            // comms channels
            var commsNode = tree.AddItemWithImage("Communications Channels", "Communications Channels", Pictures.GetGenericImage(typeof(Empire)));

            foreach (var ee in emp.EncounteredEmpires.Where(ee => !package.CommunicationChannels.Contains(ee)))
            {
                commsNode.AddItemWithImage(ee.Name, ee, ee.Icon);
            }
        }