-
Notifications
You must be signed in to change notification settings - Fork 3
/
PokePlayer.cs
161 lines (140 loc) · 6.44 KB
/
PokePlayer.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using Microsoft.Xna.Framework;
using PokeModBlue.Items.Weapons;
using System;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace PokeModBlue {
public class PokePlayer : ModPlayer {
public bool loaded = false;
public Boolean trainerCard = false;
private Color black = Microsoft.Xna.Framework.Color.Black;
/*
public override void PostUpdate() {
if (trainerCard) {
Vector2 position = Main.fontMouseText.MeasureString("This Text");
float num83 = 0f;
if (Main.player[player.whoAmI].chatOverhead.timeLeft > 0) {
num83 = -position.Y;
}
Vector2 vector4 = new Vector2((float)(Main.screenWidth / 2) + Main.screenPosition.X, (float)(Main.screenHeight / 2) + Main.screenPosition.Y);
float num86 = Main.player[player.whoAmI].position.X + (float)(Main.player[player.whoAmI].width / 2) - vector4.X;
float num87 = Main.player[player.whoAmI].position.Y - position.Y - 2f + num83 - vector4.Y;
Main.spriteBatch.DrawString(Main.fontMouseText, "This Text", vector4, black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
base.PostUpdateEquips();
}
*/
public override void PreUpdate() {
if (!loaded) {
Main.NewText("PokeModBlue loaded. Thanks for playing, let me know of any suggestions or issues on the forums :)");
Main.NewText("-UnownDeveloper");
loaded = true;
}
// closes the conversation window if trying to select a pokemon and talking to the goblin to prevent reforging pokemon
if (player.talkNPC > -1) {
if (Main.npc[player.talkNPC].type == 107 && player.selectedItem == 58 && player.inventory[player.selectedItem].modItem != null) {
PokemonWeapon pokeWeapon;
pokeWeapon = player.inventory[player.selectedItem].modItem as PokemonWeapon;
if (pokeWeapon != null) {
player.talkNPC = -1;
}
}
}
}
public override void SetupStartInventory(IList<Item> items) {
Item item = new Item();
item.SetDefaults(mod.ItemType("Pokecase"));
item.stack = 1;
items.Add(item);
item = new Item();
item.SetDefaults(mod.ItemType("PokeBall"));
item.stack = 5;
items.Add(item);
}
// 0: v0.2 -- v, numExtra, readInventory
public static int SaveVersion = 0;
public static int MaxExtraAccessories = 6;
public Item[] ExtraAccessories = new Item[MaxExtraAccessories];
public int numberExtraAccessoriesEnabled = 0;
public override void UpdateEquips(ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff) {
for (int i = 0; i < numberExtraAccessoriesEnabled; i++) {
player.VanillaUpdateEquip(ExtraAccessories[i]);
}
for (int i = 0; i < numberExtraAccessoriesEnabled; i++) {
player.VanillaUpdateAccessory(ExtraAccessories[i], false, ref wallSpeedBuff, ref tileSpeedBuff, ref tileRangeBuff);
}
}
public override void Initialize() {
ExtraAccessories = new Item[MaxExtraAccessories];
for (int i = 0; i < MaxExtraAccessories; i++) {
ExtraAccessories[i] = new Item();
ExtraAccessories[i].SetDefaults();
}
}
public override void LoadCustomData(BinaryReader reader) {
for (int i = 0; i < MaxExtraAccessories; i++) {
ExtraAccessories[i] = new Item();
ExtraAccessories[i].SetDefaults();
}
int loadVersion = reader.ReadInt32();
if (loadVersion == 0) {
numberExtraAccessoriesEnabled = reader.ReadInt32();
ReadInventory(ExtraAccessories, reader, false, false);
}
}
public override void SaveCustomData(BinaryWriter writer) {
writer.Write(SaveVersion);
writer.Write(numberExtraAccessoriesEnabled);
WriteInventory(ExtraAccessories, writer, false, false);
}
internal static bool WriteInventory(Item[] inv, BinaryWriter writer, bool writeStack = false, bool writeFavorite = false) {
ushort count = 0;
byte[] data;
using (MemoryStream stream = new MemoryStream()) {
using (BinaryWriter invWriter = new BinaryWriter(stream)) {
for (int k = 0; k < inv.Length; k++) {
// if (IsModItem(inv[k]))
{
invWriter.Write((ushort)k);
Terraria.ModLoader.IO.ItemIO.WriteItem(inv[k], invWriter, writeStack, writeFavorite);
count++;
}
}
}
data = stream.ToArray();
}
if (count > 0) {
writer.Write(count);
writer.Write(data);
return true;
}
return false;
}
internal static void ReadInventory(Item[] inv, BinaryReader reader, bool readStack = false, bool readFavorite = false) {
int count = reader.ReadUInt16();
for (int k = 0; k < count; k++) {
ushort index = reader.ReadUInt16();
Terraria.ModLoader.IO.ItemIO.ReadItem(inv[index], reader, readStack, readFavorite);
}
}
internal static bool IsModItem(Item item) {
return item.type >= ItemID.Count;
}
public override void Kill(double damage, int hitDirection, bool pvp, string deathText) {
for (int i = 0; i < player.inventory.Length; i++) {
PokemonWeapon pokemonWeapon = player.inventory[i].modItem as PokemonWeapon;
if (pokemonWeapon != null) {
pokemonWeapon.currentHP = pokemonWeapon.maxHP;
pokemonWeapon.SetToolTip();
if (pokemonWeapon.npc != null) {
pokemonWeapon.npc.life = pokemonWeapon.maxHP;
pokemonWeapon.npc.HealEffect(pokemonWeapon.maxHP);
}
}
}
}
}
}