示例#1
0
        private static TValue InternalGetValueSlow(bool logErrorIfClientHasNoValue)
        {
            if (Api.IsClient)
            {
                var fallbackValue = RatesManager.GetInstance <TServerRate>()
                                    .ValueDefault;
                if (!logErrorIfClientHasNoValue)
                {
                    return(fallbackValue);
                }

                Api.Logger.Error("The server rate value is not yet received from the server: "
                                 + typeof(TServerRate)
                                 + " - will provide the fallback value: "
                                 + fallbackValue);
                return(fallbackValue);
            }

            // Invoking this static method will ensure that all the static constructors are invoked
            // that will in turn initialize all the server rates (including the current one).
            RatesManager.SharedEnsureInitialized();

            if (!sharedIsReady)
            {
                // apparently due to recursion the rate was not initialized - initialize it now
                RatesManager.GetInstance <TServerRate>()
                .ServerInit();
            }

            return(sharedValue);
        }
示例#2
0
        private void ClientRemote_ServerRates(RateEntry[] serverRates)
        {
            /*Logger.Dev("Received server rates:"
             + Environment.NewLine
             + serverRates.Select(e => e.Id + "=" + e.AbstractValue)
             +                      .GetJoinedString(Environment.NewLine));*/

            RatesManager.ClientSetValuesFromServer(serverRates);
        }
示例#3
0
        protected override double ServerReadValueWithRange()
        {
            var result = base.ServerReadValueWithRange();

            if (result
                > RateStructuresLandClaimDecayDelayDurationMultiplier.SharedValue)
            {
                result = RateStructuresLandClaimDecayDelayDurationMultiplier.SharedValue;
                Api.Logger.Error(
                    string.Format(
                        "Please note: {0} server rate value is higher than {1} which is not correct (it must be lower or equal).",
                        this.Id,
                        RatesManager
                        .GetInstance <RateStructuresLandClaimDecayDelayDurationMultiplier>().Id));
            }

            return(result);
        }
示例#4
0
 protected TRate GetRate <TRate>()
     where TRate : IRate, new()
 {
     return(RatesManager.GetInstance <TRate>());
 }