public static void OnDoUpgragePre(PlayerAction_Build __instance, int objId, int grade, int upgrade) { if (UndoManager.IgnoreAllEvents.Value) { return; } if (NebulaModAPI.IsMultiplayerActive) { if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient) { return; } } if (!RecordUpgrades) { return; } if (objId == 0) { return; } if (upgradeIds.Contains(objId)) { return; } upgradeIds.Add(objId); ItemProto itemProto = __instance.noneTool.GetItemProto(objId); if (itemProto != null && itemProto.canUpgrade) { int oldGrade = itemProto.Grade; ItemProto newItemProto = itemProto; if (grade > 0) { newItemProto = itemProto.GetGradeItem(grade); } else if (upgrade != 0) { newItemProto = itemProto.GetUpgradeItem(upgrade); } upgradeList.Add(new UpgradeData(objId, oldGrade, newItemProto.Grade)); } }