Branding
Production personality profile has been moved from blueprint to factory
This commit is contained in:
parent
39ce6809c0
commit
a01d760f39
11 changed files with 1368 additions and 60 deletions
|
|
@ -16,6 +16,9 @@ public class FactoryData : BehaviorData
|
|||
[InspectableField, JsonProperty("automation"), Key(2)]
|
||||
public int AutomationPoints;
|
||||
|
||||
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("productionProfile"), Key(3)]
|
||||
public Dictionary<Guid, float> ProductionProfile = new Dictionary<Guid, float>();
|
||||
|
||||
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
|
||||
{
|
||||
return new Factory(context, this, entity, item);
|
||||
|
|
@ -28,6 +31,7 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
public double RetoolingTime;
|
||||
public string ItemName;
|
||||
public Guid ItemUnderConstruction;
|
||||
public bool Active;
|
||||
|
||||
public Entity Entity { get; }
|
||||
public Gear Item { get; }
|
||||
|
|
@ -47,8 +51,9 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
_blueprint = value;
|
||||
RetoolingTime = ToolingTime;
|
||||
_retooling = true;
|
||||
Active = false;
|
||||
ItemName = Context.Cache.Get<ItemData>(Context.Cache.Get<BlueprintData>(value).Item).Name;
|
||||
Item.Change();
|
||||
ItemName = Context.Cache.Get<BlueprintData>(value).Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,18 +79,6 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
var blueprint = Context.Cache.Get<BlueprintData>(_blueprint);
|
||||
if (blueprint == null)
|
||||
return false;
|
||||
|
||||
if (RetoolingTime > 0)
|
||||
{
|
||||
RetoolingTime -= delta;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_retooling)
|
||||
{
|
||||
_retooling = false;
|
||||
Item.Change();
|
||||
}
|
||||
|
||||
if (ItemUnderConstruction != Guid.Empty)
|
||||
{
|
||||
|
|
@ -108,19 +101,35 @@ public class Factory : IBehavior, IPersistentBehavior
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Applying exponents to two random numbers and adding them produces a range of interesting probability distributions for quality
|
||||
ItemUnderConstruction = Entity.Build(blueprint, blueprint.Quality *
|
||||
pow(ProductionQuality, blueprint.QualityExponent) *
|
||||
(pow(Context.Random.NextFloat(), blueprint.RandomExponent) +
|
||||
pow(Context.Random.NextFloat(), blueprint.RandomExponent)) / 2, ItemName);
|
||||
|
||||
if(ItemUnderConstruction!=Guid.Empty)
|
||||
if (RetoolingTime > 0)
|
||||
{
|
||||
RetoolingTime -= delta;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_retooling)
|
||||
{
|
||||
_retooling = false;
|
||||
Item.Change();
|
||||
}
|
||||
|
||||
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 *
|
||||
pow(ProductionQuality, blueprint.QualityExponent) *
|
||||
(pow(Context.Random.NextFloat(), blueprint.RandomExponent) +
|
||||
pow(Context.Random.NextFloat(), blueprint.RandomExponent)) / 2, ItemName);
|
||||
|
||||
if(ItemUnderConstruction!=Guid.Empty)
|
||||
Item.Change();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO Update Factory Persistence
|
||||
public PersistentBehaviorData Store()
|
||||
{
|
||||
return new FactoryPersistence
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public class ThermotoggleData : BehaviorData
|
|||
|
||||
public class Thermotoggle : IBehavior
|
||||
{
|
||||
public float TargetTemperature;
|
||||
private ThermotoggleData _data;
|
||||
|
||||
private Entity Entity { get; }
|
||||
|
|
@ -34,10 +35,11 @@ public class Thermotoggle : IBehavior
|
|||
Entity = entity;
|
||||
Item = item;
|
||||
Context = context;
|
||||
TargetTemperature = data.TargetTemperature;
|
||||
}
|
||||
|
||||
public bool Update(float delta)
|
||||
{
|
||||
return Entity.Temperature < _data.TargetTemperature ^ _data.HighPass;
|
||||
return Entity.Temperature < TargetTemperature ^ _data.HighPass;
|
||||
}
|
||||
}
|
||||
|
|
@ -51,9 +51,6 @@ public class BlueprintData : DatabaseEntry, INamedEntry
|
|||
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("resourceRequirements"), Key(14)]
|
||||
public Dictionary<Guid, int> ResourceRequirements = new Dictionary<Guid, int>();
|
||||
|
||||
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("productionProfile"), Key(15)]
|
||||
public Dictionary<Guid, float> ProductionProfile = new Dictionary<Guid, float>();
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
get => Name;
|
||||
|
|
|
|||
|
|
@ -813,7 +813,7 @@ public class GameContext
|
|||
Ingredients = ingredients.Select(i=>i.ID).ToList(),
|
||||
Quality = Random.NextFloat(qualityMin, qualityMax),
|
||||
Blueprint = blueprint.ID,
|
||||
Name = $"Generic {item.Name}"
|
||||
Name = $"{item.Name}"
|
||||
};
|
||||
newGear.Durability = Evaluate(equippableItemData.Durability, newGear);
|
||||
Cache.Add(newGear);
|
||||
|
|
@ -827,7 +827,7 @@ public class GameContext
|
|||
Ingredients = ingredients.Select(i=>i.ID).ToList(),
|
||||
Quality = Random.NextFloat(qualityMin, qualityMax),
|
||||
Blueprint = blueprint.ID,
|
||||
Name = $"Generic {item.Name}"
|
||||
Name = $"{item.Name}"
|
||||
};
|
||||
Cache.Add(newCommodity);
|
||||
return newCommodity;
|
||||
|
|
|
|||
Loading…
Reference in a new issue