/// <summary> /// Registers Apples /// </summary> /// <param name="typeMapper">Type Mapper</param> /// <param name="settings">Settings</param> private void RegisterApple(ITypeMapper typeMapper, KeyValueStore settings) { // Apple typeMapper.RegisterItem <AppleItem, AppleState, AppleInfo>(this, "Apple"); // Collidable settings.Set <AppleItem>("Mass", 200f, "Mass of an Apple"); typeMapper.AttachItemProperty <AppleItem, CollidableProperty>(this, "Apple Collidable", (i) => { CollidableProperty property = new CollidableProperty(i); // Define Radius property.CollisionRadius = AppleItem.AppleInnerRadius; // Define Mass property.CollisionFixed = false; property.CollisionMass = i.Settings.GetFloat <AppleItem>("Mass").Value; return(property); }); // Visibility typeMapper.AttachItemProperty <AppleItem, VisibleProperty>(this, "Apple Visible", (i) => { VisibleProperty property = new VisibleProperty(i); // Bind Visibility Radius to the Item Radius property.VisibilityRadius = i.Radius; i.RadiusChanged += (item, v) => { property.VisibilityRadius = v; }; return(property); }); // Portable settings.Set <AppleItem>("Weight", 200f, "Weight of an Apple"); typeMapper.AttachItemProperty <AppleItem, PortableProperty>(this, "Apple Portable", (i) => { PortableProperty property = new PortableProperty(i); // Set Weight property.PortableWeight = settings.GetFloat <AppleItem>("Weight").Value; // Bind Portable Radius to the Item Radius property.PortableRadius = i.Radius; i.RadiusChanged += (item, v) => { property.PortableRadius = v; }; return(property); }); settings.Set <AppleItem>("Collectable", false, "Will an Apple be collectable"); settings.Set <AppleItem>("Amount", 250, "Amount of Apple Units"); typeMapper.AttachItemProperty <AppleItem, AppleCollectableProperty>(this, "Apple Collectable", (i) => { if (!i.Settings.GetBool <AppleItem>("Collectable").Value) { return(null); } AppleCollectableProperty property = new AppleCollectableProperty(i); property.Capacity = i.Settings.GetInt <AppleItem>("Amount").Value; property.Amount = i.Settings.GetInt <AppleItem>("Amount").Value; return(property); }); }