Пример #1
0
        internal PlayerStatus(EliteDangerousAPI api)
        {
            api.GameEvents.Status += (s, e) =>
            {
                lock (_lock)
                {
                    if (LegalState != e.LegalState)
                    {
                        LegalState = e.LegalState;
                        api.InvokePlayerStatusChanged(this);
                    }
                }
            };

            api.GameEvents.LoadGame += (s, e) =>
            {
                lock (_lock)
                {
                    FrontierId = e.FrontierId;
                    Commander  = e.Commander;
                    api.InvokePlayerStatusChanged(this);
                }
            };

            api.GameEvents.ClearSavedGame += (s, e) =>
            {
                lock (_lock)
                {
                    FrontierId = e.FrontierId;
                    Commander  = e.Name;
                    api.InvokePlayerStatusChanged(this);
                }
            };

            api.PlayerEvents.NewCommander += (s, e) =>
            {
                lock (_lock)
                {
                    FrontierId = e.FrontierId;
                    Commander  = e.Name;
                    api.InvokePlayerStatusChanged(this);
                }
            };

            api.PlayerEvents.Commander += (s, e) =>
            {
                lock (_lock)
                {
                    FrontierId = e.FrontierId;
                    Commander  = e.Name;
                    api.InvokePlayerStatusChanged(this);
                }
            };

            api.PlayerEvents.Progress += (s, e) =>
            {
                lock (_lock)
                {
                    CombatRank.Progress      = e.Combat;
                    TradeRank.Progress       = e.Trade;
                    ExplorationRank.Progress = e.Explore;
                    FederationRank.Progress  = e.Federation;
                    EmpireRank.Progress      = e.Empire;
                    CqcRank.Progress         = e.Cqc;

                    api.InvokePlayerStatusChanged(this);
                }
            };

            api.PlayerEvents.Promotion += (s, e) =>
            {
                lock (_lock)
                {
                    CombatRank.UpdateRank(e.Combat);
                    TradeRank.UpdateRank(e.Trade);
                    ExplorationRank.UpdateRank(e.Explore);
                    EmpireRank.UpdateRank(e.Empire);
                    FederationRank.UpdateRank(e.Federation);
                    CqcRank.UpdateRank(e.Cqc);

                    api.InvokePlayerStatusChanged(this);
                }
            };

            api.PlayerEvents.Rank += (s, e) =>
            {
                lock (_lock)
                {
                    CombatRank.UpdateRank(e.Combat);
                    TradeRank.UpdateRank(e.Trade);
                    ExplorationRank.UpdateRank(e.Explore);
                    EmpireRank.UpdateRank(e.Empire);
                    FederationRank.UpdateRank(e.Federation);
                    CqcRank.UpdateRank(e.Cqc);

                    api.InvokePlayerStatusChanged(this);
                }
            };

            api.PlayerEvents.Reputation += (s, e) =>
            {
                lock (_lock)
                {
                    EmpireReputation      = new MajorReputation(e.Empire);
                    FederationReputation  = new MajorReputation(e.Federation);
                    IndependentReputation = new MajorReputation(e.Independent);
                    AllianceReputation    = new MajorReputation(e.Alliance);

                    api.InvokePlayerStatusChanged(this);
                }
            };
        }
Пример #2
0
 public static string GetText(FederationRank federationRank) => App.GetResource <string>($"Faction.Federation.{(int)federationRank}.Text");