Production/Demand Profiles and Blueprint Resource Requirements
Added the ability to associate blueprints and compound commodities with personality attributes Added the ability to restrict blueprints according to the presence of resources, for resource harvesting infrastructure Improved the properties panel UI for Sector and Tech tabs
This commit is contained in:
parent
98937c4b87
commit
35fb4381ed
16 changed files with 769 additions and 263 deletions
|
|
@ -50,6 +50,12 @@ public class BlueprintData : DatabaseEntry, INamedEntry
|
|||
|
||||
[InspectableDatabaseLink(typeof(CraftedItemData)), JsonProperty("factoryItem"), Key(14)]
|
||||
public Guid FactoryItem;
|
||||
|
||||
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("resourceRequirements"), Key(15)]
|
||||
public Dictionary<Guid, int> ResourceRequirements = new Dictionary<Guid, int>();
|
||||
|
||||
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("productionProfile"), Key(16)]
|
||||
public Dictionary<Guid, float> ProductionProfile = new Dictionary<Guid, float>();
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
|
|
@ -64,16 +70,16 @@ public class BlueprintStatEffect
|
|||
[InspectableField, JsonProperty("ingredient"), Key(1)]
|
||||
public Guid Ingredient;
|
||||
|
||||
[InspectableField, JsonProperty("stat"), Key(2)]
|
||||
[InspectableField, JsonProperty("stat"), Key(2)]
|
||||
public StatReference StatReference = new StatReference();
|
||||
}
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class StatReference
|
||||
{
|
||||
[InspectableType(typeof(IBehaviorData)), JsonProperty("behavior"), Key(1)]
|
||||
[InspectableType(typeof(IBehaviorData)), JsonProperty("behavior"), Key(1)]
|
||||
public string Behavior;
|
||||
|
||||
[InspectableField, JsonProperty("stat"), Key(2)]
|
||||
[InspectableField, JsonProperty("stat"), Key(2)]
|
||||
public string Stat;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ public interface INamedEntry
|
|||
Union(14, typeof(StationData)),
|
||||
Union(15, typeof(OrbitData)),
|
||||
Union(16, typeof(PlanetData)),
|
||||
Union(17, typeof(PersonalityAttribute)),
|
||||
// Union(17, typeof(ShipData)),
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
|
||||
//[Union(21, typeof(ContractData))]
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ public enum HardpointType
|
|||
Energy,
|
||||
Ballistic,
|
||||
Launcher,
|
||||
Infrastructure
|
||||
Infrastructure,
|
||||
ControlModule
|
||||
}
|
||||
|
||||
public enum DamageType
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public static class Extensions
|
|||
private static Random Random => (Random) (_random ?? (_random = new Random((uint) (DateTime.Now.Ticks%uint.MaxValue))));
|
||||
// public static T RandomElement<T>(this IEnumerable<T> enumerable) => enumerable.ElementAt(Random.NextInt(0, enumerable.Count()));
|
||||
public static float NextUnbounded(this ref Random random) => 1 / (1 - random.NextFloat()) - 1;
|
||||
public static float NextUnbounded(this ref Random random, float bias, float power) => 1 / (1 - pow(random.NextFloat(), 1 - pow(clamp(bias,0,.99f), 1 / power))) - 1;
|
||||
public static float NextUnbounded(this ref Random random, float bias, float power, float ceiling) => 1 / (1 - pow(min(random.NextFloat(), ceiling), 1 - pow(clamp(bias,0,.99f), 1 / power))) - 1;
|
||||
|
||||
private static Dictionary<Type,Type[]> InterfaceClasses = new Dictionary<Type, Type[]>();
|
||||
public static Type[] GetAllInterfaceClasses(this Type type)
|
||||
|
|
|
|||
|
|
@ -50,10 +50,14 @@ public class SimpleCommodityData : ItemData
|
|||
|
||||
// Controls the bias power variable during resource placement
|
||||
[InspectableField, JsonProperty("resourceDensityBiasPower"), Key(8)]
|
||||
public float ResourceDensityBiasPower = 5;
|
||||
public float DensityBiasPower = 5;
|
||||
|
||||
// Controls the bias power variable during resource placement
|
||||
[InspectableField, JsonProperty("resourceRandomCeiling"), Key(9)]
|
||||
public float RandomCeiling = .9f;
|
||||
|
||||
// Minimum amount of resources needed for presence to register
|
||||
[InspectableField, JsonProperty("resourceFloor"), Key(9)]
|
||||
[InspectableField, JsonProperty("resourceFloor"), Key(10)]
|
||||
public float ResourceFloor = 10f;
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +72,11 @@ public abstract class CraftedItemData : ItemData
|
|||
}
|
||||
|
||||
[RethinkTable("Items"), Inspectable, MessagePackObject]
|
||||
public class CompoundCommodityData : CraftedItemData {}
|
||||
public class CompoundCommodityData : CraftedItemData
|
||||
{
|
||||
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("demandProfile"), Key(6)]
|
||||
public Dictionary<Guid, float> DemandProfile = new Dictionary<Guid, float>();
|
||||
}
|
||||
|
||||
[Union(0, typeof(GearData)),
|
||||
Union(1, typeof(HullData)),
|
||||
|
|
@ -210,4 +218,17 @@ public class PerformanceStat
|
|||
|
||||
return ConstantModifiers[entity];
|
||||
}
|
||||
}
|
||||
|
||||
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class PersonalityAttribute : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[InspectableField, JsonProperty("name"), Key(1)]
|
||||
public string Name;
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
get => Name;
|
||||
set => Name = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ public class ZoneGenerator
|
|||
planet.Mass > context.GlobalData.PlanetMass ? BodyType.Planet : BodyType.Planetoid);
|
||||
if ((bodyType & r.ResourceBodyType) != 0)
|
||||
{
|
||||
float quantity = context.Random.NextUnbounded(r.ResourceDensity.Aggregate(1f, (m, rdm) => m * resourceMaps[rdm]), r.ResourceDensityBiasPower);
|
||||
float quantity = context.Random.NextUnbounded(r.ResourceDensity.Aggregate(1f, (m, rdm) => m * resourceMaps[rdm]), r.DensityBiasPower, r.RandomCeiling);
|
||||
if (r.ResourceFloor < quantity) dictionary.Add(r.ID, quantity);
|
||||
}
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ public class ZoneGenerator
|
|||
if (rosette)
|
||||
{
|
||||
// Create a rosette with a number of vertices between 2 and 9 inclusive
|
||||
root.ExpandRosette((int)(random.NextFloat(1, 3) * random.NextFloat(2, 3)));
|
||||
root.ExpandRosette((int)(random.NextFloat(1, 5) + random.NextFloat(1, 5)));
|
||||
|
||||
// Create a small number of less massive "captured" planets orbiting past the rosette
|
||||
root.ExpandSolar(
|
||||
|
|
@ -146,7 +146,7 @@ public class ZoneGenerator
|
|||
var m = p.Mass / averageChildMass;
|
||||
// Give each child in the rosette its own mini solar system
|
||||
p.ExpandSolar(
|
||||
count: (int) (random.NextFloat() * random.NextFloat() * m * 5 + 1),
|
||||
count: (int) (random.NextFloat(1, 3 * m) + random.NextFloat(1, 3 * m)),
|
||||
massMulMin: 0.75f,
|
||||
massMulMax: 2.5f,
|
||||
distMulMin: 1 + m * .25f,
|
||||
|
|
|
|||
Loading…
Reference in a new issue