コード例 #1
0
ファイル: AwwScrap2Core.cs プロジェクト: Thraxus/AwwScrap2
        //private void PrintProductionBlocksDefinitions()
        //{
        //	foreach (var def in MyDefinitionManager.Static.GetDefinitionsOfType<MyRefineryDefinition>())
        //	{
        //		WriteToLog("", $"{def}", LogType.General);

        //		foreach (var cls in def.BlueprintClasses)
        //		{
        //			WriteToLog("", $"{cls}", LogType.General);
        //		}
        //	}

        //	foreach (var def in MyDefinitionManager.Static.GetDefinitionsOfType<MySurvivalKitDefinition>())
        //	{
        //		WriteToLog("", $"{def}", LogType.General);
        //		foreach (var cls in def.BlueprintClasses)
        //		{
        //			WriteToLog("", $"{cls}", LogType.General);
        //		}
        //	}
        //}

        private void SetupCollections()
        {
            foreach (var def in MyDefinitionManager.Static.GetAllDefinitions())
            {
                MyPhysicalItemDefinition physDef = def as MyPhysicalItemDefinition;
                if (physDef != null && physDef.Public)
                {
                    if (physDef.Id.TypeId == typeof(MyObjectBuilder_Component))
                    {
                        _components.Add(physDef);
                    }

                    if (def.Id.TypeId == typeof(MyObjectBuilder_Ore))
                    {
                        _ores.Add(physDef);
                    }
                    continue;
                }

                MyCubeBlockDefinition blockDef = def as MyCubeBlockDefinition;
                if (blockDef != null && blockDef.Public)
                {
                    _cubes.Add(blockDef);
                }
            }

            foreach (var bp in MyDefinitionManager.Static.GetBlueprintDefinitions())
            {
                MyBlueprintDefinition bpDef = bp as MyBlueprintDefinition;
                if (bpDef != null && bpDef.Public)
                {
                    _blueprints.Add(bpDef);
                }
            }
        }
コード例 #2
0
ファイル: AwwScrap2Core.cs プロジェクト: Thraxus/AwwScrap2
        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));
        }