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:
hyperion51 2020-06-08 01:01:33 +01:00
commit 70100a48ef
17 changed files with 920 additions and 25 deletions

View file

@ -9,6 +9,8 @@ using UniRx;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Unity.Mathematics;
using static Unity.Mathematics.math;
public class PropertiesPanel : MonoBehaviour
{
@ -26,6 +28,7 @@ public class PropertiesPanel : MonoBehaviour
public BoolField BoolField;
public PropertyButton PropertyButton;
public ButtonField ButtonField;
public IncrementField IncrementField;
[HideInInspector] public FlatFlatButton SelectedChild;
[HideInInspector] public GameContext Context;
@ -215,6 +218,27 @@ public class PropertiesPanel : MonoBehaviour
OnPropertyAdded?.Invoke(field.gameObject);
}
public void AddIncrementField(string name, Func<int> read, Action<int> write, Func<int> min, Func<int> max)
{
var field = Instantiate(IncrementField, transform);
field.Label.text = name;
field.Increment.OnClick += data => write(read() + 1);
field.Decrement.OnClick += data => write(read() - 1);
RefreshPropertyValues += () =>
{
var val = read();
var minval = min();
var maxval = max();
if (val < minval || val > maxval)
write(val = clamp(val, minval, maxval));
field.Value.text = val.ToString(CultureInfo.InvariantCulture);
field.Increment.CurrentState = val == maxval ? FlatButtonState.Disabled : FlatButtonState.Unselected;
field.Decrement.CurrentState = val == minval ? FlatButtonState.Disabled : FlatButtonState.Unselected;
};
Properties.Add(field.gameObject);
OnPropertyAdded?.Invoke(field.gameObject);
}
public void AddField(string name, Func<float> read, Action<float> write, float min, float max)
{
var field = Instantiate(RangedFloatField, transform);
@ -464,6 +488,11 @@ public class PropertiesPanel : MonoBehaviour
}
foreach (var behavior in hardpoint.Behaviors)
{
if(behavior is IPopulationAssignment populationAssignment)
AddIncrementField("Assigned Population",
() => populationAssignment.AssignedPopulation,
p => populationAssignment.AssignedPopulation = p,
() => 0, () => entity.Population - entity.AssignedPopulation + populationAssignment.AssignedPopulation);
if (behavior is Thermotoggle thermotoggle)
AddField("Target Temperature", () => thermotoggle.TargetTemperature, temp => thermotoggle.TargetTemperature = temp);
if (behavior is Factory factory)