public virtual void SerializeItem(Item item, DM_Item holder) { holder.gameObjectName = item.gameObject.name; holder.ItemID = item.ItemID; holder.Name = item.Name; holder.Description = item.Description; holder.LegacyItemID = item.LegacyItemID; holder.CastLocomotionEnabled = item.CastLocomotionEnabled; holder.CastModifier = item.CastModifier; holder.CastSheatheRequired = item.CastSheathRequired; holder.GroupItemInDisplay = item.GroupItemInDisplay; holder.HasPhysicsWhenWorld = item.HasPhysicsWhenWorld; holder.IsPickable = item.IsPickable; holder.IsUsable = item.IsUsable; holder.QtyRemovedOnUse = item.QtyRemovedOnUse; holder.MobileCastMovementMult = item.MobileCastMovementMult; holder.RepairedInRest = item.RepairedInRest; holder.BehaviorOnNoDurability = item.BehaviorOnNoDurability; holder.OverrideSellModifier = (float)At.GetField(item, "m_overrideSellModifier"); if (item.GetComponent <Perishable>() is Perishable perish) { float perishRate = perish.DepletionRate * 0.03333333f; float perishModifier = 1 / perishRate; var remainingTicks = item.MaxDurability * perishModifier; // each tick is 2 in-game minutes (~5 seconds irl) var minutes = remainingTicks * 2; TimeSpan t = TimeSpan.FromMinutes(minutes); holder.PerishTime = $"{t.Days} Days, {t.Hours} Hours, {t.Minutes} Minutes, {t.Seconds} Seconds"; } holder.CastType = (Character.SpellCastType)At.GetField(item, "m_activateEffectAnimType"); if (item.GetComponent <ItemStats>() is ItemStats stats) { holder.StatsHolder = DM_ItemStats.ParseItemStats(stats); } if (item.Tags != null) { foreach (Tag tag in item.Tags) { holder.Tags.Add(tag.TagName); ListManager.AddTagSource(tag, Serializer.SafeName(item.Name)); } } foreach (Transform child in item.transform) { var effectsChild = DM_EffectTransform.ParseTransform(child); if (effectsChild.ChildEffects.Count > 0 || effectsChild.Effects.Count > 0 || effectsChild.EffectConditions.Count > 0) { holder.EffectTransforms.Add(effectsChild); } } }
public virtual void SerializeStats(ItemStats stats, DM_ItemStats holder) { holder.BaseValue = stats.BaseValue; holder.MaxDurability = stats.MaxDurability; holder.RawWeight = stats.RawWeight; }