Files
2025-05-21 20:40:04 +02:00

376 lines
12 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
// Token: 0x0200007B RID: 123
public class GatherEmeraldsXP : MonoBehaviour
{
// Token: 0x06000C16 RID: 3094 RVA: 0x000ED20C File Offset: 0x000EB40C
private void Start()
{
SceneItem[] array = Object.FindObjectsByType<SceneItem>(FindObjectsSortMode.None);
BreakableActions[] array2 = Object.FindObjectsByType<BreakableActions>(FindObjectsSortMode.None);
ChestActions[] array3 = Object.FindObjectsByType<ChestActions>(FindObjectsSortMode.None);
int num = 0;
int num2 = 0;
int num3 = 0;
List<CreatureActions> list = new List<CreatureActions>();
foreach (SceneItem sceneItem in array)
{
int num4 = num;
if (sceneItem && !sceneItem.forSale)
{
string text = sceneItem.item.ToString();
if (text == "Emerald")
{
num += sceneItem.amount;
}
else
{
Library.Inventory invRowFromName = Links.x.library.GetInvRowFromName(text);
if (!invRowFromName._NeedFullStack)
{
int num5 = sceneItem.amount;
if (num5 < 1)
{
num5 = 1;
}
if (!invRowFromName._Stackable)
{
num5 = 1;
}
num += invRowFromName._SellPrice * num5;
}
}
Debug.Log(text + " ems from item " + (num - num4).ToString());
}
}
foreach (ChestActions chestActions in array3)
{
int num6 = num3;
if (chestActions)
{
List<SceneItem.xmlNames> list2 = new List<SceneItem.xmlNames>();
List<int> list3 = new List<int>();
if (chestActions.chest.item1 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item1);
list3.Add(chestActions.chest.itemStack1);
}
if (chestActions.chest.item2 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item2);
list3.Add(chestActions.chest.itemStack2);
}
if (chestActions.chest.item3 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item3);
list3.Add(chestActions.chest.itemStack3);
}
if (chestActions.chest.item4 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item4);
list3.Add(chestActions.chest.itemStack4);
}
if (chestActions.chest.item5 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item5);
list3.Add(chestActions.chest.itemStack5);
}
if (chestActions.chest.item6 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item6);
list3.Add(chestActions.chest.itemStack6);
}
if (chestActions.chest.item7 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item7);
list3.Add(chestActions.chest.itemStack7);
}
if (chestActions.chest.item8 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item8);
list3.Add(chestActions.chest.itemStack8);
}
if (chestActions.chest.item9 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item9);
list3.Add(chestActions.chest.itemStack9);
}
if (chestActions.chest.item10 != SceneItem.xmlNames.None)
{
list2.Add(chestActions.chest.item10);
list3.Add(chestActions.chest.itemStack10);
}
for (int j = 0; j < list2.Count; j++)
{
string text2 = list2[j].ToString();
Library.Inventory invRowFromName2 = Links.x.library.GetInvRowFromName(text2);
if (invRowFromName2 != null && !invRowFromName2._NeedFullStack)
{
int num7 = list3[j];
if (num7 < 1)
{
num7 = 1;
}
if (!invRowFromName2._Stackable)
{
num7 = 1;
}
num3 += invRowFromName2._SellPrice * num7;
}
if (text2 == "Emerald")
{
num3 += list3[j];
}
}
ChestActions chestActions2 = chestActions;
Debug.Log(((chestActions2 != null) ? chestActions2.ToString() : null) + " ems from item " + (num3 - num6).ToString());
}
}
foreach (BreakableActions breakableActions in array2)
{
int num8 = num2;
if (breakableActions.resourceLocation == -1)
{
string text3 = "";
string text4 = "";
string text5 = "";
string text6 = "";
if (breakableActions.breakable.itemA != SceneItem.xmlNames.None)
{
text3 = breakableActions.breakable.itemA.ToString();
}
if (breakableActions.breakable.itemB != SceneItem.xmlNames.None)
{
text4 = breakableActions.breakable.itemB.ToString();
}
if (breakableActions.breakable.itemC != SceneItem.xmlNames.None)
{
text5 = breakableActions.breakable.itemC.ToString();
}
if (breakableActions.breakable.itemD != SceneItem.xmlNames.None)
{
text6 = breakableActions.breakable.itemD.ToString();
}
if (text3 != "" && text3 != "None")
{
Library.Inventory inventory = Links.x.library.GetInvRowFromName(text3);
if (inventory != null && !inventory._NeedFullStack)
{
int num9 = breakableActions.breakable.itemStackA;
if (num9 < 1)
{
num9 = 1;
}
if (!inventory._Stackable)
{
num9 = 1;
}
num2 += inventory._SellPrice * num9;
}
if (text3 == "Emerald")
{
num2 += breakableActions.breakable.itemStackA;
}
}
if (text4 != "" && text4 != "None")
{
Library.Inventory inventory = Links.x.library.GetInvRowFromName(text4);
if (inventory != null && !inventory._NeedFullStack)
{
int num10 = breakableActions.breakable.itemStackB;
if (num10 < 1)
{
num10 = 1;
}
if (!inventory._Stackable)
{
num10 = 1;
}
num2 += inventory._SellPrice * num10;
}
if (text4 == "Emerald")
{
num2 += breakableActions.breakable.itemStackB;
}
}
if (text5 != "" && text5 != "None")
{
Library.Inventory inventory = Links.x.library.GetInvRowFromName(text5);
if (inventory != null && !inventory._NeedFullStack)
{
int num11 = breakableActions.breakable.itemStackC;
if (num11 < 1)
{
num11 = 1;
}
if (!inventory._Stackable)
{
num11 = 1;
}
num2 += inventory._SellPrice * num11;
}
if (text5 == "Emerald")
{
num2 += breakableActions.breakable.itemStackC;
}
}
if (text6 != "" && text6 != "None")
{
Library.Inventory inventory = Links.x.library.GetInvRowFromName(text6);
if (inventory != null && !inventory._NeedFullStack)
{
int num12 = breakableActions.breakable.itemStackD;
if (num12 < 1)
{
num12 = 1;
}
if (!inventory._Stackable)
{
num12 = 1;
}
num2 += inventory._SellPrice * num12;
}
if (text6 == "Emerald")
{
num2 += breakableActions.breakable.itemStackD;
}
}
if (num2 - num8 > 0)
{
BreakableActions breakableActions2 = breakableActions;
Debug.Log(((breakableActions2 != null) ? breakableActions2.ToString() : null) + " ems from breakie " + (num2 - num8).ToString());
}
}
else if (breakableActions.breakable.component != Breakable.ComponentTypes.Acorn && breakableActions.breakable.component != Breakable.ComponentTypes.Berry && breakableActions.breakable.component != Breakable.ComponentTypes.Frog && breakableActions.breakable.component != Breakable.ComponentTypes.Mushroom && breakableActions.breakable.component != Breakable.ComponentTypes.Rock && breakableActions.breakable.component != Breakable.ComponentTypes.Stick)
{
Breakable.ComponentTypes component = breakableActions.breakable.component;
}
}
int num13 = 0;
int num14 = 0;
CreatureActions[] array7 = Object.FindObjectsByType<CreatureActions>(FindObjectsSortMode.None);
foreach (CreatureActions creatureActions in array7)
{
int num15 = num13;
if (creatureActions.creatures.temperament != Creatures.temperamentState.AttacksOnSight)
{
List<Character> characters = creatureActions.characters;
foreach (Character character in characters)
{
if (character && character.hostility < 2)
{
num13 += character.stats.characterRow._XP;
int num16 = character.HasItem(2);
int num17 = 0;
if (num16 > 0)
{
num17 = character.GetInvNum(num16 + 1);
num14 += num17;
}
int num18 = character.SellPriceOfDrops();
num14 += num18;
string[] array9 = new string[5];
int num19 = 0;
Character character2 = character;
array9[num19] = ((character2 != null) ? character2.ToString() : null);
array9[1] = " sell price of drops ";
array9[2] = num18.ToString();
array9[3] = " ";
array9[4] = num17.ToString();
Debug.Log(string.Concat(array9));
}
}
if (characters.Count == 0)
{
list.Add(creatureActions);
}
}
CreatureActions creatureActions2 = creatureActions;
Debug.Log(((creatureActions2 != null) ? creatureActions2.ToString() : null) + " xp " + (num13 - num15).ToString());
}
int num20 = 0;
int num21 = 0;
int num22 = 0;
foreach (CreatureActions creatureActions3 in array7)
{
if (creatureActions3.creatures.temperament == Creatures.temperamentState.AttacksOnSight)
{
int num23 = num20;
int num24 = num22;
List<Character> characters2 = creatureActions3.characters;
int number = creatureActions3.creatures.number;
for (int k = 0; k < number; k++)
{
string text7 = creatureActions3.creatures.characterName.ToString();
Library.Characters pcrowFromName = Links.x.library.GetPCRowFromName(text7);
num20 += pcrowFromName._XP;
}
foreach (Character character3 in characters2)
{
if (character3)
{
int num25 = character3.HasItem(2);
int num26 = 0;
if (num25 > 0)
{
num26 = character3.GetInvNum(num25 + 1);
num21 += num26;
}
int num27 = character3.SellPriceOfDrops();
num21 += num27;
string[] array10 = new string[5];
int num28 = 0;
Character character4 = character3;
array10[num28] = ((character4 != null) ? character4.ToString() : null);
array10[1] = " sell price of drops ";
array10[2] = num27.ToString();
array10[3] = " ";
array10[4] = num26.ToString();
Debug.Log(string.Concat(array10));
}
}
if (characters2.Count == 0)
{
list.Add(creatureActions3);
}
CreatureActions creatureActions4 = creatureActions3;
Debug.Log(((creatureActions4 != null) ? creatureActions4.ToString() : null) + " xp " + (num20 - num23).ToString());
if (creatureActions3.creatures.wipeOutBehavior == Creatures.wipeOutState.RespawnTowerWithHostileCreature || creatureActions3.creatures.wipeOutBehavior == Creatures.wipeOutState.RespawnTowerWithPeacefulCreature)
{
string text8 = creatureActions3.creatures.afterDeathSpawns.ToString();
Library.Characters pcrowFromName2 = Links.x.library.GetPCRowFromName(text8);
num22 += pcrowFromName2._XP * number;
}
CreatureActions creatureActions5 = creatureActions3;
Debug.Log(((creatureActions5 != null) ? creatureActions5.ToString() : null) + " wipeout " + (num22 - num24).ToString());
}
}
Debug.Log("-------------------");
Debug.Log("XP from NPCs " + num20.ToString());
Debug.Log("XP from Friendlies " + num13.ToString());
Debug.Log("XP from respawns (need to multiply x .75, .5 and .25 " + num22.ToString());
Debug.Log("-------------------");
Debug.Log("Emeralds from chests " + num3.ToString());
Debug.Log("Emeralds from breakables " + num2.ToString());
Debug.Log("Emeralds from items " + num.ToString());
Debug.Log("Emeralds from Friendlies " + num14.ToString());
Debug.Log("Emeralds from NPCs " + num21.ToString());
Debug.Log("-------------------");
string text9 = "";
text9 += "Manually add emeralds from : ";
for (int l = 0; l < list.Count; l++)
{
if (l > 0)
{
text9 += ", ";
}
string text10 = text9;
CreatureActions creatureActions6 = list[l];
text9 = text10 + ((creatureActions6 != null) ? creatureActions6.ToString() : null);
}
Debug.Log(text9);
}
}