Ejemplo n.º 1
0
        public void AddToDescriptionBuffer(GameEntity_Squad RelatedEntityOrNull, GameEntityTypeData RelatedEntityTypeData, ArcenDoubleCharacterBuffer Buffer)
        {
            // Make sure we are getting an entity.
            if (RelatedEntityOrNull == null)
            {
                return;
            }
            // Load our cargo data.
            CivilianCargo cargoData = RelatedEntityOrNull.GetCivilianCargoExt();

            SpecialFaction_SKCivilianIndustry civFaction;

            if (RelatedEntityOrNull.PlanetFaction.Faction.Implementation is SpecialFaction_SKCivilianIndustry)
            {
                civFaction = (SpecialFaction_SKCivilianIndustry)RelatedEntityOrNull.PlanetFaction.Faction.Implementation;
            }
            else
            {
                civFaction = (SpecialFaction_SKCivilianIndustry)SpecialFaction_SKCivilianIndustry.GetFriendlyIndustry(RelatedEntityOrNull.PlanetFaction.Faction).Implementation;
            }

            // Inform them about what the station has on it.
            for (int x = 0; x < cargoData.Amount.Length; x++)
            {
                if (civFaction.IgnoreResource[x])
                {
                    if (cargoData.PerSecond[x] != 0)
                    {
                        Buffer.StartColor(CivilianResourceHexColors.Color[x]);
                        Buffer.Add("\n" + ((CivilianResource)x).ToString());
                        Buffer.EndColor();
                        Buffer.StartColor(UnityEngine.Color.red);
                        Buffer.Add(" is produced here but currently ignored due to tech level.");
                        Buffer.EndColor();
                    }
                }
                else
                {
                    Buffer.StartColor(CivilianResourceHexColors.Color[x]);
                    if (cargoData.Amount[x] > 0 || cargoData.PerSecond[x] != 0)
                    {
                        Buffer.Add($"\n{cargoData.Amount[x]}/{cargoData.Capacity[x]} {(CivilianResource)x}");
                    }
                    Buffer.EndColor();
                    // If resource has generation or drain, notify them.
                    if (cargoData.PerSecond[x] > 0)
                    {
                        int income = cargoData.PerSecond[x] + RelatedEntityOrNull.CurrentMarkLevel;
                        Buffer.Add($" +{income} per second");
                    }
                }
            }

            // Add in an empty line to stop any other gunk (such as the fleet display) from messing up our given information.
            Buffer.Add("\n");
            return;
        }
        public void AddToDescriptionBuffer(GameEntity_Squad RelatedEntityOrNull, GameEntityTypeData RelatedEntityTypeData, ArcenDoubleCharacterBuffer Buffer)
        {
            // Make sure we are getting an entity.
            if (RelatedEntityOrNull == null)
            {
                return;
            }

            // Load our cargo data.
            CivilianCargo cargoData = RelatedEntityOrNull.GetCivilianCargoExt();
            // Load our status data.
            CivilianStatus shipStatus = RelatedEntityOrNull.GetCivilianStatusExt();
            // Load our faction data.
            CivilianFaction factionData = RelatedEntityOrNull.PlanetFaction.Faction.GetCivilianFactionExt();

            // Inform them what the ship is currently doing.
            Buffer.Add("\nThis ship is currently ");
            // Idle
            if (factionData.CargoShipsIdle.Contains(RelatedEntityOrNull.PrimaryKeyID))
            {
                Buffer.Add("Idle.");
            }
            // Pathing
            if (factionData.CargoShipsPathing.Contains(RelatedEntityOrNull.PrimaryKeyID))
            {
                Buffer.Add("Pathing");
                GameEntity_Squad target = World_AIW2.Instance.GetEntityByID_Squad(shipStatus.Origin);
                if (target != null)
                {
                    Buffer.Add(" towards " + target.TypeData.DisplayName + " on " + target.Planet.Name);
                }
                Buffer.Add(".");
            }
            // Loading
            if (factionData.CargoShipsLoading.Contains(RelatedEntityOrNull.PrimaryKeyID))
            {
                Buffer.Add("Loading resources");
                GameEntity_Squad target = World_AIW2.Instance.GetEntityByID_Squad(shipStatus.Origin);
                if (target != null)
                {
                    Buffer.Add(" from " + target.TypeData.DisplayName + " on " + target.Planet.Name);
                }
                Buffer.Add(".");
                if (shipStatus.LoadTimer > 0)
                {
                    Buffer.Add(" It will automatically depart after " + shipStatus.LoadTimer + " seconds");
                }
                GameEntity_Squad target2 = World_AIW2.Instance.GetEntityByID_Squad(shipStatus.Destination);
                if (target2 != null)
                {
                    Buffer.Add(" and head towards " + target2.TypeData.DisplayName + " on " + target2.Planet.Name);
                }
                Buffer.Add(".");
            }
            // Enroute
            if (factionData.CargoShipsEnroute.Contains(RelatedEntityOrNull.PrimaryKeyID))
            {
                Buffer.Add("Enroute");
                GameEntity_Squad target = World_AIW2.Instance.GetEntityByID_Squad(shipStatus.Destination);
                if (target != null)
                {
                    Buffer.Add(" towards " + target.TypeData.DisplayName + " on " + target.Planet.Name);
                }
                Buffer.Add(".");
            }
            // Unloading
            if (factionData.CargoShipsUnloading.Contains(RelatedEntityOrNull.PrimaryKeyID))
            {
                Buffer.Add("Unloading resources");
                GameEntity_Squad target = World_AIW2.Instance.GetEntityByID_Squad(shipStatus.Destination);
                if (target != null)
                {
                    Buffer.Add(" onto " + target.TypeData.DisplayName + " on " + target.Planet.Name);
                }
                Buffer.Add(".");
            }
            // Building
            if (factionData.CargoShipsBuilding.Contains(RelatedEntityOrNull.PrimaryKeyID))
            {
                Buffer.Add("Building forces");
                GameEntity_Squad target = World_AIW2.Instance.GetEntityByID_Squad(shipStatus.Destination);
                if (target != null)
                {
                    Buffer.Add(" at " + target.TypeData.DisplayName + " on " + target.Planet.Name);
                }
                Buffer.Add(".");
            }

            // Inform them about what the ship has on it.
            for (int x = 0; x < cargoData.Amount.Length; x++)
            {
                if (cargoData.Amount[x] > 0)
                {
                    Buffer.StartColor(CivilianResourceHexColors.Color[x]);
                    Buffer.Add($"\n{cargoData.Amount[x]}/{cargoData.Capacity[x]} {((CivilianResource)x).ToString()}");
                    Buffer.EndColor();
                }
            }
            // Add in an empty line to stop any other gunk (such as the fleet display) from messing up our given information.
            Buffer.Add("\n");
            return;
        }
Ejemplo n.º 3
0
        public void AddToDescriptionBuffer(GameEntity_Squad RelatedEntityOrNull, GameEntityTypeData RelatedEntityTypeData, ArcenDoubleCharacterBuffer Buffer)
        {
            // Make sure we are getting an entity.
            if (RelatedEntityOrNull == null)
            {
                return;
            }
            // Load our militia data
            CivilianMilitia militiaData = RelatedEntityOrNull.GetCivilianMilitiaExt();
            CivilianCargo   cargoData   = RelatedEntityOrNull.GetCivilianCargoExt();

            CivilianFaction factionData = RelatedEntityOrNull.PlanetFaction.Faction.GetCivilianFactionExt();

            if (factionData == null)
            {
                return;
            }

            // Inform them about any focus the ship may have.
            GameEntity_Squad centerpiece = World_AIW2.Instance.GetEntityByID_Squad(militiaData.Centerpiece);

            if (centerpiece != null && centerpiece.PrimaryKeyID != RelatedEntityOrNull.PrimaryKeyID)
            {
                Buffer.Add(" This structure is producing ships for " + centerpiece.FleetMembership.Fleet.GetName() + " on the planet " + centerpiece.Planet.Name + ".");
            }
            else
            {
                Planet targetPlanet = World_AIW2.Instance.GetPlanetByIndex(militiaData.PlanetFocus);
                if (targetPlanet != null)
                {
                    Buffer.Add($" This ship's planetary focus is {targetPlanet.Name}");
                }
                else
                {
                    Buffer.Add(" This ship is currently waiting for a protection request.");
                }
            }

            if (militiaData.Ships.Count > 0)
            {
                for (int x = 0; x < (int)CivilianResource.Length; x++)
                {
                    GameEntityTypeData entityData = GameEntityTypeDataTable.Instance.GetRowByName(militiaData.ShipTypeData[x], false, null);

                    if (entityData == null)
                    {
                        continue;
                    }

                    int count = militiaData.GetShipCount(entityData.InternalName);
                    Buffer.Add($"\n{entityData.DisplayName}:");
                    Buffer.StartColor(UnityEngine.Color.green);
                    Buffer.Add($" {count}/{militiaData.ShipCapacity[x]}");
                    Buffer.EndColor();
                    Buffer.StartColor(CivilianResourceHexColors.Color[x]);
                    Buffer.Add($" ({(CivilianResource)x})");
                    Buffer.EndColor();

                    int cost;
                    if (RelatedEntityOrNull.TypeData.GetHasTag("BuildsProtectors"))
                    {
                        cost = (int)(12000 * SpecialFaction_SKCivilianIndustry.CostIntensityModifier(RelatedEntityOrNull.PlanetFaction.Faction));
                    }
                    else
                    {
                        double countCostModifier = 1.0 + (1.0 - ((militiaData.ShipCapacity[x] - count + 1.0) / militiaData.ShipCapacity[x]));
                        int    baseCost          = entityData.CostForAIToPurchase;
                        cost = (int)(SpecialFaction_SKCivilianIndustry.CostIntensityModifier(RelatedEntityOrNull.PlanetFaction.Faction) * (baseCost * countCostModifier * (militiaData.CostMultiplier / 100.0)));
                    }

                    if (count < militiaData.ShipCapacity[x])
                    {
                        double perc = Math.Min(100, 100.0 * (1.0 * cargoData.Amount[x] / cost));
                        Buffer.Add($" {perc.ToString("0.##")}% (Building)");
                    }
                    else
                    {
                        double perc = Math.Min(100, 100.0 * (1.0 * cargoData.Amount[x] / cargoData.Capacity[x]));
                        Buffer.Add($" {perc.ToString("0.##")}% (Stockpiling)");
                    }
                    Buffer.EndColor();
                }
            }

            // Add in an empty line to stop any other gunk (such as the fleet display) from messing up our given information.
            Buffer.Add("\n");
            return;
        }