Пример #1
0
        public MyFaction(MyObjectBuilder_Faction obj)
        {
            FactionId   = obj.FactionId;
            Tag         = obj.Tag;
            Name        = obj.Name;
            Description = obj.Description;
            PrivateInfo = obj.PrivateInfo;

            AutoAcceptMember = obj.AutoAcceptMember;
            AutoAcceptPeace  = obj.AutoAcceptPeace;
            EnableFriendlyFire = obj.EnableFriendlyFire;

            m_members = new Dictionary<long, MyFactionMember>(obj.Members.Count);

            foreach (var member in obj.Members)
            {
                m_members.Add(member.PlayerId, member);
                if (member.IsFounder)
                    FounderId = member.PlayerId;
            }

            if (obj.JoinRequests != null)
            {
                m_joinRequests = new Dictionary<long, MyFactionMember>(obj.JoinRequests.Count);

                foreach (var request in obj.JoinRequests)
                    m_joinRequests.Add(request.PlayerId, request);
            }
            else
            {
                m_joinRequests = new Dictionary<long, MyFactionMember>();
            }
        }
        public Faction( MyObjectBuilder_Faction faction )
        {
            m_faction = faction;

            m_members = new Dictionary<long, FactionMember>( );
            foreach ( MyObjectBuilder_FactionMember member in m_faction.Members )
            {
                m_members.Add( member.PlayerId, new FactionMember( this, member ) );
            }

            m_joinRequests = new Dictionary<long, FactionMember>( );
            foreach ( MyObjectBuilder_FactionMember member in m_faction.JoinRequests )
            {
                m_joinRequests.Add( member.PlayerId, new FactionMember( this, member ) );
            }
        }
Пример #3
0
        public MyObjectBuilder_Faction GetObjectBuilder()
        {
            var builder = new MyObjectBuilder_Faction();

            builder.FactionId   = FactionId;
            builder.Tag         = Tag;
            builder.Name        = Name;
            builder.Description = Description;
            builder.PrivateInfo = PrivateInfo;

            builder.AutoAcceptMember = AutoAcceptMember;
            builder.AutoAcceptPeace  = AutoAcceptPeace;
            builder.EnableFriendlyFire = EnableFriendlyFire;

            builder.Members = new List<MyObjectBuilder_FactionMember>(Members.Count());
            foreach (var member in Members)
                builder.Members.Add(member.Value);

            builder.JoinRequests = new List<MyObjectBuilder_FactionMember>(JoinRequests.Count());
            foreach (var request in JoinRequests)
                builder.JoinRequests.Add(request.Value);

            return builder;
        }
Пример #4
0
 public static long GetFactionAstoids(MyObjectBuilder_Faction faction)
 {
     long NumCapturedAstoids = 0;
     List<MyObjectBuilder_FactionMember> currentfacitonmembers = faction.Members;
     foreach (MyObjectBuilder_FactionMember currentmember in currentfacitonmembers)
     {
         var leaders = GMConquest.Instance.Leaderboard.GroupBy(x => x.Value).Select(group => new { group.Key, Total = group.Count() }).OrderByDescending(x => x.Total);
         foreach (var p in leaders)
         {
             if (p.Key == currentmember.PlayerId)
             {
                 NumCapturedAstoids += p.Total;
             }
         }
     }
     return NumCapturedAstoids;
 }