Beispiel #1
0
 /// <summary>
 /// When the reactor completely shut downs, it will destroy all modules
 /// that have remaining durability below 1%.
 /// </summary>
 private static void ServerOnReactorShutdown(ObjectGeneratorPragmiumReactorPrivateState reactorPrivateState)
 {
     foreach (var item in reactorPrivateState.ItemsContainer.Items.ToList())
     {
         if (item.ProtoGameObject is ProtoItemReactorModule &&
             ItemDurabilitySystem.SharedGetDurabilityPercent(item) < 1)
         {
             ItemDurabilitySystem.ServerBreakItem(item);
         }
     }
 }
        public static double SharedCalculateResultDurabilityFraction(
            IItem inputItem1,
            IItem inputItem2,
            ICharacter character)
        {
            var result = ItemDurabilitySystem.SharedGetDurabilityPercent(inputItem1)
                         + ItemDurabilitySystem.SharedGetDurabilityPercent(inputItem2)
                         + SkillMaintenance.SharedGetCurrentBonusPercent(character);

            result = MathHelper.Clamp(result, 0, 100);
            return(result / 100.0);
        }
Beispiel #3
0
        private void Refresh()
        {
            if (this.IsDisposed)
            {
                return;
            }

            var character = ClientCurrentCharacterHelper.Character;
            if (ClientCurrentCharacterFinalStatsHelper.FinalStatsCache.IsDirty)
            {
                // refresh will be called again automatically when the new final stats cache is assigned
                return;
            }

            this.PercentSkillText = SkillMaintenance.SharedGetCurrentBonusPercent(character) + "%";

            var inputItem1 = this.containerInput.GetItemAtSlot(0);
            this.PercentInput1Text = GetDurabilityPercentText(inputItem1);

            var inputItem2 = this.containerInput.GetItemAtSlot(1);
            this.PercentInput2Text = GetDurabilityPercentText(inputItem2);

            var outputItem = this.containerOutput.GetItemAtSlot(0);
            if (outputItem != null)
            {
                this.PercentOutputText = string.Empty;
                return;
            }
            else
            {
                if (inputItem1 == null
                    || inputItem2 == null)
                {
                    this.PercentOutputText = "?";
                }
                else
                {
                    var resultPercent = ObjectTinkerTable.SharedCalculateResultDurabilityFraction(inputItem1,
                                                                                                  inputItem2,
                                                                                                  character);
                    this.PercentOutputText = (byte)(100 * resultPercent) + "%";
                }
            }

            string GetDurabilityPercentText(IItem item) =>
                item == null
                    ? string.Empty
                    : ItemDurabilitySystem.SharedGetDurabilityPercent(item) + "%";
        }
 static string GetDurabilityPercentText(IItem item)
 => item == null ||
 !(item.ProtoItem is IProtoItemWithDurability)
            ? string.Empty
            : ItemDurabilitySystem.SharedGetDurabilityPercent(item) + "%";