Exemplo n.º 1
0
 private List <MyInventoryItem> GetInventoryItems(MyMwcObjectBuilder_Base objectBuilder)
 {
     m_helperInventoryItems.Clear();
     if (!(objectBuilder is MyMwcObjectBuilder_PrefabBase))
     {
         MyEditor.Static.FoundationFactory.PrefabContainer.Inventory.GetInventoryItems(ref m_helperInventoryItems, objectBuilder);
         //return MyEditor.Static.FoundationFactory.PrefabContainer.Inventory.GetInventoryItems(objectBuilder);
         //return m_helperInventoryItems;
     }
     else
     {
         MyMwcObjectBuilder_PrefabBase prefabBuilder = objectBuilder as MyMwcObjectBuilder_PrefabBase;
         //List<MyInventoryItem> inventoryItems = new List<MyInventoryItem>();
         foreach (MyInventoryItem inventoryItem in MyEditor.Static.FoundationFactory.PrefabContainer.Inventory.GetInventoryItems())
         {
             MyMwcObjectBuilder_Base inventoryItemBuilder = inventoryItem.GetInventoryItemObjectBuilder(false);
             if (inventoryItemBuilder is MyMwcObjectBuilder_PrefabBase)
             {
                 MyMwcObjectBuilder_PrefabBase inventoryPrefabBuilder = inventoryItemBuilder as MyMwcObjectBuilder_PrefabBase;
                 if (inventoryPrefabBuilder.GetObjectBuilderType() == prefabBuilder.GetObjectBuilderType() &&
                     inventoryPrefabBuilder.GetObjectBuilderId() == prefabBuilder.GetObjectBuilderId() &&
                     inventoryPrefabBuilder.FactionAppearance == prefabBuilder.FactionAppearance)
                 {
                     //inventoryItems.Add(inventoryItem);
                     m_helperInventoryItems.Add(inventoryItem);
                 }
             }
         }
         //return inventoryItems;
     }
     return(m_helperInventoryItems);
 }
Exemplo n.º 2
0
        /// <summary>
        /// CreatePrefab
        /// </summary>
        /// <param name="hudLabelText"></param>
        /// <param name="objBuilder"></param>
        /// <returns></returns>
        public MyPrefabBase CreatePrefab(string hudLabelText, MyPrefabContainer prefabContainer, MyMwcObjectBuilder_PrefabBase prefabBuilder)
        {
            Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyPrefabFactory.CreatePrefab");

            MyPrefabConfiguration config   = MyPrefabConstants.GetPrefabConfiguration(prefabBuilder.GetObjectBuilderType(), prefabBuilder.GetObjectBuilderId().Value);
            Vector3 relativePosition       = MyPrefabContainer.GetRelativePositionInAbsoluteCoords(prefabBuilder.PositionInContainer);
            Matrix  prefabLocalOrientation = Matrix.CreateFromYawPitchRoll(prefabBuilder.AnglesInContainer.X, prefabBuilder.AnglesInContainer.Y, prefabBuilder.AnglesInContainer.Z);

            MyPrefabBase prefab = null;

            if (config is MyPrefabConfigurationKinematic)
            {
                prefab = new MyPrefabKinematic(prefabContainer);
            }
            else if (config is MyPrefabConfigurationLight)
            {
                prefab = new MyPrefabLight(prefabContainer);
            }
            else if (config is MyPrefabConfigurationLargeWeapon)
            {
                prefab = new MyPrefabLargeWeapon(prefabContainer);
            }
            else if (config is MyPrefabConfigurationSound)
            {
                prefab = new MyPrefabSound(prefabContainer);
            }
            else if (config is MyPrefabConfigurationParticles)
            {
                prefab = new MyPrefabParticles(prefabContainer);
            }
            else if (config is MyPrefabConfigurationLargeShip)
            {
                prefab = new MyPrefabLargeShip(prefabContainer);
            }
            else if (config is MyPrefabConfigurationHangar)
            {
                prefab = new MyPrefabHangar(prefabContainer);
            }
            else if (config is MyPrefabConfigurationFoundationFactory)
            {
                prefab = new MyPrefabFoundationFactory(prefabContainer);
            }
            else if (config is MyPrefabConfigurationSecurityControlHUB)
            {
                prefab = new MyPrefabSecurityControlHUB(prefabContainer);
            }
            else if (config is MyPrefabConfigurationBankNode)
            {
                prefab = new MyPrefabBankNode(prefabContainer);
            }
            else if (config is MyPrefabConfigurationGenerator)
            {
                prefab = new MyPrefabGenerator(prefabContainer);
            }
            else if (config is MyPrefabConfigurationScanner)
            {
                prefab = new MyPrefabScanner(prefabContainer);
            }
            else if (config is MyPrefabConfigurationCamera)
            {
                prefab = new MyPrefabCamera(prefabContainer);
            }
            else if (config is MyPrefabConfigurationAlarm)
            {
                prefab = new MyPrefabAlarm(prefabContainer);
            }
            else
            {
                prefab = new MyPrefab(prefabContainer);
                //prefab.Init(hudLabelText, relativePosition, prefabLocalOrientation, prefabBuilder, config);
            }
            prefab.Init(hudLabelText, relativePosition, prefabLocalOrientation, prefabBuilder, config);

            Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            return(prefab);
        }