Skip to content
This repository was archived by the owner on Dec 30, 2024. It is now read-only.

Commit 8023b19

Browse files
committed
🚧 Managed to get object and agent hits working
1 parent bdc547d commit 8023b19

File tree

4 files changed

+574
-173
lines changed

4 files changed

+574
-173
lines changed

‎RogueLibs v3.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hitbox/@EntryIndexedValue">True</s:Boolean>
1919
<s:Boolean x:Key="/Default/UserDictionary/Words/=hookable/@EntryIndexedValue">True</s:Boolean>
2020
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hypnotizer/@EntryIndexedValue">True</s:Boolean>
21+
<s:Boolean x:Key="/Default/UserDictionary/Words/=impactful/@EntryIndexedValue">True</s:Boolean>
2122
<s:Boolean x:Key="/Default/UserDictionary/Words/=Interactable/@EntryIndexedValue">True</s:Boolean>
2223
<s:Boolean x:Key="/Default/UserDictionary/Words/=Jugularious/@EntryIndexedValue">True</s:Boolean>
2324
<s:Boolean x:Key="/Default/UserDictionary/Words/=Knockback/@EntryIndexedValue">True</s:Boolean>

‎RogueLibsCore.Test/Tests/Weapons/Knocker.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using UnityEngine;
7-
8-
namespace RogueLibsCore.Test
1+
namespace RogueLibsCore.Test
92
{
103
public class Knocker : CustomWeaponMelee
114
{
@@ -34,7 +27,7 @@ public override MeleeAttackInfo StartAttack()
3427
TestPlugin.Log.LogWarning("StartAttack");
3528
return new MeleeAttackInfo(MeleeAttackType.Swing, MeleeHands.Both)
3629
{
37-
Speed = 4f,
30+
Speed = 4f,
3831
CanBackstab = false,
3932
KnockForce = 0f,
4033
};
@@ -45,7 +38,8 @@ public override void EndAttack()
4538
}
4639
public override void Hit(MeleeHitArgs e)
4740
{
48-
41+
TestPlugin.Log.LogWarning("Hit");
42+
e.KnockbackStrength *= 5f;
4943
}
5044

5145
}

‎RogueLibsCore/Hooks/Items/Weapons/MeleeHitArgs.cs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ namespace RogueLibsCore
77
/// </summary>
88
public sealed class MeleeHitArgs
99
{
10-
internal MeleeHitArgs(GameObject gameObject, PlayfieldObject target)
10+
internal MeleeHitArgs(MeleePreHitArgs e)
1111
{
12-
GameObject = gameObject;
13-
Target = target;
12+
GameObject = e.GameObject;
13+
Target = e.Target;
14+
IsFirstHit = e.IsFirstHit;
15+
FromClient = e.FromClient;
1416
}
1517

1618
/// <summary>
@@ -22,30 +24,40 @@ internal MeleeHitArgs(GameObject gameObject, PlayfieldObject target)
2224
/// </summary>
2325
public PlayfieldObject Target { get; }
2426

27+
public int DamageDealt { get; internal set; }
28+
2529
// Visuals and sounds
2630
/// <summary>
2731
/// <para>Gets or sets whether to highlight the hit object for just a moment.</para>
2832
/// </summary>
2933
public bool DoFlash { get; set; }
34+
public string? Particles { get; set; }
35+
public Vector2 ParticlesPosition { get; set; }
36+
public float ParticlesAngle { get; set; }
37+
3038
/// <summary>
3139
/// <para>Gets or sets the sound that the hit should make.</para>
3240
/// </summary>
3341
public string? HitSound { get; set; }
34-
public string? Particles { get; set; }
42+
public Vector2 HitSoundPosition { get; set; }
3543
public float NoiseVolume { get; set; }
44+
public Vector2 NoisePosition { get; set; }
3645

3746
// Input response
3847
public float ScreenShakeTime { get; set; }
3948
public float ScreenShakeOffset { get; set; }
49+
public float VibrateControllerIntensity { get; set; }
50+
public float VibrateControllerTime { get; set; }
4051
public int FreezeFrames { get; set; }
41-
public float VibrateController { get; set; }
52+
public bool AlienFX { get; set; }
4253

4354
// Knockback
4455
public Vector2 KnockbackDirection { get; set; }
4556
public float KnockbackStrength { get; set; }
4657
public Vector2 RecoilDirection { get; set; }
4758
public float RecoilStrength { get; set; }
4859

60+
public bool DoOwnCheck { get; set; }
4961
public float AICombatCooldown { get; set; }
5062

5163
public int DepleteAmount { get; set; }
@@ -60,6 +72,7 @@ internal MeleeHitArgs(GameObject gameObject, PlayfieldObject target)
6072
/// <para>Determines whether this hit was the first one on this object (used with <see cref="CanHitAgain"/>).</para>
6173
/// </summary>
6274
public bool IsFirstHit { get; }
75+
public bool FromClient { get; }
6376

6477
/// <summary>
6578
/// <para>Prevents any default behaviour of the melee weapon hit.</para>
@@ -69,17 +82,18 @@ public void PreventDefault()
6982
IsDefaultPrevented = true;
7083

7184
DoFlash = false;
72-
HitSound = null;
7385
Particles = null;
86+
HitSound = null;
7487
NoiseVolume = 0f;
7588

76-
ScreenShakeTime = 0f;
7789
ScreenShakeOffset = 0f;
90+
VibrateControllerIntensity = 0f;
7891
FreezeFrames = 0;
79-
VibrateController = 0f;
92+
AlienFX = false;
8093

8194
KnockbackStrength = 0f;
8295
RecoilStrength = 0f;
96+
DoOwnCheck = false;
8397
AICombatCooldown = 0f;
8498
DepleteAmount = 0;
8599
}
@@ -89,13 +103,15 @@ public void PreventDefault()
89103
public sealed class MeleePreHitArgs
90104
{
91105
internal MeleePreHitArgs(GameObject gameObject, PlayfieldObject target,
92-
GameObject originalGameObject, PlayfieldObject originalTarget, bool isFirstHit)
106+
GameObject originalGameObject, PlayfieldObject originalTarget,
107+
bool isFirstHit, bool fromClient)
93108
{
94109
GameObject = gameObject;
95110
Target = target;
96111
OriginalGameObject = originalGameObject;
97112
OriginalTarget = originalTarget;
98113
IsFirstHit = isFirstHit;
114+
FromClient = fromClient;
99115
}
100116

101117
/// <summary>
@@ -116,12 +132,11 @@ internal MeleePreHitArgs(GameObject gameObject, PlayfieldObject target,
116132
public bool IgnoreLineOfSight { get; set; }
117133
public bool IgnoreAlignedCheck { get; set; }
118134

119-
120-
121135
/// <summary>
122136
/// <para>Determines whether this hit was the first one on this object (used with <see cref="CanHitAgain"/>).</para>
123137
/// </summary>
124138
public bool IsFirstHit { get; }
139+
public bool FromClient { get; }
125140

126141
/// <summary>
127142
/// <para>Prevents any default behaviour of the melee weapon.</para>

0 commit comments

Comments
 (0)