Пример #1
0
        private static void Invite(YiObj player, ref MsgTeam packet)
        {
            if (!TeamSystem.Teams.ContainsKey(player.UniqueId))
            {
                return;
            }
            if (TeamSystem.Teams[player.UniqueId].Members.ContainsKey(packet.TargetUniqueId))
            {
                return;
            }
            if (TeamSystem.Teams[player.UniqueId].Members.Count > 4)
            {
                return;
            }

            if (!GameWorld.Maps[player.MapId].Entities.TryGetValue(packet.TargetUniqueId, out var found))
            {
                return;
            }
            if (found == null)
            {
                return;
            }
            var target = found;

            (target as Player)?.Send(Invite(player));
            if (target is Bot)
            {
                TeamSystem.Join(player, target);
            }
        }
Пример #2
0
 private static void AcceptInvite(YiObj player, ref MsgTeam packet)
 {
     if (GameWorld.Maps[player.MapId].Entities.TryGetValue(packet.TargetUniqueId, out var found))
     {
         var leader = found;
         TeamSystem.Join(leader, player);
     }
 }
Пример #3
0
        public static byte[] Create(YiObj human, MsgTeamAction action)
        {
            var msg = new MsgTeam
            {
                Size = (ushort)sizeof(MsgTeam),
                Id   = 1023, Mode = action, TargetUniqueId = human.UniqueId
            };

            return(msg);
        }
Пример #4
0
        private static void CreateTeam(Player player, ref MsgTeam packet)
        {
            if (GameWorld.Maps.TryGetValue(player.MapId, out var map))
            {
                if (map.Flags.HasFlag(MapFlags.DisableTeams))
                {
                    player.GetMessage("SYSTEM", player.Name, "Team's are not allowed on this map.", MsgTextType.Action);
                    return;
                }
            }

            TeamSystem.Teams.AddOrUpdate(player.UniqueId, new TeamSystem.TeamData(player));
            player.Send(packet);
        }
Пример #5
0
 private static void DismissTeam(YiObj leader, ref MsgTeam packet)
 {
     if (packet.TargetUniqueId != leader.UniqueId)
     {
         return;
     }
     if (!TeamSystem.Teams.ContainsKey(leader.UniqueId))
     {
         return;
     }
     if (leader.UniqueId != TeamSystem.Teams[leader.UniqueId].Leader.UniqueId)
     {
         return;
     }
     TeamSystem.Disband(leader);
 }
Пример #6
0
 private static void Kick(YiObj player, ref MsgTeam packet)
 {
     if (!TeamSystem.Teams.ContainsKey(player.UniqueId))
     {
         return;
     }
     if (!TeamSystem.Teams[player.UniqueId].Members.ContainsKey(packet.TargetUniqueId))
     {
         return;
     }
     if (!TeamSystem.Teams[player.UniqueId].Members.TryGetValue(packet.TargetUniqueId, out var kick))
     {
         return;
     }
     TeamSystem.Leave(player, kick);
 }
Пример #7
0
 private static void AcceptJoin(YiObj player, ref MsgTeam packet)
 {
     if (!TeamSystem.Teams.ContainsKey(player.UniqueId))
     {
         return;
     }
     if (TeamSystem.Teams[player.UniqueId].Members.Count > 4)
     {
         return;
     }
     if (!GameWorld.Maps[player.MapId].Entities.TryGetValue(packet.TargetUniqueId, out var found))
     {
         return;
     }
     if (found == null)
     {
         return;
     }
     TeamSystem.Join(player, found);
 }
Пример #8
0
        private static void RequestJoin(YiObj player, ref MsgTeam packet)
        {
            if (GameWorld.Maps[player.MapId].Entities.TryGetValue(packet.TargetUniqueId, out var obj))
            {
                if (obj == null)
                {
                    return;
                }

                var leader = obj;
                if (!TeamSystem.Teams.ContainsKey(leader.UniqueId))
                {
                    return;
                }
                if (TeamSystem.Teams[leader.UniqueId].Members.Count > 4)
                {
                    return;
                }
                if (TeamSystem.Teams[leader.UniqueId].Locked)
                {
                    Message.SendTo(player, "TeamData currently not accepting new members.", MsgTextType.Top);
                    return;
                }
                if (leader is Bot)
                {
                    //leader.TeamData.Join(player);
                    return;
                }
                var playerLeader = leader as Player;
                if (playerLeader != null)
                {
                    packet.TargetUniqueId = player.UniqueId;
                    playerLeader.Send(packet);
                }
            }
        }