private MyDefinitionId GetAmmoDefinitionIdFromCategory(MyAmmoCategoryEnum category) { switch (category) { case MyAmmoCategoryEnum.SmallCaliber: return(new MyDefinitionId(typeof(MyObjectBuilder_AmmoDefinition), "SmallCaliber")); case MyAmmoCategoryEnum.LargeCaliber: return(new MyDefinitionId(typeof(MyObjectBuilder_AmmoDefinition), "LargeCaliber")); case MyAmmoCategoryEnum.Missile: return(new MyDefinitionId(typeof(MyObjectBuilder_AmmoDefinition), "Missile")); } throw new NotImplementedException(); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); MyObjectBuilder_AmmoMagazineDefinition definition = builder as MyObjectBuilder_AmmoMagazineDefinition; this.Capacity = definition.Capacity; this.Category = definition.Category; if (definition.AmmoDefinitionId != null) { this.AmmoDefinitionId = new MyDefinitionId(definition.AmmoDefinitionId.Type, definition.AmmoDefinitionId.Subtype); } else { this.AmmoDefinitionId = this.GetAmmoDefinitionIdFromCategory(this.Category); } }
private MyDefinitionId GetAmmoDefinitionIdFromCategory(MyAmmoCategoryEnum category) { switch (category) { case MyAmmoCategoryEnum.LargeCaliber: return new MyDefinitionId(typeof(MyObjectBuilder_AmmoDefinition), "LargeCaliber"); break; case MyAmmoCategoryEnum.SmallCaliber: return new MyDefinitionId(typeof(MyObjectBuilder_AmmoDefinition), "SmallCaliber"); break; case MyAmmoCategoryEnum.Missile: return new MyDefinitionId(typeof(MyObjectBuilder_AmmoDefinition), "Missile"); break; default: throw new NotImplementedException(); } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_AmmoMagazineDefinition; MyDebug.AssertDebug(ob != null); this.Capacity = ob.Capacity; this.Category = ob.Category; if (ob.AmmoDefinitionId != null) { this.AmmoDefinitionId = new MyDefinitionId(ob.AmmoDefinitionId.Type, ob.AmmoDefinitionId.Subtype); } else { this.AmmoDefinitionId = GetAmmoDefinitionIdFromCategory(Category); } }