-
Notifications
You must be signed in to change notification settings - Fork 0
/
XRaces.cs
121 lines (109 loc) · 4.89 KB
/
XRaces.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
109
110
111
112
113
114
115
116
117
118
119
120
121
using System;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace XRaces {
class XRaces : Mod {
public static Texture2D head, eyeWhites, eyes;
public static Texture2D[, ] RaceTextures = new Texture2D[Enum.GetNames(typeof (Race)).Length, 3];
public XRaces() {
Properties = new ModProperties() {
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}
public override void Load() {
head = TextureManager.Load("Images/Player_0_0");
eyeWhites = TextureManager.Load("Images/Player_0_1");
eyes = TextureManager.Load("Images/Player_0_2");
for (int i = 0; i < RaceTextures.Length / 3; i++) {
String name = "Race/" + ((Race) i).ToString();
if (TextureExists(name + "Head")) RaceTextures[i, 0] = (GetTexture(name + "Head"));
else RaceTextures[i, 0] = head;
if (TextureExists(name + "EyeWhites")) RaceTextures[i, 1] = (GetTexture(name + "EyeWhites"));
else RaceTextures[i, 1] = eyeWhites;
if (TextureExists(name + "Eyes")) RaceTextures[i, 2] = (GetTexture(name + "Eyes"));
else RaceTextures[i, 2] = eyes;
}
}
public override void Unload() {
Main.playerTextures[0, 0] = head;
Main.playerTextures[0, 1] = eyeWhites;
Main.playerTextures[0, 2] = eyes;
}
public override void AddRecipeGroups() {
RecipeGroup group = new RecipeGroup(() => Language.GetText("any") + " Soul", new int[] {
this.ItemType<Items.Misc.AntSoul>(),
this.ItemType<Items.Misc.DemonSoul>(),
this.ItemType<Items.Misc.GoblinSoul>(),
this.ItemType<Items.Misc.LizardmanSoul>(),
this.ItemType<Items.Misc.RobotSoul>(),
this.ItemType<Items.Misc.ShadeSoul>(),
this.ItemType<Items.Misc.SkeletonSoul>(),
this.ItemType<Items.Misc.SlimeSoul>(),
this.ItemType<Items.Misc.ZombieSoul>()
});
RecipeGroup.RegisterGroup("XRSouls", group);
}
public override void HandlePacket(System.IO.BinaryReader reader, int whoAmI) {
XRModMessageType msgType = (XRModMessageType) reader.ReadByte();
Player player = Main.player[reader.ReadInt32()];
XRPlayer modPlayer = player.GetModPlayer<XRPlayer>();
switch (msgType) {
case XRModMessageType.FromClient:
if (Main.netMode == NetmodeID.Server) {
Race race = (Race) reader.ReadByte();
modPlayer.race = race;
modPlayer.player.hair = reader.ReadInt32();
modPlayer.player.hairColor = reader.ReadRGB();
modPlayer.player.eyeColor = reader.ReadRGB();
modPlayer.player.skinColor = reader.ReadRGB();
modPlayer.wet = reader.ReadBoolean();
modPlayer.falling = reader.ReadBoolean();
modPlayer.idle = reader.ReadInt32();
modPlayer.manaMaxMul = reader.ReadSingle();
modPlayer.GetPacket((byte) XRModMessageType.FromServer).Send();
//NetMessage.BroadcastChatMessage(Terraria.Localization.NetworkText.FromLiteral(player.name + " " + race.ToString()), Microsoft.Xna.Framework.Color.White);
}
break;
case XRModMessageType.FromServer:
if (!player.Equals(Main.LocalPlayer)) {
Race race = (Race) reader.ReadByte();
modPlayer.race = race;
modPlayer.player.hair = reader.ReadInt32();
modPlayer.player.hairColor = reader.ReadRGB();
modPlayer.player.eyeColor = reader.ReadRGB();
modPlayer.player.skinColor = reader.ReadRGB();
modPlayer.wet = reader.ReadBoolean();
modPlayer.falling = reader.ReadBoolean();
modPlayer.idle = reader.ReadInt32();
modPlayer.manaMaxMul = reader.ReadSingle();
}
break;
default:
ErrorLogger.Log("XRaces: Unknown Message type: " + msgType);
break;
}
}
}
enum XRModMessageType : byte {
FromServer,
FromClient
}
public enum Race : byte {
Human,
Demon,
Ant,
Slime,
Zombie,
Goblin,
Skeleton,
Lizardman,
Shade,
Robot
}
}