Skip to content

Commit 8bd3301

Browse files
author
dath
committed
ADD: attack event (no damage is synced yet)
1 parent 2b0502f commit 8bd3301

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

ScavMulti/MainExperiment.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System;
22
using System.Collections.Generic;
3+
using HarmonyLib;
34
using ScavMulti.Network.Messages;
45
using UnityEngine;
56

67
namespace ScavMulti;
78

9+
[HarmonyPatch]
810
/// <summary>
911
/// represents the Expie that is YOU, the player on this computer
1012
/// </summary>
@@ -36,4 +38,15 @@ void LateUpdate()
3638
}
3739
Events.Clear();
3840
}
41+
42+
[HarmonyPrefix]
43+
[HarmonyPatch(typeof(global::Body), nameof(global::Body.Attack))]
44+
static void Body_Attack_Prefix(global::Body __instance)
45+
{
46+
if (MessageDispatcher.IsAvailable && __instance == MainExperiment.Instance.Body)
47+
{
48+
if (__instance.conscious && __instance.attackCooldown <= 0f)
49+
MainExperiment.Instance.Events.Add(new AttackEvent());
50+
}
51+
}
3952
}

ScavMulti/OtherExperiment.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using UnityEngine;
3+
using HarmonyLib;
34
using ScavMulti.Network.Messages;
45

56
namespace ScavMulti;
67

8+
[HarmonyPatch]
79
/// <summary>
810
/// represents any Expie that is NOT you, the player on this computer
911
/// </summary>
@@ -39,6 +41,18 @@ public void HandleUpdate(ExpieUpdate expieUpdate)
3941
}
4042
}
4143

44+
[HarmonyPrefix]
45+
[HarmonyPatch(typeof(global::Body), nameof(global::Body.Attack))]
46+
static void Body_Attack_Prefix(global::Body __instance, global::AttackInfo atk)
47+
{
48+
if (MessageDispatcher.IsAvailable && __instance != MainExperiment.Instance.Body)
49+
{
50+
// only show the animation and "disable" the damage done
51+
atk.distance = 0;
52+
atk.damage = 0;
53+
}
54+
}
55+
4256
public static OtherExperiment CreateInstance(int id, Vector3 position)
4357
{
4458
if (!_baseBody)

0 commit comments

Comments
 (0)