Upload from upload_mods.ps1
This commit is contained in:
464
Harmony/Harmony_CropsGrown.cs
Normal file
464
Harmony/Harmony_CropsGrown.cs
Normal file
@@ -0,0 +1,464 @@
|
||||
using Audio;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.CropsGrownPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockCropsGrown))]
|
||||
[HarmonyPatch("HasBlockActivationCommands")]
|
||||
public class HasBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockCropsGrown __instance, ref bool __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing)
|
||||
{
|
||||
__result = RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _clrIdx);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockCropsGrown), "OnBlockActivated", new Type[] { typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue), typeof(EntityPlayerLocal) })]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
//public static MethodInfo setPlantBackToBaby = AccessTools.Method(typeof(BlockCropsGrown), "setPlantBackToBaby", new Type[] { typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue) });
|
||||
|
||||
public static bool Prefix(BlockCropsGrown __instance, ref bool __result, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated START");
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 1");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Block.SItemDropProb> list = null;
|
||||
int num = 0;
|
||||
|
||||
if (__instance.itemsToDrop.TryGetValue(EnumDropEvent.Harvest, out list) && (num = Utils.FastMax(0, list[0].minCount)) > 0)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated A num: " + num);
|
||||
|
||||
if (_blockPos.y > 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 2");
|
||||
int num2 = (int)(_world.GetBlock(_blockPos - Vector3i.up).Block.blockMaterial.FertileLevel / __instance.bonusHarvestDivisor);
|
||||
num += num2;
|
||||
}
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated B num: " + num);
|
||||
|
||||
int numType = 0;
|
||||
int numAdd = 0;
|
||||
string strBlockName = _blockValue.Block.GetBlockName();
|
||||
|
||||
if (strBlockName == "plantedMushroom3Harvest" ||
|
||||
strBlockName == "mushroom01" ||
|
||||
strBlockName == "mushroom02" ||
|
||||
strBlockName == "plantedYucca3Harvest" ||
|
||||
strBlockName == "plantedCotton3Harvest" ||
|
||||
strBlockName == "plantedCoffee3Harvest" ||
|
||||
strBlockName == "plantedGoldenrod3Harvest" ||
|
||||
strBlockName == "plantedAloe3Harvest" ||
|
||||
strBlockName == "plantedBlueberry3Harvest" ||
|
||||
strBlockName == "plantedPotato3Harvest" ||
|
||||
strBlockName == "plantedChrysanthemum3Harvest" ||
|
||||
strBlockName == "plantedCorn3Harvest" ||
|
||||
strBlockName == "plantedGraceCorn3Harvest" ||
|
||||
strBlockName == "plantedHop3Harvest" ||
|
||||
strBlockName == "plantedSnowberry3Harvest" ||
|
||||
strBlockName == "plantedPumpkin3Harvest" ||
|
||||
strBlockName == "plantedCorn2Deco"
|
||||
)
|
||||
{
|
||||
numType = 1;
|
||||
//Log.Out("TYPE 1");
|
||||
}
|
||||
else if (strBlockName == "plantedMushroom3Harvest" ||
|
||||
strBlockName == "plantedMushroom3HarvestPlayer" ||
|
||||
strBlockName == "plantedYucca3HarvestPlayer" ||
|
||||
strBlockName == "plantedCotton3HarvestPlayer" ||
|
||||
strBlockName == "plantedCoffee3HarvestPlayer" ||
|
||||
strBlockName == "plantedGoldenrod3HarvestPlayer" ||
|
||||
strBlockName == "plantedAloe3HarvestPlayer" ||
|
||||
strBlockName == "plantedBlueberry3HarvestPlayer" ||
|
||||
strBlockName == "plantedPotato3HarvestPlayer" ||
|
||||
strBlockName == "plantedChrysanthemum3HarvestPlayer" ||
|
||||
strBlockName == "plantedCorn3HarvestPlayer" ||
|
||||
strBlockName == "plantedGraceCorn3HarvestPlayer" ||
|
||||
strBlockName == "plantedHop3HarvestPlayer" ||
|
||||
strBlockName == "plantedSnowberry3HarvestPlayer" ||
|
||||
strBlockName == "plantedPumpkin3HarvestPlayer"
|
||||
)
|
||||
{
|
||||
numType = 2;
|
||||
//Log.Out("TYPE 2");
|
||||
}
|
||||
//else
|
||||
//{
|
||||
//Log.Out("NO TYPE");
|
||||
//}
|
||||
|
||||
ProgressionValue progressionValue1 = _player.Progression.GetProgressionValue("perkLivingOffTheLand");
|
||||
ProgressionValue progressionValue2 = _player.Progression.GetProgressionValue("FuriousRamsayAchievementCrops");
|
||||
|
||||
if (progressionValue1 != null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3, progressionValue1: " + progressionValue1.Level);
|
||||
if (progressionValue1.Level == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3a");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3b");
|
||||
numAdd++;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3c");
|
||||
numAdd += 0; // 0 ?? Are you sure? ^^
|
||||
}
|
||||
}
|
||||
else if (progressionValue1.Level == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3d");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3e");
|
||||
numAdd++;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3f");
|
||||
numAdd++;
|
||||
}
|
||||
}
|
||||
else if (progressionValue1.Level == 3)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3g");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3h");
|
||||
numAdd += 2;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3i");
|
||||
numAdd++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (progressionValue2 != null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4, progressionValue2: " + progressionValue2.Level);
|
||||
if (progressionValue2.Level == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4a");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4b");
|
||||
numAdd = numAdd + 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4c");
|
||||
numAdd = numAdd + 0;
|
||||
}
|
||||
}
|
||||
else if (progressionValue2.Level == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4d");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4e");
|
||||
numAdd = numAdd + 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4f");
|
||||
numAdd += 1;
|
||||
}
|
||||
}
|
||||
else if (progressionValue2.Level == 3)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4g");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4h");
|
||||
numAdd += 2;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4i");
|
||||
numAdd += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
num += numAdd;
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated C num: " + num);
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated numType: " + numType + ", numAdd: " + numAdd + ", Index: " + _cIdx);
|
||||
|
||||
if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 5");
|
||||
if (!__instance.DowngradeBlock.isair)
|
||||
{
|
||||
////Log.Out("BlockCropsGrownRebirth-OnBlockActivated DOWNGRADE: " + this.DowngradeBlock.Block.GetBlockName());
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated POSITION X: " + _blockPos.x + ", Y: " + _blockPos.y + ", Z: " + _blockPos.z);
|
||||
|
||||
BlockValue blockValue2 = __instance.DowngradeBlock;
|
||||
blockValue2 = BlockPlaceholderMap.Instance.Replace(blockValue2, _world.GetGameRandom(), _blockPos.x, _blockPos.z);
|
||||
blockValue2.rotation = _blockValue.rotation;
|
||||
blockValue2.meta = _blockValue.meta;
|
||||
Block block4 = blockValue2.Block;
|
||||
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_cIdx];
|
||||
chunkCluster.InvokeOnBlockDamagedDelegates(_blockPos, _blockValue, 9999, _player.entityId);
|
||||
|
||||
if (!block4.shape.IsTerrain())
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 1");
|
||||
_world.SetBlockRPC(_cIdx, _blockPos, blockValue2);
|
||||
|
||||
if (chunkCluster.GetTextureFull(_blockPos) != 0L)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 2");
|
||||
if (__instance.RemovePaintOnDowngrade == null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3");
|
||||
GameManager.Instance.SetBlockTextureServer(_blockPos, BlockFace.None, 0, _player.entityId);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4");
|
||||
for (int i = 0; i < __instance.RemovePaintOnDowngrade.Count; i++)
|
||||
{
|
||||
GameManager.Instance.SetBlockTextureServer(_blockPos, __instance.RemovePaintOnDowngrade[i], 0, _player.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 5");
|
||||
_world.SetBlockRPC(_cIdx, _blockPos, blockValue2, block4.Density);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 6, num: " + num);
|
||||
|
||||
ItemStack itemStack = new ItemStack(ItemClass.GetItem(list[0].name, false), num);
|
||||
ItemStack @is = itemStack.Clone();
|
||||
|
||||
if ((_player.inventory.CanStackNoEmpty(itemStack) && _player.inventory.AddItem(itemStack)) || _player.bag.AddItem(itemStack) || _player.inventory.AddItem(itemStack))
|
||||
{
|
||||
_player.PlayOneShot("item_plant_pickup", false);
|
||||
|
||||
if (numType == 1)
|
||||
{
|
||||
__instance.setPlantBackToBaby(_world, _cIdx, _blockPos, _blockValue);
|
||||
QuestEventManager.Current.BlockPickedUp(_blockValue.Block.GetBlockName(), _blockPos);
|
||||
}
|
||||
|
||||
if (_player is EntityPlayerLocal)
|
||||
{
|
||||
_player.AddUIHarvestingItem(@is, false);
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Manager.PlayInsidePlayerHead("ui_denied", -1, 0f, false);
|
||||
}
|
||||
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockCropsGrown), "GetActivationText")]
|
||||
public class GetActivationTextPatch
|
||||
{
|
||||
public static bool Prefix(BlockCropsGrown __instance, ref string __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
if (_world.IsEditor()) return true;
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText START");
|
||||
List<Block.SItemDropProb> list = null;
|
||||
int num;
|
||||
|
||||
if (__instance.itemsToDrop.TryGetValue(EnumDropEvent.Harvest, out list) && (num = Utils.FastMax(0, list[0].minCount)) > 0)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 1");
|
||||
if (_blockPos.y > 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 2");
|
||||
int num2 = (int)(_world.GetBlock(_blockPos - Vector3i.up).Block.blockMaterial.FertileLevel / __instance.bonusHarvestDivisor);
|
||||
num += num2;
|
||||
}
|
||||
|
||||
int numType = 0;
|
||||
int numAdd = 0;
|
||||
string strBlockName = _blockValue.Block.GetBlockName();
|
||||
|
||||
if (strBlockName == "plantedMushroom3Harvest" ||
|
||||
strBlockName == "mushroom01" ||
|
||||
strBlockName == "mushroom02" ||
|
||||
strBlockName == "plantedYucca3Harvest" ||
|
||||
strBlockName == "plantedCotton3Harvest" ||
|
||||
strBlockName == "plantedCoffee3Harvest" ||
|
||||
strBlockName == "plantedGoldenrod3Harvest" ||
|
||||
strBlockName == "plantedAloe3Harvest" ||
|
||||
strBlockName == "plantedBlueberry3Harvest" ||
|
||||
strBlockName == "plantedPotato3Harvest" ||
|
||||
strBlockName == "plantedChrysanthemum3Harvest" ||
|
||||
strBlockName == "plantedCorn3Harvest" ||
|
||||
strBlockName == "plantedGraceCorn3Harvest" ||
|
||||
strBlockName == "plantedHop3Harvest" ||
|
||||
strBlockName == "plantedSnowberry3Harvest" ||
|
||||
strBlockName == "plantedPumpkin3Harvest" ||
|
||||
strBlockName == "plantedCorn2Deco"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 3");
|
||||
numType = 1;
|
||||
}
|
||||
else if (strBlockName == "plantedMushroom3Harvest" ||
|
||||
strBlockName == "plantedMushroom3HarvestPlayer" ||
|
||||
strBlockName == "plantedYucca3HarvestPlayer" ||
|
||||
strBlockName == "plantedCotton3HarvestPlayer" ||
|
||||
strBlockName == "plantedCoffee3HarvestPlayer" ||
|
||||
strBlockName == "plantedGoldenrod3HarvestPlayer" ||
|
||||
strBlockName == "plantedAloe3HarvestPlayer" ||
|
||||
strBlockName == "plantedBlueberry3HarvestPlayer" ||
|
||||
strBlockName == "plantedPotato3HarvestPlayer" ||
|
||||
strBlockName == "plantedChrysanthemum3HarvestPlayer" ||
|
||||
strBlockName == "plantedCorn3HarvestPlayer" ||
|
||||
strBlockName == "plantedGraceCorn3HarvestPlayer" ||
|
||||
strBlockName == "plantedHop3HarvestPlayer" ||
|
||||
strBlockName == "plantedSnowberry3HarvestPlayer" ||
|
||||
strBlockName == "plantedPumpkin3HarvestPlayer"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 4");
|
||||
numType = 2;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 5");
|
||||
//}
|
||||
|
||||
ProgressionValue progressionValue1 = _entityFocusing.Progression.GetProgressionValue("perkLivingOffTheLand");
|
||||
ProgressionValue progressionValue2 = _entityFocusing.Progression.GetProgressionValue("FuriousRamsayAchievementCrops");
|
||||
|
||||
if (progressionValue1 != null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 6");
|
||||
if (progressionValue1.Level == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 7");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 8");
|
||||
numAdd += 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 9");
|
||||
numAdd += 0; // 0 again ??
|
||||
}
|
||||
}
|
||||
else if (progressionValue1.Level == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 10");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 11");
|
||||
numAdd += 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 12");
|
||||
numAdd += 1;
|
||||
}
|
||||
}
|
||||
else if (progressionValue1.Level == 3)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 13");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 14");
|
||||
numAdd += 2;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 15");
|
||||
numAdd += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (progressionValue2 != null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 16");
|
||||
if (progressionValue2.Level == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 17");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 18");
|
||||
numAdd += 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 19");
|
||||
numAdd += 0;
|
||||
}
|
||||
}
|
||||
else if (progressionValue2.Level == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 20");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 21");
|
||||
numAdd += 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 22");
|
||||
numAdd += 1;
|
||||
}
|
||||
}
|
||||
else if (progressionValue2.Level == 3)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 23");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 24");
|
||||
numAdd += 2;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 25");
|
||||
numAdd += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
num += numAdd;
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText END 1");
|
||||
|
||||
__result = string.Format(Localization.Get("pickupCrops"), num, Localization.Get(list[0].name));
|
||||
return false;
|
||||
}
|
||||
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user