using System.Collections.Generic;
private readonly Func<T> _getter;
private readonly Action<T> _setter;
public PropertyWrapper(Func<T> getter, Action<T> setter)
public readonly Dictionary<string, bool> LimbRepair = new Dictionary<string, bool> {
{ "CenterTorso", false },
public float CurrentInternalStructure = 0.1f;
public Limb Head { get; set; }
public Limb LeftArm { get; set; }
public Limb RightArm { get; set; }
public Limb LeftTorso { get; set; }
public Limb RightTorso { get; set; }
public Limb CenterTorso { get; set; }
public Limb RightLeg { get; set; }
public Limb LeftLeg { get; set; }
private readonly Dictionary<string, PropertyWrapper<Limb>> Properties;
Properties = new Dictionary<string, PropertyWrapper<Limb>>
{"Head", new PropertyWrapper<Limb>( () => Head, v => Head = v ) },
{"LeftArm", new PropertyWrapper<Limb>( () => LeftArm, v => LeftArm = v ) },
{"RightArm", new PropertyWrapper<Limb>( () => RightArm, v => RightArm = v ) },
{"CenterTorso",new PropertyWrapper<Limb>( () => CenterTorso, v => CenterTorso = v )},
{"RightTorso", new PropertyWrapper<Limb>( () => RightTorso, v => RightTorso = v ) },
{"LeftTorso", new PropertyWrapper<Limb>( () => LeftTorso, v => LeftTorso = v ) },
{"RightLeg", new PropertyWrapper<Limb>( () => RightLeg, v => RightLeg = v ) },
{"LeftLeg", new PropertyWrapper<Limb>( () => LeftLeg, v => LeftLeg = v ) }
foreach (var property in Properties) property.Value.Value = new Limb();
public Limb this[string name]
return Properties[name].Value;
Properties[name].Value = value;
public static void Main()
var mech = new MechDef();
var settings = new Settings();
foreach (var pair in settings.LimbRepair)
if (pair.Value != false) continue;
var limb = mech[pair.Key];
limb.CurrentInternalStructure = Math.Max
limb.CurrentInternalStructure * (float)rng.NextDouble()
Console.WriteLine("Head: {0:0.00}", mech.Head.CurrentInternalStructure);
Console.WriteLine("LeftArm: {0:0.00}", mech.Head.CurrentInternalStructure);
Console.WriteLine("RightArm: {0:0.00}", mech.Head.CurrentInternalStructure);