Exemple #1
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);
            m_cubeGrid = cubeGrid;

            MyDebug.AssertDebug(BlockDefinition is MyAssemblerDefinition);
            m_assemblerDef = BlockDefinition as MyAssemblerDefinition;

            InputInventory.Constraint = m_assemblerDef.InputInventoryConstraint;
            OutputInventory.Constraint = m_assemblerDef.OutputInventoryConstraint;

            if (Sync.IsServer)
                OutputInventory.ContentsChanged += OutputInventory_ContentsChanged;

            bool removed = InputInventory.FilterItemsUsingConstraint();
            Debug.Assert(!removed, "Inventory filter removed items which were present in the object builder.");

            var builder = (MyObjectBuilder_Assembler)objectBuilder;
            if (builder.OtherQueue != null)
            {
                m_otherQueue.Clear();
                if (m_otherQueue.Capacity < builder.OtherQueue.Length)
                    m_otherQueue.Capacity = builder.OtherQueue.Length;
                for (int i = 0; i < builder.OtherQueue.Length; ++i)
                {
                    var item = builder.OtherQueue[i];

                    var blueprint = MyDefinitionManager.Static.TryGetBlueprintDefinitionByResultId(item.Id);
                    if (blueprint != null)
                    {
                        m_otherQueue.Add(new QueueItem()
                        {
                            Blueprint = blueprint,
                            Amount = item.Amount,
                        });
                    }
                    else
                    {
                        MySandboxGame.Log.WriteLine(string.Format("No blueprint that produces a single result with Id '{0}'", item.Id));
                    }
                }
            }
            CurrentProgress = builder.CurrentProgress;
            m_disassembleEnabled = builder.DisassembleEnabled;
            m_repeatAssembleEnabled = builder.RepeatAssembleEnabled;
            m_repeatDisassembleEnabled = builder.RepeatDisassembleEnabled;
            m_slave = builder.SlaveEnabled;
            UpdateInventoryFlags();

            UpgradeValues.Add("Productivity", 0f);
            UpgradeValues.Add("PowerEfficiency", 1f);

            OnUpgradeValuesChanged += UpdateDetailedInfo;

            PowerReceiver.RequiredInputChanged += PowerReceiver_RequiredInputChanged;
            UpdateDetailedInfo();
        }
Exemple #2
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            UpgradeValues.Add("Productivity", 0f);
            UpgradeValues.Add("PowerEfficiency", 1f);

            base.Init(objectBuilder, cubeGrid);
            m_cubeGrid = cubeGrid;
            NeedsUpdate |= VRage.ModAPI.MyEntityUpdateEnum.EACH_100TH_FRAME;

            MyDebug.AssertDebug(BlockDefinition is MyAssemblerDefinition);
            m_assemblerDef = BlockDefinition as MyAssemblerDefinition;


            if (InventoryAggregate.InventoryCount > 2)
            {
                Debug.Fail("Inventory aggregate has to many inventories, probably wrong save. If you continue the unused inventories will be removed. Save the world to correct it. Please report this is if problem prevail.");

                FixInputOutputInventories(m_assemblerDef.InputInventoryConstraint, m_assemblerDef.OutputInventoryConstraint);
            }

            InputInventory.Constraint = m_assemblerDef.InputInventoryConstraint;
            OutputInventory.Constraint = m_assemblerDef.OutputInventoryConstraint;

            bool removed = InputInventory.FilterItemsUsingConstraint();
            Debug.Assert(!removed, "Inventory filter removed items which were present in the object builder.");

            var builder = (MyObjectBuilder_Assembler)objectBuilder;
            if (builder.OtherQueue != null)
            {
                m_otherQueue.Clear();
                if (m_otherQueue.Capacity < builder.OtherQueue.Length)
                    m_otherQueue.Capacity = builder.OtherQueue.Length;
                for (int i = 0; i < builder.OtherQueue.Length; ++i)
                {
                    var item = builder.OtherQueue[i];

                    var blueprint = MyDefinitionManager.Static.TryGetBlueprintDefinitionByResultId(item.Id);
                    if (blueprint != null)
                    {
                        m_otherQueue.Add(new QueueItem()
                        {
                            Blueprint = blueprint,
                            Amount = item.Amount,
                        });
                    }
                    else
                    {
                        MySandboxGame.Log.WriteLine(string.Format("No blueprint that produces a single result with Id '{0}'", item.Id));
                    }
                }
            }
            CurrentProgress = builder.CurrentProgress;
            m_disassembleEnabled = builder.DisassembleEnabled;
            m_repeatAssembleEnabled = builder.RepeatAssembleEnabled;
            m_repeatDisassembleEnabled = builder.RepeatDisassembleEnabled;
            m_slave = builder.SlaveEnabled;
            UpdateInventoryFlags();

            m_baseIdleSound = BlockDefinition.PrimarySound;
            m_processSound = BlockDefinition.ActionSound;

            OnUpgradeValuesChanged += UpdateDetailedInfo;

            ResourceSink.RequiredInputChanged += PowerReceiver_RequiredInputChanged;
            UpdateDetailedInfo();
        }