Population Personality Property Production Performance
Personality now affects production quality You can now assign population points to infrastructure Production influences personality Automated production has a quality variable, imitating population affinity New properties panel field type for incrementing/decrementing integers
This commit is contained in:
parent
9e368796cf
commit
70100a48ef
17 changed files with 920 additions and 25 deletions
|
|
@ -47,6 +47,11 @@ public interface IPersistentBehavior//<T> where T : IBehavior
|
|||
void Restore(PersistentBehaviorData data);
|
||||
}
|
||||
|
||||
public interface IPopulationAssignment
|
||||
{
|
||||
int AssignedPopulation { get; set; }
|
||||
}
|
||||
|
||||
public interface IController
|
||||
{
|
||||
bool Available { get; }
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ public class FactoryData : BehaviorData
|
|||
|
||||
[InspectableField, JsonProperty("automation"), Key(2)]
|
||||
public int AutomationPoints;
|
||||
|
||||
[InspectableField, JsonProperty("automationQuality"), Key(3)]
|
||||
public float AutomationQuality = .5f;
|
||||
|
||||
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("productionProfile"), Key(3)]
|
||||
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("productionProfile"), Key(4)]
|
||||
public Dictionary<Guid, float> ProductionProfile = new Dictionary<Guid, float>();
|
||||
|
||||
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
|
||||
|
|
@ -25,13 +28,14 @@ public class FactoryData : BehaviorData
|
|||
}
|
||||
}
|
||||
|
||||
public class Factory : IBehavior, IPersistentBehavior
|
||||
public class Factory : IBehavior, IPersistentBehavior, IPopulationAssignment
|
||||
{
|
||||
public float ProductionQuality;
|
||||
public double RetoolingTime;
|
||||
public string ItemName;
|
||||
public Guid ItemUnderConstruction;
|
||||
public bool Active;
|
||||
public int AssignedPopulation { get; set; }
|
||||
|
||||
public Entity Entity { get; }
|
||||
public Gear Item { get; }
|
||||
|
|
@ -64,7 +68,6 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
private FactoryData _data;
|
||||
|
||||
private Guid _blueprint;
|
||||
private int _assignedPopulation;
|
||||
private bool _retooling = false;
|
||||
private float _currentProductionQuality;
|
||||
|
||||
|
|
@ -86,7 +89,7 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
if (ItemUnderConstruction != Guid.Empty)
|
||||
{
|
||||
Entity.IncompleteCargo[ItemUnderConstruction] =
|
||||
Entity.IncompleteCargo[ItemUnderConstruction] - delta * (_assignedPopulation + _data.AutomationPoints) /
|
||||
Entity.IncompleteCargo[ItemUnderConstruction] - delta * (AssignedPopulation + _data.AutomationPoints) /
|
||||
pow(lerp(blueprint.QualityFloor, 1, saturate(_currentProductionQuality)),
|
||||
blueprint.ProductionExponent);
|
||||
|
||||
|
|
@ -99,6 +102,9 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
Entity.AddCargo(craftedItemInstance);
|
||||
Entity.IncompleteCargo.Remove(ItemUnderConstruction);
|
||||
ItemUnderConstruction = Guid.Empty;
|
||||
foreach (var attribute in _data.ProductionProfile)
|
||||
Entity.Personality[attribute.Key] = lerp(Entity.Personality[attribute.Key], attribute.Value,
|
||||
Context.GlobalData.ProductionPersonalityLerp * ((float) AssignedPopulation / Entity.Population));
|
||||
Item.Change();
|
||||
}
|
||||
|
||||
|
|
@ -119,11 +125,20 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
|
||||
if (Active)
|
||||
{
|
||||
// Applying exponents to two random numbers and adding them produces a range of interesting probability distributions for quality
|
||||
ItemUnderConstruction = Entity.Build(blueprint, blueprint.Quality *
|
||||
var profileDistance = 0f;
|
||||
if (_data.ProductionProfile.Any())
|
||||
profileDistance = _data.ProductionProfile.Sum(x => abs(x.Value - Entity.Personality[x.Key])) /
|
||||
_data.ProductionProfile.Count;
|
||||
var personalityQuality =
|
||||
(_data.AutomationPoints * _data.AutomationQuality + AssignedPopulation * (1 - profileDistance)) /
|
||||
(_data.AutomationPoints + AssignedPopulation);
|
||||
ItemUnderConstruction = Entity.Build(blueprint,
|
||||
blueprint.Quality *
|
||||
pow(personalityQuality, blueprint.PersonalityExponent) *
|
||||
pow(ProductionQuality, blueprint.QualityExponent) *
|
||||
(pow(Context.Random.NextFloat(), blueprint.RandomExponent) +
|
||||
pow(Context.Random.NextFloat(), blueprint.RandomExponent)) / 2, ItemName);
|
||||
// Applying exponents to two random numbers and averaging them produces a range of interesting probability distributions for quality
|
||||
(pow(Context.Random.NextFloat(), blueprint.RandomQualityExponent) +
|
||||
pow(Context.Random.NextFloat(), blueprint.RandomQualityExponent)) / 2, ItemName);
|
||||
|
||||
if(ItemUnderConstruction!=Guid.Empty)
|
||||
Item.Change();
|
||||
|
|
@ -139,7 +154,7 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
{
|
||||
Blueprint = _blueprint,
|
||||
RetoolingTime = RetoolingTime,
|
||||
AssignedPopulation = _assignedPopulation,
|
||||
AssignedPopulation = AssignedPopulation,
|
||||
ProductionQuality = ProductionQuality
|
||||
};
|
||||
}
|
||||
|
|
@ -149,7 +164,7 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
var factoryPersistence = data as FactoryPersistence;
|
||||
_blueprint = factoryPersistence.Blueprint;
|
||||
RetoolingTime = factoryPersistence.RetoolingTime;
|
||||
_assignedPopulation = factoryPersistence.AssignedPopulation;
|
||||
AssignedPopulation = factoryPersistence.AssignedPopulation;
|
||||
ProductionQuality = factoryPersistence.ProductionQuality;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,24 +31,27 @@ public class BlueprintData : DatabaseEntry, INamedEntry
|
|||
public float ProductionExponent = 1;
|
||||
|
||||
[InspectableField, JsonProperty("randomExponent"), Key(8)]
|
||||
public float RandomExponent = 1;
|
||||
public float RandomQualityExponent = 1;
|
||||
|
||||
[InspectableField, JsonProperty("qualityFloor"), Key(9)]
|
||||
[InspectableField, JsonProperty("personalityExponent"), Key(9)]
|
||||
public float PersonalityExponent = 1;
|
||||
|
||||
[InspectableField, JsonProperty("qualityFloor"), Key(10)]
|
||||
public float QualityFloor = .25f;
|
||||
|
||||
[InspectableField, JsonProperty("statEffects"), Key(10)]
|
||||
[InspectableField, JsonProperty("statEffects"), Key(11)]
|
||||
public List<BlueprintStatEffect> StatEffects = new List<BlueprintStatEffect>();
|
||||
|
||||
[InspectableField, JsonProperty("researchTime"), Key(11)]
|
||||
[InspectableField, JsonProperty("researchTime"), Key(12)]
|
||||
public float ResearchTime;
|
||||
|
||||
[InspectableDatabaseLink(typeof(BlueprintData)), JsonProperty("researchDependencies"), Key(12)]
|
||||
[InspectableDatabaseLink(typeof(BlueprintData)), JsonProperty("researchDependencies"), Key(13)]
|
||||
public List<Guid> Dependencies = new List<Guid>();
|
||||
|
||||
[InspectableDatabaseLink(typeof(CraftedItemData)), JsonProperty("factoryItem"), Key(13)]
|
||||
[InspectableDatabaseLink(typeof(CraftedItemData)), JsonProperty("factoryItem"), Key(14)]
|
||||
public Guid FactoryItem;
|
||||
|
||||
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("resourceRequirements"), Key(14)]
|
||||
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("resourceRequirements"), Key(15)]
|
||||
public Dictionary<Guid, int> ResourceRequirements = new Dictionary<Guid, int>();
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
// [IgnoreMember] public Dictionary<Gear, EquippableItemData> GearData;
|
||||
// [IgnoreMember] public Dictionary<Gear, List<IBehavior>> ItemBehaviors;
|
||||
|
||||
private List<IPopulationAssignment> PopulationAssignments = new List<IPopulationAssignment>();
|
||||
|
||||
[IgnoreMember] public int AssignedPopulation => PopulationAssignments.Sum(pa => pa.AssignedPopulation);
|
||||
[IgnoreMember] public float Mass { get; private set; }
|
||||
[IgnoreMember] public float OccupiedCapacity { get; private set; }
|
||||
[IgnoreMember] public float ThermalMass { get; private set; }
|
||||
|
|
@ -187,6 +190,10 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
Trigger = (Trigger) g.FirstOrDefault(b=>b is Trigger)
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
foreach(var behavior in hardpoint.Behaviors)
|
||||
if(behavior is IPopulationAssignment populationAssignment)
|
||||
PopulationAssignments.Add(populationAssignment);
|
||||
}
|
||||
|
||||
public void Equip(Gear gear, Hardpoint hardpoint)
|
||||
|
|
|
|||
|
|
@ -744,7 +744,7 @@ public class GameContext
|
|||
{
|
||||
Name = $"{loadoutData.Name} {Random.NextInt(1,255):X}",
|
||||
Temperature = 293,
|
||||
Population = 1
|
||||
Population = 4
|
||||
};
|
||||
var parentCorp = Cache.Get<MegaCorporation>(corpData.Parent);
|
||||
foreach (var attribute in parentCorp.Personality)
|
||||
|
|
|
|||
|
|
@ -163,6 +163,9 @@ public class GlobalData : DatabaseEntry
|
|||
|
||||
[InspectableField, JsonProperty("significantDigits"), Key(51)]
|
||||
public int SignificantDigits = 3;
|
||||
|
||||
[InspectableField, JsonProperty("productionPersonalityLerp"), Key(52)]
|
||||
public float ProductionPersonalityLerp = .05f;
|
||||
|
||||
public float PlanetRadius(float mass)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue