183 lines
5.1 KiB
C#
183 lines
5.1 KiB
C#
using PSO2SERVER.Database;
|
||
using PSO2SERVER.Models;
|
||
using PSO2SERVER.Protocol.Packets;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
|
||
namespace PSO2SERVER.Party
|
||
{
|
||
public class Party
|
||
{
|
||
public string name;
|
||
private List<Client> members;
|
||
private Client host;
|
||
public PartyQuest currentQuest;
|
||
public PartySettingsPacket partySetting;
|
||
public string questname;
|
||
|
||
public Party(string name, Client Leader)
|
||
{
|
||
this.name = name;
|
||
this.host = Leader;
|
||
members = new List<Client>();
|
||
currentQuest = new PartyQuest();
|
||
partySetting = new PartySettingsPacket();
|
||
questname = string.Empty;
|
||
addClientToParty(Leader);
|
||
}
|
||
|
||
public void addClientToParty(Client c)
|
||
{
|
||
members.Add(c);
|
||
if (members.Count < 1)
|
||
{
|
||
c.SendPacket(new PartyInitPacket(members));
|
||
}
|
||
else
|
||
{
|
||
// ???
|
||
}
|
||
c.currentParty = this;
|
||
}
|
||
|
||
public void removeClientFromParty(Client c)
|
||
{
|
||
if (!members.Contains(c))
|
||
{
|
||
Logger.WriteWarning("[PTY] Client {0} was trying to be removed from {1}, but he was never in {1}!", c._account.Username, name);
|
||
return;
|
||
}
|
||
|
||
members.Remove(c);
|
||
//TODO do stuff like send the "remove from party" packet.
|
||
}
|
||
|
||
public bool hasClientInParty(Client c)
|
||
{
|
||
return members.Contains(c);
|
||
}
|
||
|
||
public Client getPartyHost()
|
||
{
|
||
return host;
|
||
}
|
||
|
||
public int getSize()
|
||
{
|
||
return members.Count;
|
||
}
|
||
|
||
public List<Client> getMembers()
|
||
{
|
||
return members;
|
||
}
|
||
}
|
||
|
||
public enum PartyColor : byte
|
||
{
|
||
Red,
|
||
Green,
|
||
Yellow,
|
||
Blue,
|
||
}
|
||
|
||
[Serializable]
|
||
public unsafe struct PartyEntry
|
||
{
|
||
/// 玩家对象的头部信息(包含ID、类型、区域ID等)。
|
||
public ObjectHeader id;
|
||
|
||
/// 玩家昵称。
|
||
public string nickname;
|
||
|
||
/// 玩家角色名称。
|
||
public string char_name;
|
||
|
||
/// 主职业的等级。
|
||
public byte level;
|
||
|
||
/// 副职业的等级。
|
||
public byte sublevel;
|
||
|
||
/// 玩家主职业类型(`ClassType` 枚举类型)。
|
||
public ClassType mainClass;
|
||
|
||
/// 玩家副职业类型(`ClassType` 枚举类型)。
|
||
public ClassType subClass;
|
||
|
||
/// 玩家在队伍中的颜色标识。
|
||
public PartyColor color;
|
||
|
||
/// 7字节的未知数据(通常是填充或者未定义用途)。
|
||
public fixed byte unk1[7];
|
||
|
||
/// 一个未知的 uint 类型数据,具体用途不明。
|
||
public uint unk2;
|
||
|
||
/// 玩家HP(体力)的三个数值。具体原因为什么有三个值目前不明。
|
||
public fixed uint hp[3];
|
||
|
||
/// 玩家所在的地图ID。
|
||
public ushort mapid;
|
||
|
||
/// 另一个未知的 ushort 类型数据。
|
||
public ushort unk3;
|
||
|
||
/// 12字节的未知数据。
|
||
public fixed byte unk4[0x0C];
|
||
|
||
/// 3个未知的 uint 数组数据。
|
||
public fixed uint unk5[0x03];
|
||
|
||
/// 未知的字符串,可能是其他信息(如玩家状态或其他描述信息)。
|
||
public string unk6;
|
||
|
||
// PSO VITA(PlayStation Vita)相关字段,已注释掉,可能与Vita版本相关。
|
||
public string unk10;
|
||
|
||
// 玩家角色的 ASCII 字符串相关数据,已注释掉。
|
||
public string unk7; // ASCII 字符串
|
||
|
||
// 玩家语言设置(`ShortLanguage` 枚举类型),已注释掉。
|
||
public ShortLanguage lang;
|
||
|
||
// 3字节的未知数据,已注释掉。
|
||
public fixed byte unk9[3];
|
||
}
|
||
|
||
[Serializable]
|
||
public unsafe struct PartyInfo
|
||
{
|
||
public fixed byte unk1[0x0C];
|
||
public ObjectHeader party_object; // Assuming ObjectHeader is another class
|
||
public string name; // Name of the party 0xE7E8, 0xFF
|
||
public fixed byte unk2[0x09];
|
||
public fixed byte unk3[0x03];
|
||
public uint unk4; // 32-bit unsigned integer
|
||
public uint invite_time; // Time when the player was invited
|
||
public uint unk6; // 32-bit unsigned integer
|
||
}
|
||
|
||
[Flags]
|
||
public enum PartyFlags : byte
|
||
{
|
||
/// Is the party only for friends.
|
||
FRIENDS_ONLY = 1 << 0, // 1
|
||
/// Is the party only for alliance members.
|
||
ALLIANCE_ONLY = 1 << 1, // 2
|
||
/// Limit multiplayer requests from other parties.
|
||
LIMIT_OTHERS = 1 << 2, // 4
|
||
/// Is the party only for a single run.
|
||
SINGLE_RUN = 1 << 3, // 8
|
||
/// Is the party actively looking for members.
|
||
OPEN = 1 << 4, // 16
|
||
/// Is the party voice chat focused.
|
||
VC_FOCUS = 1 << 6, // 64
|
||
|
||
// This flag would represent an invalid state (all bits set).
|
||
_ = byte.MaxValue, // 255 (all flags set)
|
||
}
|
||
}
|