Files
7d2dXG/Mods/zzz_REBIRTH__Utils/Harmony/Harmony_JunkSledgeFireController.cs
Nathaniel Cosford e06f2bd282 Add All Mods
2025-05-29 23:33:28 +09:30

81 lines
3.7 KiB
C#

namespace Harmony.JunkSledgeFireControllerPatches
{
[HarmonyPatch(typeof(JunkSledgeFireController))]
[HarmonyPatch("hitTarget")]
public class hitTargetPatch
{
public static bool Prefix(ref JunkSledgeFireController __instance,
DamageMultiplier ___damageMultiplier
)
{
//Log.Out("JunkSledgeFireControllerPatches-hitTarget START");
Vector3 position = __instance.Cone.transform.position;
global::EntityAlive holdingEntity = GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as global::EntityAlive;
float maxDistance = __instance.MaxDistance;
Vector3 vector = __instance.Cone.transform.forward;
vector *= -1f;
Ray ray = new Ray(position + Origin.position, vector);
Voxel.Raycast(GameManager.Instance.World, ray, maxDistance, -538750981, 128, 0.15f);
ItemValue itemValue = __instance.entityTurret.OriginalItemValue;
//Log.Out("JunkSledgeFireControllerPatches-hitTarget itemValue (BEFORE): " + itemValue.ItemClass.GetItemName());
global::EntityAlive myOwner = GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as global::EntityAlive;
ItemValue getItemValue = null;
if (myOwner != null)
{
//Log.Out("JunkSledgeFireControllerPatches-hitTarget myOwner: " + myOwner.EntityClass.entityClassName);
getItemValue = RebirthUtilities.GetItemValue(myOwner, "JunkTurret", __instance.entityTurret.EntityClass.entityClassName);
}
else
{
//Log.Out("JunkSledgeFireControllerPatches-hitTarget myOwner == null");
}
if (getItemValue != null)
{
itemValue = getItemValue;
}
//Log.Out("JunkSledgeFireControllerPatches-hitTarget itemValue (AFTER): " + itemValue.ItemClass.GetItemName());
ItemActionAttack.Hit(Voxel.voxelRayHitInfo.Clone(),
__instance.entityTurret.belongsPlayerId,
EnumDamageTypes.Bashing,
__instance.GetDamageBlock(
itemValue,
BlockValue.Air,
holdingEntity,
1),
__instance.GetDamageEntity(
itemValue,
holdingEntity,
1),
1f,
itemValue.PercentUsesLeft,
0f,
0f,
"metal",
___damageMultiplier,
__instance.buffActions,
new ItemActionAttack.AttackHitInfo(),
1,
0,
0f,
null,
null,
ItemActionAttack.EnumAttackMode.RealNoHarvesting,
null,
__instance.entityTurret.entityId,
itemValue
);
return false;
}
}
}