Mini Galaxy Gen

Added flags to game manager and player settings to check tutorial status
Created alternate galaxy generation process for tutorial
This commit is contained in:
Reinier Vens 2021-04-22 02:53:06 +01:00
commit b1bd89a687
224 changed files with 423 additions and 208 deletions

View file

@ -29,6 +29,18 @@ public class LoadoutGenerator
Faction = faction;
PriceExponent = priceExponent;
}
public LoadoutGenerator(
ref Random random,
ItemManager itemManager,
Faction faction,
float priceExponent)
{
Random = random;
ItemManager = itemManager;
Faction = faction;
PriceExponent = priceExponent;
}
public EntityPack GenerateShipLoadout(Predicate<HullData> hullFilter = null)
{
@ -89,12 +101,14 @@ public class LoadoutGenerator
.Where(item =>
item.Price > 0 &&
(hullFilter?.Invoke(item) ?? true) &&
item.HullType == type &&
item.HullType == type &&
item.Manufacturer != Guid.Empty &&
(Sector?.ContainsFaction(item.Manufacturer) ?? true) &&
(Faction == null || item.Manufacturer == Faction.ID || Faction.Allegiance.ContainsKey(item.Manufacturer)))
.WeightedRandomElements(ref Random,
item =>
(Faction == null || item.Manufacturer == Faction.ID ? 1 : Faction.Allegiance[item.Manufacturer]) / // Prioritize items from allied manufacturers
Zone.Distance[Sector.HomeZones[ItemManager.ItemData.Get<Faction>(item.Manufacturer)]] / // Penalize distance to manufacturer headquarters
(Zone?.Distance[Sector.HomeZones[ItemManager.ItemData.Get<Faction>(item.Manufacturer)]] ?? 1) / // Penalize distance to manufacturer headquarters
pow(item.Price, PriceExponent), // Penalize item price to a controllable degree
1
).FirstOrDefault();
@ -104,14 +118,15 @@ public class LoadoutGenerator
{
return ItemManager.ItemData.GetAll<T>()
.Where(item =>
item.Price > 0 &&
Sector.ContainsFaction(item.Manufacturer) &&
item.Price > 0 &&
item.Manufacturer != Guid.Empty &&
(Sector?.ContainsFaction(item.Manufacturer) ?? true) &&
(Faction == null || Faction.Allegiance.ContainsKey(item.Manufacturer)) &&
(filter?.Invoke(item) ?? true))
.WeightedRandomElements(ref Random, item =>
(Faction == null || item.Manufacturer == Faction.ID ? 1 : Faction.Allegiance[item.Manufacturer]) * // Prioritize items from allied manufacturers
pow(item.Shape.Coordinates.Length, sizeExponent) / // Prioritize larger items
Zone.Distance[Sector.HomeZones[ItemManager.ItemData.Get<Faction>(item.Manufacturer)]] / // Penalize distance to manufacturer headquarters
(Zone?.Distance[Sector.HomeZones[ItemManager.ItemData.Get<Faction>(item.Manufacturer)]] ?? 1) / // Penalize distance to manufacturer headquarters
pow(item.Price, PriceExponent), // Penalize item price to a controllable degree
count
);