Upload from upload_mods.ps1
This commit is contained in:
178
Harmony/Harmony_BlockWorkstation.cs
Normal file
178
Harmony/Harmony_BlockWorkstation.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
namespace Harmony.BlockWorkstationPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(BlockWorkstation))]
|
||||
[HarmonyPatch("PlaceBlock")]
|
||||
public class PlaceBlockPatch
|
||||
{
|
||||
public static void Postfix(BlockWorkstation __instance, WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
TileEntityWorkstation tileEntity = (TileEntityWorkstation)_world.GetTileEntity(_result.blockPos);
|
||||
if (tileEntity != null)
|
||||
{
|
||||
tileEntity.entityId = _ea.entityId;
|
||||
tileEntity.setModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockWorkstation))]
|
||||
[HarmonyPatch("GetBlockActivationCommands")]
|
||||
public class GetBlockActivationCommandsPatch
|
||||
{
|
||||
public static bool Prefix(BlockWorkstation __instance, ref BlockActivationCommand[] __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
bool flag1 = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer());
|
||||
TileEntityWorkstation tileEntity = (TileEntityWorkstation)_world.GetTileEntity(_blockPos);
|
||||
bool flag2 = false;
|
||||
bool flag3 = false;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
flag2 = tileEntity.IsPlayerPlaced;
|
||||
flag3 = tileEntity.entityId == _entityFocusing.entityId;
|
||||
}
|
||||
|
||||
__instance.cmds[1].enabled = ((flag1 & flag2) || flag3) && (double)__instance.TakeDelay > 0.0;
|
||||
__result = __instance.cmds;
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("OnBlockEntityTransformAfterActivated")]
|
||||
public class OnBlockEntityTransformAfterActivatedPatch
|
||||
{
|
||||
public static bool Prefix(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated START");
|
||||
|
||||
if (_blockValue.Block.Properties.Values.ContainsKey("HasAnim"))
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated HAS ANIM");
|
||||
|
||||
if (_ebcd != null)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated GetBlockName(): " + _ebcd.blockValue.Block.GetBlockName());
|
||||
if (_ebcd.bHasTransform)
|
||||
{
|
||||
Animator[] componentsInChildren = _ebcd.transform.GetComponentsInChildren<Animator>();
|
||||
if (componentsInChildren != null)
|
||||
{
|
||||
for (int i = componentsInChildren.Length - 1; i >= 0; i--)
|
||||
{
|
||||
Animator animator = componentsInChildren[i];
|
||||
animator.enabled = true;
|
||||
|
||||
if (_blockValue.meta != 0)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated TURN ON");
|
||||
animator.enabled = true;
|
||||
animator.SetBool("isOn", true);
|
||||
}
|
||||
else if (_blockValue.meta == 0)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated TURN OFF");
|
||||
animator.SetBool("isOn", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform transform2 = GameUtils.FindDeepChild(_ebcd.transform, "Audio");
|
||||
if (transform2 != null)
|
||||
{
|
||||
if (_blockValue.meta != 0)
|
||||
{
|
||||
transform2.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform2.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated NO TRANSFORM");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated NO BLOCK INFO, _blockValue: " + _blockValue.Block.GetBlockName());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockWorkstation))]
|
||||
[HarmonyPatch("checkParticles")]
|
||||
public class checkParticlesPatch
|
||||
{
|
||||
public static bool Prefix(BlockWorkstation __instance, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles START");
|
||||
|
||||
if (_blockValue.Block.Properties.Values.ContainsKey("HasAnim"))
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles HAS ANIM");
|
||||
|
||||
BlockEntityData _ebcd = ((World)_world).ChunkClusters[_clrIdx].GetBlockEntity(_blockPos);
|
||||
|
||||
if (_ebcd != null)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles GetBlockName(): " + _ebcd.blockValue.Block.GetBlockName());
|
||||
if (_ebcd.bHasTransform)
|
||||
{
|
||||
Animator[] componentsInChildren = _ebcd.transform.GetComponentsInChildren<Animator>();
|
||||
if (componentsInChildren != null)
|
||||
{
|
||||
for (int i = componentsInChildren.Length - 1; i >= 0; i--)
|
||||
{
|
||||
Animator animator = componentsInChildren[i];
|
||||
animator.enabled = true;
|
||||
|
||||
if (_blockValue.meta != 0)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated TURN ON");
|
||||
animator.enabled = true;
|
||||
animator.SetBool("isOn", true);
|
||||
}
|
||||
else if (_blockValue.meta == 0)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated TURN OFF");
|
||||
animator.SetBool("isOn", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform transform2 = GameUtils.FindDeepChild(_ebcd.transform, "Audio");
|
||||
if (transform2 != null)
|
||||
{
|
||||
if (_blockValue.meta != 0)
|
||||
{
|
||||
transform2.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform2.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles NO TRANSFORM");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles NO BLOCK INFO, _blockValue: " + _blockValue.Block.GetBlockName());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user