public static Character AddCharacter(this TContext ctx, int userId, Terraria.Player player) { Character chr = new Character() { UserId = userId, UUID = player.ClientUUId, Health = player.statLife, MaxHealth = player.statLifeMax, Mana = player.statMana, MaxMana = player.statManaMax, SpawnX = player.SpawnX, SpawnY = player.SpawnY, Hair = player.hair, HairDye = player.hairDye, HideVisual = DataEncoding.EncodeInteger(player.hideVisual), Difficulty = player.difficulty, HairColor = DataEncoding.EncodeColor(player.hairColor), SkinColor = DataEncoding.EncodeColor(player.skinColor), EyeColor = DataEncoding.EncodeColor(player.eyeColor), ShirtColor = DataEncoding.EncodeColor(player.shirtColor), UnderShirtColor = DataEncoding.EncodeColor(player.underShirtColor), PantsColor = DataEncoding.EncodeColor(player.pantsColor), ShoeColor = DataEncoding.EncodeColor(player.shoeColor), AnglerQuests = player.anglerQuestsFinished }; ctx.Characters.Add(chr); ctx.SaveChanges(); return chr; }
public static Character NewCharacter( TContext ctx, CharacterMode mode, string auth, string clientUUID, int health, int maxHealth, int mana, int maxMana, int spawnX, int spawnY, int hair, byte hairDye, int hideVisual, byte difficulty, uint hairColor, uint skinColor, uint eyeColor, uint shirtColor, uint underShirtColor, uint pantsColor, uint shoeColor, int anglerQuests ) { int? userId = null; if (mode == CharacterMode.AUTH) { var user = AuthenticatedUsers.GetUser(auth); userId = user.Id; } else if (mode != CharacterMode.UUID) return null; Character chr = new Character() { UserId = userId, UUID = clientUUID, Health = health, MaxHealth = maxHealth, Mana = mana, MaxMana = maxMana, SpawnX = spawnX, SpawnY = spawnY, Hair = hair, HairDye = hairDye, HideVisual = hideVisual, Difficulty = difficulty, HairColor = hairColor, SkinColor = skinColor, EyeColor = eyeColor, ShirtColor = shirtColor, UnderShirtColor = underShirtColor, PantsColor = pantsColor, ShoeColor = shoeColor, AnglerQuests = anglerQuests }; ctx.Characters.Add(chr); ctx.SaveChanges(); return chr; }