private void SetupPhysicalItem() { // 1) Physical Item MyObjectBuilder_PhysicalItemDefinition newPhysDefOb = new MyObjectBuilder_PhysicalItemDefinition { Id = new SerializableDefinitionId { TypeId = typeof(MyObjectBuilder_Ore), SubtypeId = "BulletproofGlassScrap2" }, DisplayName = "Bulletproof Glass Scrap 2", Icons = new[] { Constants.IconLocation + Constants.BulletproofGlassIcon }, Size = new Vector3(0.2, 0.2, 0.1), Mass = 1, Volume = 0.254f, Model = Constants.KnownScrapModelLocation + Constants.Scrap2, PhysicalMaterial = "Metal" }; // 1b) Physical Item Def -- May not be needed... MyPhysicalItemDefinition newPhysItemDef = new MyPhysicalItemDefinition { Id = newPhysDefOb.Id, AvailableInSurvival = true }; WriteToLog("Added", $"{ManualAddToDefinitions(newPhysItemDef)}", LogType.General); //WriteToLog("Added",$"{MyDefinitionManager.Static.Definitions.AddOrRelaceDefinition(newPhysItemDef)}",LogType.General); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); MyObjectBuilder_PhysicalItemDefinition definition = builder as MyObjectBuilder_PhysicalItemDefinition; this.Size = definition.Size; this.Mass = definition.Mass; this.Model = definition.Model; this.Models = definition.Models; this.Volume = (definition.Volume != null) ? (definition.Volume.Value / 1000f) : definition.Size.Volume; this.ModelVolume = (definition.ModelVolume != null) ? (definition.ModelVolume.Value / 1000f) : this.Volume; this.IconSymbol = !string.IsNullOrEmpty(definition.IconSymbol) ? new MyStringId?(MyStringId.GetOrCompute(definition.IconSymbol)) : null; this.PhysicalMaterial = MyStringHash.GetOrCompute(definition.PhysicalMaterial); this.VoxelMaterial = MyStringHash.GetOrCompute(definition.VoxelMaterial); this.CanSpawnFromScreen = definition.CanSpawnFromScreen; this.RotateOnSpawnX = definition.RotateOnSpawnX; this.RotateOnSpawnY = definition.RotateOnSpawnY; this.RotateOnSpawnZ = definition.RotateOnSpawnZ; this.Health = definition.Health; if (definition.DestroyedPieceId != null) { this.DestroyedPieceId = new MyDefinitionId?(definition.DestroyedPieceId.Value); } this.DestroyedPieces = definition.DestroyedPieces; this.ExtraInventoryTooltipLine = (definition.ExtraInventoryTooltipLine == null) ? new StringBuilder() : new StringBuilder().Append(MyEnvironment.NewLine).Append(definition.ExtraInventoryTooltipLine); this.MaxStackAmount = definition.MaxStackAmount; }
private void SetupTestItem2() { // 1a) Physical Item Ob // 1b) Physical Item Def? // 1c) TODO: Add this... somewhere... // 2) Blueprint (add 1 to 2) // 3a) Blueprint Class OB // 3b) Blueprint Class Def // 3a) Add 3a to 3b // 4a) Add 3b to Refineries // 4a) Add 3b to Skits [if applicable] // 1) Physical Item //ReportOreDefinitions(); MyObjectBuilder_PhysicalItemDefinition newPhysDefOb = new MyObjectBuilder_PhysicalItemDefinition { Id = new SerializableDefinitionId { TypeId = typeof(MyObjectBuilder_Ore), SubtypeId = "BulletproofGlassScrap2" }, AvailableInSurvival = true, CanPlayerOrder = false, CanSpawnFromScreen = true, Enabled = true, Public = true, DisplayName = "Bulletproof Glass Scrap 2", Icons = new[] { Constants.IconLocation + Constants.BulletproofGlassIcon }, Size = new Vector3(0.2, 0.2, 0.1), Mass = 1, Volume = 0.254f, Model = Constants.KnownScrapModelLocation + Constants.Scrap2, PhysicalMaterial = "Metal" }; var baseDef = MyDefinitionManagerBase.GetObjectFactory().CreateInstance(newPhysDefOb.TypeId); baseDef.Context = new MyModContext(); baseDef.Context.Init((MyModContext)ModContext); baseDef.Init(newPhysDefOb, (MyModContext)ModContext); baseDef.AvailableInSurvival = true; baseDef.Public = true; WriteToLog("SetupTestItem2", $"{MyDefinitionManager.Static.Definitions.AddOrRelaceDefinition(baseDef)}", LogType.General); WriteToLog("SetupTestItem2", $"{MyDefinitionManager.Static.Definitions.AddOrRelaceDefinition(baseDef)}", LogType.General); WriteToLog("SetupTestItem2", $"{(MyDefinitionManager.Static.TryGetPhysicalItemDefinition(baseDef.Id)).Id}", LogType.General); WriteToLog("SetupTestItem2", $"{(MyDefinitionManager.Static.TryGetPhysicalItemDefinition(baseDef.Id)).IsOre}", LogType.General); MyPhysicalItemDefinition siliconOreDef = MyDefinitionManager.Static.GetPhysicalItemDefinition(new MyDefinitionId(typeof(MyObjectBuilder_Ore), "Silicon")); ReportCustomDefinition((MyPhysicalItemDefinition)baseDef); ReportCustomDefinition(siliconOreDef); //ReportOreDefinitions(); //ReportDefinitions(); // 1b) Physical Item Def -- May not be needed... //MyPhysicalItemDefinition newPhysItemDef = new MyPhysicalItemDefinition //{ // Context = (MyModContext) ModContext, // Id = newPhysDefOb.Id, // Public = true //}; // 0) OB //MyObjectBuilder_PhysicalItemDefinition defOb = new MyObjectBuilder_PhysicalItemDefinition() //{ // Id = new.Id //}; //MyObjectBuilder_LCDTextureDefinition lcdDef = new MyObjectBuilder_LCDTextureDefinition //{ // Id = baseDef.Id //}; //MyDefinitionManager.Static.Definitions.Definitions[typeof(MyObjectBuilder_LCDTextureDefinition)].Add(lcdDef.SubtypeId, baseDef); //MyDefinitionManager.Static.GetLoadingSet().Definitions //WriteToLog("SetupTestItem2", $"{MyDefinitionManager.Static.GetLoadingSet().Definitions.Count}",LogType.General); //MyDefinitionManager.Static.Definitions.AddDefinition(baseDef); //MyDefinitionPostprocessor.Bundle bundle = default(MyDefinitionPostprocessor.Bundle); //bundle.Context = (MyModContext)ModContext; //bundle.Set = new MyDefinitionSet(); //MyDefinitionPostprocessor.Bundle definitions = bundle; //bundle.Definitions.Add(baseDef.Id.SubtypeId, baseDef); //MyDefinitionManagerBase.GetPostProcessor(baseDef.GetObjectBuilder().TypeId). .AfterLoaded(ref definitions); //foreach (MyDefinitionPostprocessor postProcessor in MyDefinitionManagerBase.GetPostProcessor(baseDef.GetObjectBuilder().TypeId)) //{ //if (definitionSet.Definitions.TryGetValue(myDefinitionPostprocessor.DefinitionType, out definitions.Definitions)) //{ //postProcessor.AfterLoaded(ref definitions); //} //} //MyDefinitionManager.Static.Definitions.AddDefinition(baseDef); //MyDefinitionManager.Static.Definitions.AddOrRelaceDefinition(baseDef); //foreach (var test in MyDefinitionManager.Static.Definitions.Definitions[typeof(MyObjectBuilder_Ore)].Keys) //{ // //test this //} // 2) Blueprint //MyPhysicalItemDefinition siliconIngotDef = MyDefinitionManager.Static.GetPhysicalItemDefinition(new MyDefinitionId(typeof(MyObjectBuilder_Ingot), "Silicon")); //BlueprintItem preReq = new BlueprintItem //{ // Id = newPhysItemDef.Id, // Amount = "1" //}; //BlueprintItem results = new BlueprintItem //{ // Id = siliconIngotDef.Id, // Amount = "1" //}; //MyObjectBuilder_BlueprintDefinition newBpDefOb = new MyObjectBuilder_BlueprintDefinition //{ // Id = new MyDefinitionId(typeof(MyObjectBuilder_BlueprintDefinition), "BulletproofGlassToIngot"), // DisplayName = "Bulletproof Glass Scrap", // Icons = new[] // { // Constants.IconLocation + Constants.BulletproofGlassIcon // }, // Prerequisites = new[] // { // preReq // }, // Results = new[] // { // results // }, // BaseProductionTimeInSeconds = 0.04f //}; //MyBlueprintDefinition newBpDef = new MyBlueprintDefinition //{ // Id = newBpDefOb.Id //}; ////MyBlueprintDefinition newBp = new MyBlueprintDefinition ////{ //// Id = new MyDefinitionId(typeof(MyObjectBuilder_BlueprintDefinition), "BulletproofGlassToIngot"), //// DisplayNameString = "Bulletproof Glass Scrap", //// Icons = new[] //// { //// Constants.IconLocation + Constants.BulletproofGlassIcon //// }, //// Prerequisites = new[] //// { //// new MyBlueprintDefinitionBase.Item //// { //// Amount = 1, //// Id = siliconOreDef.Id //// } //// }, //// Results = new[] //// { //// new MyBlueprintDefinitionBase.Item //// { //// Amount = (MyFixedPoint) 6.75, //// Id = siliconIngotDef.Id //// } //// }, //// BaseProductionTimeInSeconds = 0.04f ////}; //// 3a) Blueprint Class OB //MyObjectBuilder_BlueprintClassDefinition newBpClassDefOb = new MyObjectBuilder_BlueprintClassDefinition //{ // Id = new SerializableDefinitionId // { // TypeId = typeof(MyObjectBuilder_BlueprintClassDefinition), // SubtypeId = "AwwScrap2" // }, // DisplayName = "Scrap Recycling", // Description = "Scrap Recycling", // Icons = new[] // { // "Textures\\GUI\\Icons\\component\\ScrapMetalComponent.dds" // }, // HighlightIcon = "Textures\\GUI\\Icons\\component\\ScrapMetalComponent.dds", // InputConstraintIcon = "Textures\\GUI\\Icons\\filter_ore.dds", // OutputConstraintIcon = "Textures\\GUI\\Icons\\filter_ingot.dds" //}; //// 3b) Blueprint Class Definition //MyBlueprintClassDefinition newBpClassDef = new MyBlueprintClassDefinition //{ // Id = newBpClassDefOb.Id //}; ////ReportDefinitions(); ////ReportDefinitionManager(); ////ReportCustomDefinition(newPhysItemDef); ////ReportOreDefinitions(); ////MyDefinitionManagerBase.GetPostProcessor(typeof(MyObjectBuilder_Ore)).AfterPostprocess(); //// 3c) Add Blueprint to Blueprint Class (creates an entry) ////x.AddBlueprint(newBpDef); }
private void SetupTestItem() { // 1) Physical Item // 2) Blueprint // 3) Blueprint Class // 4) Blueprint Class Entry // 1) Physical Item: MyPhysicalItemDefinition newDef = new MyPhysicalItemDefinition { Id = new MyDefinitionId(typeof(MyObjectBuilder_Ore), "BulletproofGlassScrap"), DisplayNameString = "Bulletproof Glass Scrap", Icons = new[] { Constants.IconLocation + Constants.BulletproofGlassIcon }, Size = new Vector3(0.2, 0.2, 0.1), Mass = 1, Volume = 0.254f, Model = Constants.KnownScrapModelLocation + Constants.Scrap2, PhysicalMaterial = MyStringHash.GetOrCompute("Metal") }; // 0) OB MyObjectBuilder_PhysicalItemDefinition defOb = new MyObjectBuilder_PhysicalItemDefinition() { Id = newDef.Id }; newDef.Init(defOb, (MyModContext)ModContext); MyDefinitionManager.Static.Definitions.AddDefinition(newDef); // 2) Blueprint MyPhysicalItemDefinition siliconIngotDef = MyDefinitionManager.Static.GetPhysicalItemDefinition(new MyDefinitionId(typeof(MyObjectBuilder_Ingot), "Silicon")); MyPhysicalItemDefinition siliconOreDef = MyDefinitionManager.Static.GetPhysicalItemDefinition(new MyDefinitionId(typeof(MyObjectBuilder_Ore), "Silicon")); MyBlueprintDefinition newBp = new MyBlueprintDefinition { Id = new MyDefinitionId(typeof(MyObjectBuilder_BlueprintDefinition), "BulletproofGlassToIngot"), DisplayNameString = "Bulletproof Glass Scrap", Icons = new[] { Constants.IconLocation + Constants.BulletproofGlassIcon }, Prerequisites = new[] { new MyBlueprintDefinitionBase.Item { Amount = 1, Id = siliconOreDef.Id } }, Results = new[] { new MyBlueprintDefinitionBase.Item { Amount = (MyFixedPoint)6.75, Id = siliconIngotDef.Id } }, BaseProductionTimeInSeconds = 0.04f }; MyDefinitionManager.Static.Definitions.AddDefinition(newBp); // 3) Blueprint Class MyBlueprintClassDefinition newBpClass = new MyBlueprintClassDefinition { Id = new MyDefinitionId(typeof(MyBlueprintClassDefinition), Constants.AwwScrapBlueprintClassSubtypeId), DisplayNameString = "Scrap Recycling", DescriptionString = "Scrap Recycling", Icons = new[] { "Textures\\GUI\\Icons\\component\\ScrapMetalComponent.dds" }, HighlightIcon = "Textures\\GUI\\Icons\\component\\ScrapMetalComponent.dds", InputConstraintIcon = "Textures\\GUI\\Icons\\filter_ore.dds", OutputConstraintIcon = "Textures\\GUI\\Icons\\filter_ingot.dds" }; MyDefinitionManager.Static.Definitions.AddDefinition(newBpClass); // 4) Blueprint Class Entry BlueprintClassEntry newBpClassEntry = new BlueprintClassEntry { TypeId = newBp.Id.TypeId, BlueprintSubtypeId = "BulletproofGlassToIngot", Class = "Ingots", Enabled = true, BlueprintTypeId = newBp.Id.TypeId.ToString() }; WriteToLog("Added", $"May have added: {newDef}", LogType.General); //MyDefinitionManager.Static.Definitions.Definitions. //MyDefinitionManager.Static.Definitions.Definitions.Add(typeof(BlueprintClassEntry)); }