本文整理汇总了C#中WorldServer.Network.WorldClass类的典型用法代码示例。如果您正苦于以下问题:C# WorldClass类的具体用法?C# WorldClass怎么用?C# WorldClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorldClass类属于WorldServer.Network命名空间,在下文中一共展示了WorldClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleLogoutComplete
public static void HandleLogoutComplete(ref PacketReader packet, ref WorldClass session)
{
WorldMgr.DeleteSession(session.Character.Guid);
PacketWriter logoutComplete = new PacketWriter(LegacyMessage.LogoutComplete);
session.Send(logoutComplete);
}
示例2: AddNpc
public static void AddNpc(string[] args, WorldClass session)
{
var level = CommandParser.Read<byte>(args, 1);
var chatMessage = new ChatMessageValues(0, "Please enter a level between 0 and 91.");
if (level > 90 || level < 1)
{
ChatHandler.SendMessage(ref session, chatMessage);
return;
}
var pChar = session.Character;
if (SmartGuid.GetGuidType(pChar.TargetGuid) == HighGuidType.Player)
{
if (DB.Characters.Execute("UPDATE Characters SET Level = ? WHERE Guid = ?", level, pChar.Guid))
{
pChar.SetUpdateField<uint>((int)UnitFields.Level, level);
ObjectHandler.HandleUpdateObjectValues(ref session);
}
}
else
{
chatMessage.Message = "Please select a player.";
ChatHandler.SendMessage(ref session, chatMessage);
}
}
示例3: FlightSpeed
public static void FlightSpeed(string[] args, WorldClass session)
{
ChatMessageValues chatMessage = new ChatMessageValues(0, "");
if (args.Length == 1)
MoveHandler.HandleMoveSetFlightSpeed(ref session);
else
{
var speed = CommandParser.Read<float>(args, 1);
if (speed <= 50 && speed > 0)
{
chatMessage.Message = "Flight speed set to " + speed + "!";
MoveHandler.HandleMoveSetFlightSpeed(ref session, speed);
ChatHandler.SendMessage(ref session, chatMessage);
}
else
{
chatMessage.Message = "Please enter a value between 0.0 and 50.0!";
ChatHandler.SendMessage(ref session, chatMessage);
}
return;
}
chatMessage.Message = "Flight speed set to default.";
ChatHandler.SendMessage(ref session, chatMessage);
}
示例4: HandleSendKnownSpells
public static void HandleSendKnownSpells(ref WorldClass session)
{
Character pChar = session.Character;
var specializationSpells = SpecializationMgr.GetSpecializationSpells(pChar);
var specializationSpellCount = ((specializationSpells != null) ? specializationSpells.Count : 0);
var talentSpells = SpecializationMgr.GetTalentSpells(pChar, pChar.ActiveSpecGroup);
var talentSpellCount = ((talentSpells != null) ? talentSpells.Count : 0);
int count = pChar.SpellList.Count + specializationSpellCount + talentSpellCount;
PacketWriter writer = new PacketWriter(ServerMessage.SendKnownSpells);
BitPack BitPack = new BitPack(writer);
BitPack.Write(1);
BitPack.Write(count, 22);
BitPack.Flush();
pChar.SpellList.ForEach(spell =>
writer.WriteUInt32(spell.SpellId));
if (specializationSpells != null)
specializationSpells.ForEach(spell => writer.WriteUInt32(spell.Spell));
if (talentSpells != null)
talentSpells.ForEach(spell => writer.WriteUInt32(spell));
session.Send(ref writer);
}
示例5: AddNpc
public static void AddNpc(string[] args, WorldClass session)
{
var pChar = session.Character;
int creatureId = CommandParser.Read<int>(args, 1);
Creature creature = DataMgr.FindCreature(creatureId);
if (creature != null)
{
ChatMessageValues chatMessage = new ChatMessageValues(0, "");
CreatureSpawn spawn = new CreatureSpawn()
{
Guid = CreatureSpawn.GetLastGuid() + 1,
Id = creatureId,
Creature = creature,
Position = pChar.Position,
Map = pChar.Map
};
if (spawn.AddToDB())
{
chatMessage.Message = "Spawn successfully added.";
spawn.AddToWorld();
ChatHandler.SendMessage(ref session, chatMessage);
}
else
{
chatMessage.Message = "Spawn can't be added.";
ChatHandler.SendMessage(ref session, chatMessage);
}
}
}
示例6: HandleLearnTalents
public static void HandleLearnTalents(ref PacketReader packet, ref WorldClass session)
{
var pChar = session.Character;
var talentSpells = new List<uint>();
BitUnpack BitUnpack = new BitUnpack(packet);
uint talentCount = BitUnpack.GetBits<uint>(23);
for (int i = 0; i < talentCount; i++)
{
var talentId = packet.Read<ushort>();
SpecializationMgr.AddTalent(pChar, pChar.ActiveSpecGroup, talentId, true);
talentSpells.Add(CliDB.Talent.Single(talent => talent.Id == talentId).SpellId);
}
HandleUpdateTalentData(ref session);
pChar.SetUpdateField<Int32>((int)PlayerFields.SpellCritPercentage + 0, SpecializationMgr.GetUnspentTalentRowCount(pChar), 0);
ObjectHandler.HandleUpdateObjectValues(ref session);
foreach (var talentSpell in talentSpells)
SpellHandler.HandleLearnedSpells(ref session, new List<uint>(1) { talentSpell });
Log.Message(LogType.Debug, "Character (Guid: {0}) learned {1} talents.", pChar.Guid, talentCount);
}
示例7: HandleLearnTalents
//[Opcode(ClientMessage.LearnTalents, "16357")]
public static void HandleLearnTalents(ref PacketReader packet, ref WorldClass session)
{
var pChar = session.Character;
var talentSpells = new List<uint>();
BitUnpack BitUnpack = new BitUnpack(packet);
uint talentCount = BitUnpack.GetBits<uint>(25);
for (int i = 0; i < talentCount; i++)
{
var talentId = packet.ReadUInt16();
SpecializationMgr.AddTalent(pChar, pChar.ActiveSpecGroup, talentId, true);
talentSpells.Add(DBCStorage.TalentStorage.LookupByKey(talentId).SpellId);
}
HandleTalentUpdate(ref session);
pChar.SetUpdateField<Int32>((int)PlayerFields.SpellCritPercentage + 0, SpecializationMgr.GetUnspentTalentRowCount(pChar), 0);
ObjectHandler.HandleUpdateObjectValues(ref session);
// we need to send a single packet for every talent spell - stupid blizz
foreach (var talentSpell in talentSpells)
SpellHandler.HandleLearnedSpells(ref session, new List<uint>(1) { talentSpell });
Log.Message(LogType.DEBUG, "Character (Guid: {0}) learned {1} talents.", pChar.Guid, talentCount);
}
示例8: HandleCliSetSpecialization
public static void HandleCliSetSpecialization(ref PacketReader packet, ref WorldClass session)
{
var pChar = session.Character;
uint specGroupId = packet.Read<uint>();
uint specId = SpecializationMgr.GetSpecIdByGroup(pChar, (byte)specGroupId);
// check if new spec is primary or secondary
if (pChar.SpecGroupCount == 1 && pChar.PrimarySpec == 0)
{
pChar.ActiveSpecGroup = 0;
pChar.PrimarySpec = (ushort)specId;
}
else
{
pChar.ActiveSpecGroup = 1;
pChar.SecondarySpec = (ushort)specId;
pChar.SpecGroupCount = (byte)(pChar.SpecGroupCount + 1);
}
SpecializationMgr.SaveSpecInfo(pChar);
SendSpecializationSpells(ref session);
HandleUpdateTalentData(ref session);
pChar.SetUpdateField<Int32>((int)PlayerFields.CurrentSpecID, (int)pChar.GetActiveSpecId());
ObjectHandler.HandleUpdateObjectValues(ref session);
Log.Message(LogType.Debug, "Character (Guid: {0}) choosed specialization {1} for spec group {2}.", pChar.Guid, pChar.GetActiveSpecId(), pChar.ActiveSpecGroup);
}
示例9: Character
public Character(UInt64 guid, ref WorldClass session)
: base((int)PlayerFields.End)
{
SQLResult result = DB.Characters.Select("SELECT * FROM characters WHERE guid = {0}", guid);
Guid = result.Read<UInt64>(0, "Guid");
AccountId = result.Read<UInt32>(0, "AccountId");
Name = result.Read<String>(0, "Name");
Race = result.Read<Byte>(0, "Race");
Class = result.Read<Byte>(0, "Class");
Gender = result.Read<Byte>(0, "Gender");
Skin = result.Read<Byte>(0, "Skin");
Face = result.Read<Byte>(0, "Face");
HairStyle = result.Read<Byte>(0, "HairStyle");
HairColor = result.Read<Byte>(0, "HairColor");
FacialHair = result.Read<Byte>(0, "FacialHair");
Level = result.Read<Byte>(0, "Level");
Zone = result.Read<UInt32>(0, "Zone");
Map = result.Read<UInt32>(0, "Map");
X = result.Read<Single>(0, "X");
Y = result.Read<Single>(0, "Y");
Z = result.Read<Single>(0, "Z");
O = result.Read<Single>(0, "O");
GuildGuid = result.Read<UInt64>(0, "GuildGuid");
PetDisplayInfo = result.Read<UInt32>(0, "PetDisplayId");
PetLevel = result.Read<UInt32>(0, "PetLevel");
PetFamily = result.Read<UInt32>(0, "PetFamily");
CharacterFlags = result.Read<UInt32>(0, "CharacterFlags");
CustomizeFlags = result.Read<UInt32>(0, "CustomizeFlags");
// Set current session of the character
Globals.SetSession(ref session);
SetCharacterFields();
}
示例10: DeleteNpc
public static void DeleteNpc(string[] args, WorldClass session)
{
ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageSystem, "");
var pChar = session.Character;
var spawn = SpawnMgr.FindSpawn(pChar.TargetGuid);
if (spawn != null)
{
SpawnMgr.RemoveSpawn(spawn);
var destroyObject = ObjectHandler.HandleDestroyObject(ref session, pChar.TargetGuid);
session.Send(ref destroyObject);
WorldMgr.SendToInRangeCharacter(pChar, destroyObject);
chatMessage.Message = "Selected Spawn successfully removed.";
ChatHandler.SendMessage(ref session, chatMessage);
}
else
{
chatMessage.Message = "Not a creature.";
ChatHandler.SendMessage(ref session, chatMessage);
}
}
示例11: AddTele
public static void AddTele(string[] args, WorldClass session)
{
var pChar = session.Character;
string location = CommandParser.Read<string>(args, 1);
SQLResult result = DB.World.Select("SELECT * FROM teleport_locations WHERE location = ?", location);
ChatMessageValues chatMessage = new ChatMessageValues(0, "");
if (result.Count == 0)
{
if (DB.World.Execute("INSERT INTO teleport_locations (location, x, y, z, o, map) " +
"VALUES (?, ?, ?, ?, ?, ?)", location, pChar.Position.X, pChar.Position.Y, pChar.Position.Z, pChar.Position.O, pChar.Map))
{
chatMessage.Message = string.Format("Teleport location '{0}' successfully added.", location);
ChatHandler.SendMessage(ref session, chatMessage);
}
}
else
{
chatMessage.Message = string.Format("Teleport location '{0}' already exist.", location);
ChatHandler.SendMessage(ref session, chatMessage);
}
}
示例12: AddObject
public static void AddObject(string[] args, WorldClass session)
{
var pChar = session.Character;
int objectId = CommandParser.Read<int>(args, 1);
GameObject gObject = DataMgr.FindGameObject(objectId);
if (gObject != null)
{
ChatMessageValues chatMessage = new ChatMessageValues(0, "");
GameObjectSpawn spawn = new GameObjectSpawn()
{
Guid = GameObjectSpawn.GetLastGuid() + 1,
Id = objectId,
GameObject = gObject,
Position = pChar.Position,
Map = pChar.Map
};
if (spawn.AddToDB())
{
chatMessage.Message = "Spawn successfully added.";
spawn.AddToWorld();
ChatHandler.SendMessage(ref session, chatMessage);
}
else
{
chatMessage.Message = "Spawn can't be added.";
ChatHandler.SendMessage(ref session, chatMessage);
}
}
}
示例13: HandleRequestUITime
public static void HandleRequestUITime(ref PacketReader packet, ref WorldClass session)
{
PacketWriter uiTime = new PacketWriter(LegacyMessage.UITime);
uiTime.WriteUnixTime();
session.Send(uiTime);
}
示例14: HandleCreateCharacter
public static void HandleCreateCharacter(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
packet.Skip(1);
var facialHair = packet.ReadByte();
var skin = packet.ReadByte();
var race = packet.ReadByte();
var hairStyle = packet.ReadByte();
var pClass = packet.ReadByte();
var face = packet.ReadByte();
var gender = packet.ReadByte();
var hairColor = packet.ReadByte();
var nameLength = BitUnpack.GetBits<uint>(6);
var hasUnknown = BitUnpack.GetBit();
var name = Character.NormalizeName(packet.ReadString(nameLength));
if (hasUnknown)
packet.ReadUInt32();
var result = DB.Characters.Select("SELECT * from characters WHERE name = ?", name);
var createChar = new PacketWriter(ServerMessage.CreateChar);
if (result.Count != 0)
{
// Name already in use
createChar.WriteUInt8(0x32);
session.Send(ref createChar);
return;
}
result = DB.Characters.Select("SELECT map, zone, posX, posY, posZ, posO FROM character_creation_data WHERE race = ? AND class = ?", race, pClass);
if (result.Count == 0)
{
createChar.WriteUInt8(0x31);
session.Send(ref createChar);
return;
}
var map = result.Read<uint>(0, "map");
var zone = result.Read<uint>(0, "zone");
var posX = result.Read<float>(0, "posX");
var posY = result.Read<float>(0, "posY");
var posZ = result.Read<float>(0, "posZ");
var posO = result.Read<float>(0, "posO");
// Allow declined names for now
var characterFlags = CharacterFlag.Decline;
DB.Characters.Execute("INSERT INTO characters (name, accountid, realmId, race, class, gender, skin, zone, map, x, y, z, o, face, hairstyle, haircolor, facialhair, characterFlags) VALUES (" +
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
name, session.Account.Id, WorldConfig.RealmId, race, pClass, gender, skin, zone, map, posX, posY, posZ, posO, face, hairStyle, hairColor, facialHair, characterFlags);
// Success
createChar.WriteUInt8(0x2F);
session.Send(ref createChar);
}
示例15: HandleUITimeRequest
public static void HandleUITimeRequest(ref PacketReader packet, WorldClass session)
{
PacketWriter uiTime = new PacketWriter(ServerMessage.UITime);
uiTime.WriteUnixTime();
session.Send(ref uiTime);
}