Esempio n. 1
0
        private void ChangeRequirementsToResults(MyBlueprintDefinitionBase queueItem, MyFixedPoint blueprintAmount)
        {
            Debug.Assert(Sync.IsServer);

            if (!MySession.Static.CreativeMode)
            {
                blueprintAmount = MyFixedPoint.Min(OutputInventory.ComputeAmountThatFits(queueItem), blueprintAmount);
            }
            if (blueprintAmount == 0)
            {
                return;
            }

            foreach (var prerequisite in queueItem.Prerequisites)
            {
                var obPrerequisite     = (MyObjectBuilder_PhysicalObject)Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.CreateNewObject(prerequisite.Id);
                var prerequisiteAmount = blueprintAmount * prerequisite.Amount;
                InputInventory.RemoveItemsOfType(prerequisiteAmount, obPrerequisite);
            }

            foreach (var result in queueItem.Results)
            {
                var resultId     = result.Id;
                var obResult     = (MyObjectBuilder_PhysicalObject)Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.CreateNewObject(resultId);
                var resultAmount = blueprintAmount * result.Amount * m_refineryDef.MaterialEfficiency * UpgradeValues["Effectiveness"];
                OutputInventory.AddItems(resultAmount, obResult);
            }

            RemoveFirstQueueItemAnnounce(blueprintAmount);
        }
Esempio n. 2
0
        private void ChangeRequirementsToResults(MyBlueprintDefinitionBase queueItem, MyFixedPoint blueprintAmount)
        {
            Debug.Assert(Sync.IsServer);

            Debug.Assert(m_refineryDef != null, "m_refineryDef shouldn't be null!!!");

            if (Sync.IsServer == false)
            {
                return;
            }

            if (MySession.Static == null || queueItem == null || queueItem.Prerequisites == null || OutputInventory == null || InputInventory == null || queueItem.Results == null)
            {
                return;
            }

            if (!MySession.Static.CreativeMode)
            {
                blueprintAmount = MyFixedPoint.Min(OutputInventory.ComputeAmountThatFits(queueItem), blueprintAmount);
            }

            if (blueprintAmount == 0)
            {
                return;
            }

            foreach (var prerequisite in queueItem.Prerequisites)
            {
                var obPrerequisite = (MyObjectBuilder_PhysicalObject)MyObjectBuilderSerializer.CreateNewObject(prerequisite.Id);
                if (obPrerequisite == null)
                {
                    Debug.Fail("obPrerequisite shouldn't be null!!!");
                    continue;
                }
                var prerequisiteAmount = blueprintAmount * prerequisite.Amount;
                InputInventory.RemoveItemsOfType(prerequisiteAmount, obPrerequisite);
            }

            foreach (var result in queueItem.Results)
            {
                var resultId = result.Id;
                var obResult = (MyObjectBuilder_PhysicalObject)MyObjectBuilderSerializer.CreateNewObject(resultId);
                if (obResult == null)
                {
                    Debug.Fail("obResult shouldn't be null!!!");
                    continue;
                }
                var conversionRatio = result.Amount * m_refineryDef.MaterialEfficiency * UpgradeValues["Effectiveness"];
                if (conversionRatio > (MyFixedPoint)1.0f)
                {
                    conversionRatio = (MyFixedPoint)1.0f;
                }

                var resultAmount = blueprintAmount * conversionRatio;
                OutputInventory.AddItems(resultAmount, obResult);
            }

            RemoveFirstQueueItemAnnounce(blueprintAmount);
        }