-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
HEROsModModPlayer.cs
108 lines (97 loc) · 2.91 KB
/
HEROsModModPlayer.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using HEROsMod.HEROsModNetwork;
using HEROsMod.HEROsModServices;
using HEROsMod.UIKit;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.DataStructures;
using Terraria.GameInput;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using Terraria.UI;
namespace HEROsMod
{
public class HEROsModModPlayer : ModPlayer
{
// public override bool Autoload(ref string name) => true;
private float FreezeNonLoggedInMessageTimer = 7f;
public override void SetControls()
{
if (FlyCam.Enabled && !FlyCam.LockCamera)
{
Player.controlDown = false;
Player.controlUp = false;
Player.controlLeft = false;
Player.controlRight = false;
Player.controlMount = false;
Player.controlHook = false;
Player.controlThrow = false;
// player.controlJump = false;
Player.controlSmart = false;
Player.controlTorch = false;
}
if(Main.netMode == NetmodeID.MultiplayerClient && !HEROsModServices.Login.LoggedIn && ModContent.GetInstance<HEROsModServerConfig>().FreezeNonLoggedIn)
{
Player.frozen = true;
FreezeNonLoggedInMessageTimer -= ModUtils.DeltaTime;
if (FreezeNonLoggedInMessageTimer <= 0)
{
FreezeNonLoggedInMessageTimer = 7f;
Main.NewText(HEROsMod.HeroText("LoginInstructions"), Color.Red);
}
}
}
public override bool ImmuneTo(PlayerDeathReason damageSource, int cooldownCounter, bool dodgeable)
{
if (GodModeService.Enabled && !GodModeService.BuddhaMode)
return true;
return base.ImmuneTo(damageSource, cooldownCounter, dodgeable);
}
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
{
if (GodModeService.Enabled && GodModeService.BuddhaMode)
{
Player.statLife = Player.statLifeMax2;
Player.lifeRegen = 999;
return false;
}
return true;
}
public override void PreUpdate()
{
if (GodModeService.Enabled)
{
if (!GodModeService.BuddhaMode)
Player.statLife = Player.statLifeMax2;
Player.statMana = Player.statManaMax2;
Player.wingTime = Player.wingTimeMax;
}
}
// TODO - make tmodloader hook, this only gets called while there are players in the world.
private double time;
public override void PostUpdate()
{
if (Main.dedServ)
{
if (time != Main.time)
{
time = Main.time;
HEROsModNetwork.Network.Update();
}
}
if (Main.myPlayer == Player.whoAmI && Main.netMode == NetmodeID.MultiplayerClient && !HEROsModServices.Login.LoggedIn && ModContent.GetInstance<HEROsModServerConfig>().FreezeNonLoggedIn)
{
// For visuals. Other players won't see this, but less error prone than Frozen debuff.
Player.frozen = true;
}
}
public override void ProcessTriggers(TriggersSet triggersSet)
{
}
}
}