Exemple #1
0
 public override string ToString()
 {
     return(id.ToString());
 }
Exemple #2
0
    /// <summary>
    /// Gets the end to end encrypt.
    /// </summary>
    /// <returns>The end to end encrypt.</returns>
    /// <param name="partner">Partner.</param>
    /// <param name="group">Group .</param>
    public EndToEndEncrypt GetEndToEndEncrypt(EntityId partner, EntityId group)
    {
        var key = new ValueTuple <EntityId, EntityId> (partner, group);

        if (groupEndToEndEncryptInstances.ContainsKey(key))
        {
            return(groupEndToEndEncryptInstances[key]);
        }
        if (!DataController.encryptionLoaded)
        {
            throw new Exception("Master file encryption key has to loaded/entered/derived bevore chain keys can be loaded");
        }
        // try to load it
        try {
            groupEndToEndEncryptInstances[key] = DataController.Instance.LoadObject <GroupEndToEndEncryption> (key.ToString());
            return(groupEndToEndEncryptInstances[key]);
        } catch (Exception) {
            return(new EndToEndEncrypt(partner));
        }
    }
Exemple #3
0
        public static bool EconomyTweak_h_GetSupplyDemandForCategory(Town town, ItemCategory category, float dailySupply, float dailyDemand, float oldSupply, float oldDemand, ref ValueTuple <float, float> __result)
        {
            float num  = dailySupply;
            float num2 = (float)EconomyTweak_h_globalConstants.EconomyTweak_h_OptimalStockPeriodPrice * dailyDemand;
            float item = oldDemand * MathF.Pow(dailyDemand / oldDemand, 0.2f);
            float num3 = MathF.Pow((num2 + dailyDemand + 1f) / (num + dailyDemand + 1f), EconomyTweak_h_globalConstants.EconomyTweak_h_LongtermPriceMultiplierExpValue);
            bool  flag = oldSupply > 10f;

            if (flag)
            {
                oldSupply = MathF.Clamp(oldDemand / oldSupply, 0.5f, 1.5f);
            }
            float num4 = oldSupply * MathF.Pow(num3 / oldSupply, 0.2f);

            num4     = MathF.Clamp(num4, 0.4f, 10f);
            __result = new ValueTuple <float, float>(num4, item);
            bool flag2 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 0;

            if (flag2)
            {
                using (StreamWriter streamWriter = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                {
                    streamWriter.WriteLine("EconomyTweak_h_GetSupplyDemandForCategory");
                }
                bool economyTweak_h_DebugDisplay = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugDisplay;
                if (economyTweak_h_DebugDisplay)
                {
                    InformationManager.DisplayMessage(new InformationMessage("EconomyTweak_h_GetSupplyDemandForCategory"));
                }
                bool flag3 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 1;
                if (flag3)
                {
                    using (StreamWriter streamWriter2 = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                    {
                        streamWriter2.WriteLine(string.Concat(new string[]
                        {
                            "town = ",
                            town.ToString(),
                            ", category = ",
                            category.ToString(),
                            ", dailySupply = ",
                            dailySupply.ToString(),
                            ", dailyDemand = ",
                            dailyDemand.ToString(),
                            ", oldSupply = ",
                            oldSupply.ToString(),
                            ", oldDemand = ",
                            oldDemand.ToString(),
                            ", EconomyTweak_h_LongtermPriceMultiplier = ",
                            num3.ToString(),
                            ", newDemand(item) = ",
                            item.ToString(),
                            ", newSupply(num) = ",
                            num4.ToString(),
                            ", EconomyTweak_h_GetSupplyDemandForCategory(result) = ",
                            __result.ToString()
                        }));
                    }
                }
            }
            return(false);
        }