Exemple #1
0
        private float ComputeMaxPossibleIntegrity(out ConstructableComponentDefinition.CcComponent requiredComponent,
                                                  out int requiredCount)
        {
            requiredComponent = default(ConstructableComponentDefinition.CcComponent);
            requiredCount     = 0;

            _tmpStockpile.Items.Clear();
            if (_stockpile != null)
            {
                foreach (var k in _stockpile.Items)
                {
                    _tmpStockpile.AddItem(k.Key, k.Value);
                }
            }

            var availableComponents = 0;

            foreach (var c in Definition.Components)
            {
                var removed = _tmpStockpile.RemoveItemFuzzy(c.Required, c.Count);
                availableComponents += removed;
                if (removed == c.Count)
                {
                    continue;
                }
                requiredComponent = c;
                requiredCount     = c.Count - removed;
                break;
            }

            _tmpStockpile.Clear();
            return(availableComponents * Definition.MaxIntegrity / Definition.TotalComponents);
        }
Exemple #2
0
        public void IncreaseIntegrity(float hammerTime, out ConstructableComponentDefinition.CcComponent requiredComponent, out int requiredCount)
        {
            var di           = hammerTime * Definition.IntegrityPerSecond;
            var maxIntegrity = ComputeMaxPossibleIntegrity(out requiredComponent, out requiredCount);

            if (maxIntegrity >= BuildIntegrity + di)
            {
                requiredComponent = default(ConstructableComponentDefinition.CcComponent);
                requiredCount     = 0;
            }

            BuildIntegrity = Math.Min(maxIntegrity, BuildIntegrity + di);
        }