-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVibrationModule.cs
78 lines (62 loc) · 2.45 KB
/
VibrationModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraplug.Config;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;
using static Terraria.Player;
namespace Terraplug
{
internal class VibrationModule : ModPlayer
{
public bool RespondToAttacks(Player player)
{
return ModContent.GetInstance<TerraplugConfig>().RespondToAttacks;
}
public bool RespondToHits(Player player)
{
return ModContent.GetInstance<TerraplugConfig>().RespondToHits;
}
public bool RespondToDeath(Player player)
{
return ModContent.GetInstance<TerraplugConfig>().RespondToDeath;
}
public override void OnEnterWorld()
{
Task.Run(() => VibrationController.ConnectAsync());
Terraria.Main.NewText("Terraplug has connected! enjoy~ >:3", 255, 180, 234);
}
public override void OnHitAnything(float x, float y, Entity victim)
{
int time = ModContent.GetInstance<TerraplugConfig>().AttackDuration;
float strength = ModContent.GetInstance<TerraplugConfig>().AttackStrength;
if (ModContent.GetInstance<TerraplugConfig>().RespondToAttacks)
{
Task.Run(() => VibrationController.Vibrate(strength, time));
}
}
public override void OnHurt(HurtInfo info)
{
int time = ModContent.GetInstance<TerraplugConfig>().HitDuration;
float strength = ModContent.GetInstance<TerraplugConfig>().HitStrength;
if (ModContent.GetInstance<TerraplugConfig>().RespondToHits)
{
Task.Run(() => VibrationController.Vibrate(strength, time));
}
}
public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
{
int time = ModContent.GetInstance<TerraplugConfig>().DeathDuration;
float strength = ModContent.GetInstance<TerraplugConfig>().deathStrength;
if (ModContent.GetInstance<TerraplugConfig>().RespondToDeath)
{
Task.Run(() => VibrationController.Vibrate(strength, time));
}
}
public override void PreSavePlayer()
=> Task.Run(VibrationController.DisconnectAsync);
}
}