Playability
Fixed loadout generator tutorial edge cases Recreated missing items Created field shader & test scene
This commit is contained in:
parent
69aca09f63
commit
47e500e1ce
72 changed files with 3579 additions and 693 deletions
|
|
@ -38,6 +38,21 @@ public static class AetheriaMath
|
|||
return lerp(a, b, 1 - exp(-lambda * dt));
|
||||
}
|
||||
|
||||
public static double Damp(double a, double b, double lambda, double dt)
|
||||
{
|
||||
return lerp(a, b, 1 - exp(-lambda * dt));
|
||||
}
|
||||
|
||||
public static double2 Damp(double2 a, double2 b, double2 lambda, double2 dt)
|
||||
{
|
||||
return lerp(a, b, 1 - exp(-lambda * dt));
|
||||
}
|
||||
|
||||
public static double3 Damp(double3 a, double3 b, double3 lambda, double3 dt)
|
||||
{
|
||||
return lerp(a, b, 1 - exp(-lambda * dt));
|
||||
}
|
||||
|
||||
//first-order intercept using absolute target position
|
||||
public static float3 FirstOrderIntercept
|
||||
(
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ using static Unity.Mathematics.math;
|
|||
[Serializable, MessagePackObject, JsonObject]
|
||||
public class ExponentialCurve
|
||||
{
|
||||
[JsonProperty("exponent"), Key(0)]
|
||||
[JsonProperty("exponent"), Key(0), Inspectable]
|
||||
public float Exponent;
|
||||
|
||||
[JsonProperty("multiplier"), Key(1)]
|
||||
[JsonProperty("multiplier"), Key(1), Inspectable]
|
||||
public float Multiplier;
|
||||
|
||||
[JsonProperty("constant"), Key(2)]
|
||||
[JsonProperty("constant"), Key(2), Inspectable]
|
||||
public float Constant;
|
||||
|
||||
public float Evaluate(float value) => Multiplier * pow(value, Exponent) + Constant;
|
||||
|
|
@ -28,13 +28,13 @@ public class ExponentialCurve
|
|||
[Serializable, MessagePackObject, JsonObject]
|
||||
public class ExponentialLerp
|
||||
{
|
||||
[JsonProperty("exponent"), Key(0)]
|
||||
[JsonProperty("exponent"), Key(0), Inspectable]
|
||||
public float Exponent;
|
||||
|
||||
[JsonProperty("max"), Key(1)]
|
||||
[JsonProperty("max"), Key(1), Inspectable]
|
||||
public float Minimum;
|
||||
|
||||
[JsonProperty("min"), Key(2)]
|
||||
[JsonProperty("min"), Key(2), Inspectable]
|
||||
public float Maximum;
|
||||
|
||||
public float Evaluate(float value) => Minimum + pow(saturate(value), Exponent) * (Maximum - Minimum);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,12 @@ public class Galaxy
|
|||
public GalaxyZone Exit { get; }
|
||||
public Dictionary<Faction, FactionRelationship> FactionRelationships { get; } = new Dictionary<Faction, FactionRelationship>();
|
||||
private Action<string> Log { get; }
|
||||
|
||||
public bool IsPrelude { get; }
|
||||
|
||||
private HashSet<Guid> _containedFactions;
|
||||
private GalaxyZone[] _exitPath;
|
||||
private Dictionary<Faction, MarkovNameGenerator> _nameGenerators = new Dictionary<Faction, MarkovNameGenerator>();
|
||||
private readonly CultCache _cache;
|
||||
|
||||
public GalaxyZone[] ExitPath
|
||||
{
|
||||
|
|
@ -44,6 +46,8 @@ public class Galaxy
|
|||
|
||||
public Galaxy(CultCache cultCache, SavedGame savedGame, Action<string> log)
|
||||
{
|
||||
IsPrelude = savedGame.IsTutorial;
|
||||
_cache = cultCache;
|
||||
Log = log;
|
||||
Background = savedGame.Background;
|
||||
|
||||
|
|
@ -94,6 +98,8 @@ public class Galaxy
|
|||
Action<string> progressCallback = null,
|
||||
uint seed = 0)
|
||||
{
|
||||
_cache = cache;
|
||||
IsPrelude = false;
|
||||
Background = background;
|
||||
Log = log;
|
||||
var factions = cache.GetAll<Faction>();
|
||||
|
|
@ -125,6 +131,11 @@ public class Galaxy
|
|||
progressCallback?.Invoke("Done!");
|
||||
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
}
|
||||
|
||||
public Faction ResolveFaction(string name)
|
||||
{
|
||||
return _cache.GetAll<Faction>().FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
public Galaxy(
|
||||
TutorialGenerationSettings settings,
|
||||
|
|
@ -137,7 +148,8 @@ public class Galaxy
|
|||
Action<string> progressCallback = null,
|
||||
uint seed = 0)
|
||||
{
|
||||
Faction ResolveFaction(string name) => cache.GetAll<Faction>().FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
|
||||
_cache = cache;
|
||||
IsPrelude = true;
|
||||
|
||||
Background = background;
|
||||
Log = log;
|
||||
|
|
|
|||
|
|
@ -30,18 +30,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 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)
|
||||
{
|
||||
|
|
@ -86,7 +86,6 @@ public class LoadoutGenerator
|
|||
var hull = ItemManager.CreateInstance(hullData) as EquippableItem;
|
||||
var entity = new OrbitalEntity(ItemManager, null, hull, Guid.Empty, ItemManager.GameplaySettings.DefaultEntitySettings);
|
||||
entity.Faction = Faction;
|
||||
OutfitEntity(entity);
|
||||
|
||||
var emptyShape = entity.UnoccupiedSpace;
|
||||
|
||||
|
|
@ -100,6 +99,8 @@ public class LoadoutGenerator
|
|||
{
|
||||
throw new InvalidLoadoutException("Failed to equip selected docking bay!");
|
||||
}
|
||||
|
||||
OutfitEntity(entity);
|
||||
|
||||
var cargo = entity.CargoBays.First();
|
||||
IEnumerable<EquippableItemData> inventory = RandomItems<EquippableItemData>(16, 1,
|
||||
|
|
@ -119,21 +120,9 @@ public class LoadoutGenerator
|
|||
|
||||
public HullData RandomHull(HullType type, Predicate<HullData> hullFilter = null)
|
||||
{
|
||||
return ItemManager.ItemData.GetAll<HullData>()
|
||||
.Where(item =>
|
||||
item.Price > 0 &&
|
||||
return RandomItem<HullData>(0, item =>
|
||||
(hullFilter?.Invoke(item) ?? true) &&
|
||||
item.HullType == type &&
|
||||
item.Manufacturer != Guid.Empty &&
|
||||
(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[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();
|
||||
item.HullType == type);
|
||||
}
|
||||
|
||||
public T[] RandomItems<T>(int count, float sizeExponent, Predicate<T> filter = null) where T : EquippableItemData
|
||||
|
|
@ -142,13 +131,14 @@ public class LoadoutGenerator
|
|||
.Where(item =>
|
||||
item.Price > 0 &&
|
||||
item.Manufacturer != Guid.Empty &&
|
||||
(Galaxy?.ContainsFaction(item.Manufacturer) ?? true) &&
|
||||
(Faction == null || Faction.Allegiance.ContainsKey(item.Manufacturer)) &&
|
||||
(Galaxy.IsPrelude || Galaxy.ContainsFaction(item.Manufacturer) &&
|
||||
(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
|
||||
Faction == null ? 1 :
|
||||
(item.Manufacturer == Faction.ID ? 1 : Faction.Allegiance.ContainsKey(item.Manufacturer) ? Faction.Allegiance[item.Manufacturer] : 0.0f / // Prioritize items from allied manufacturers
|
||||
(Galaxy?.ContainsFaction(item.Manufacturer) ?? false ? Zone?.Distance[Galaxy.HomeZones[ItemManager.ItemData.Get<Faction>(item.Manufacturer)]] ?? 1 : 1)) * // Penalize distance to manufacturer headquarters
|
||||
pow(item.Shape.Coordinates.Length, sizeExponent) / // Prioritize larger items
|
||||
(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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -245,9 +245,7 @@ public static class ZoneGenerator
|
|||
LoadoutGenerator GetLoadoutGenerator(Faction faction)
|
||||
{
|
||||
if (!loadoutGenerators.ContainsKey(faction))
|
||||
loadoutGenerators[faction] = isTutorial
|
||||
? new LoadoutGenerator(ref random, itemManager, faction, .5f)
|
||||
: new LoadoutGenerator(ref random, itemManager, galaxy, galaxyZone, faction, .5f);
|
||||
loadoutGenerators[faction] = new LoadoutGenerator(ref random, itemManager, galaxy, galaxyZone, faction, .5f);
|
||||
return loadoutGenerators[faction];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue