Hostility Fix + Story Work
Fixed various bugs caused by triggering wormhole animation multiple times Sector -> Galaxy Fixed bug in hostility system; deserialized entities' PresencePermitted was silently throwing an exception (due to Faction being null during initialization) and thus never updating in response to security level changes Worked a bit on story processing
This commit is contained in:
parent
710d17ff4c
commit
2f98904614
26 changed files with 301 additions and 255 deletions
|
|
@ -10,22 +10,22 @@ public class LoadoutGenerator
|
|||
{
|
||||
public Random Random;
|
||||
public ItemManager ItemManager { get; }
|
||||
public Sector Sector { get; }
|
||||
public SectorZone Zone { get; }
|
||||
public Galaxy Galaxy { get; }
|
||||
public GalaxyZone Zone { get; }
|
||||
public Faction Faction { get; }
|
||||
public float PriceExponent { get; }
|
||||
|
||||
public LoadoutGenerator(
|
||||
ref Random random,
|
||||
ItemManager itemManager,
|
||||
Sector sector,
|
||||
SectorZone zone,
|
||||
Galaxy galaxy,
|
||||
GalaxyZone zone,
|
||||
Faction faction,
|
||||
float priceExponent)
|
||||
{
|
||||
Random = random;
|
||||
ItemManager = itemManager;
|
||||
Sector = sector;
|
||||
Galaxy = galaxy;
|
||||
Zone = zone;
|
||||
Faction = faction;
|
||||
PriceExponent = priceExponent;
|
||||
|
|
@ -107,12 +107,12 @@ public class LoadoutGenerator
|
|||
(hullFilter?.Invoke(item) ?? true) &&
|
||||
item.HullType == type &&
|
||||
item.Manufacturer != Guid.Empty &&
|
||||
(Sector?.ContainsFaction(item.Manufacturer) ?? true) &&
|
||||
(Galaxy?.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)]] ?? 1) / // Penalize distance to manufacturer headquarters
|
||||
(Zone?.Distance[Galaxy.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();
|
||||
|
|
@ -124,13 +124,13 @@ public class LoadoutGenerator
|
|||
.Where(item =>
|
||||
item.Price > 0 &&
|
||||
item.Manufacturer != Guid.Empty &&
|
||||
(Sector?.ContainsFaction(item.Manufacturer) ?? true) &&
|
||||
(Galaxy?.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)]] ?? 1) / // Penalize distance to manufacturer headquarters
|
||||
(Zone?.Distance[Galaxy.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
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue