示例#1
0
        public static void SerializableTable(string[] values, int nKey, Hashtable _hash)
        {
            if (values == null)
            {
                throw TableException.ErrorReader("values is null. Table: {0}  Key:{1}.", GetInstanceFile(), nKey);
            }
            if (values.Length != VALUE_NUM_PER_ROW)
            {
                throw TableException.ErrorReader("Load {0}  error as CodeSize:{1} not Equal DataSize:{2}", GetInstanceFile(), VALUE_NUM_PER_ROW, values.Length);
            }
            Tab_GoodData tabData = new Tab_GoodData();

            tabData.m_EventDropId[0] = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[7]));

            tabData.m_EventDropId[1] = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[9]));

            tabData.m_EventDropId[2] = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[11]));

            tabData.m_EventRatioDrop = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[5]));
            tabData.m_EventRatioRise = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[6]));
            tabData.m_EventRiseId[0] = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[8]));

            tabData.m_EventRiseId[1] = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[10]));

            tabData.m_EventRiseId[2] = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[12]));

            tabData.m_Icon     = values[1];
            tabData.m_ID       = nKey;
            tabData.m_Name     = values[0];
            tabData.m_PriceMax = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[4]));
            tabData.m_PriceMin = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[3]));
            tabData.m_Repute   = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[2]));

            _hash.Add(nKey, tabData);
        }
    private List <PackageField> GetFields(TableReader reader)
    {
        List <PackageField> fields = new List <PackageField>();
        int number = reader.ReadInt32();        //字段数量

        for (int i = 0; i < number; ++i)
        {
            if (reader.ReadInt8() == 0)         //基础类型
            {
                int  type  = reader.ReadInt8(); //基础类型索引
                bool array = reader.ReadBool(); //是否是数组
                fields.Add(new PackageField()
                {
                    Index = i,
                    Name  = "Value" + i,
                    Type  = BasicUtil.GetType((BasicEnum)type).ScorpioName,
                    Array = array,
                });
            }
            else                                    //自定义类
            {
                string type  = reader.ReadString(); //自定义类名称
                bool   array = reader.ReadBool();   //是否是数组
                fields.Add(new PackageField()
                {
                    Index = i,
                    Name  = "Value" + i,
                    Type  = type,
                    Array = array,
                });
            }
        }
        return(fields);
    }
示例#3
0
        public static Tab_Adventure SerializableTableItem(string[] values, int nKey, Hashtable _hash)
        {
            if (values == null)
            {
                throw TableException.ErrorReader("values is null. Table: {0}  Key:{1}.", GetInstanceFile(), nKey);
            }
            if (values.Length != VALUE_NUM_PER_ROW)
            {
                throw TableException.ErrorReader("Load {0}  error as CodeSize:{1} not Equal DataSize:{2}", GetInstanceFile(), VALUE_NUM_PER_ROW, values.Length);
            }
            Tab_Adventure tabData = new Tab_Adventure();

            tabData.m_Cash      = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[1]));
            tabData.m_Condition = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[6]));
            tabData.m_Content   = values[0];
            tabData.m_Debt      = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[3]));
            tabData.m_Deposit   = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[2]));
            tabData.m_GoodId    = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[7]));
            tabData.m_GoodNum   = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[8]));
            tabData.m_Health    = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[4]));
            tabData.m_ID        = nKey;
            tabData.m_Ratio     = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[9]));
            tabData.m_Repute    = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[5]));

            _hash.Add(nKey, tabData);
            return(tabData);
        }
示例#4
0
 //解析文件结构
 private void ParseLayout()
 {
     mFields.Clear();
     mUsedCustoms.Clear();
     for (int i = 0; i < mMaxColumn; ++i)
     {
         PackageField field = new PackageField();
         field.Index   = i;
         field.Comment = mDataTable[0][i];            //第0行是注释
         field.Name    = mDataTable[1][i];            //第1行是字段名
         field.Default = mDataTable[3][i];            //第3行是字段默认值
         var            attribute = mDataTable[2][i]; //第2行是字段属性
         Scorpio.Script script    = new Scorpio.Script();
         script.LoadLibrary();
         if (string.IsNullOrEmpty(attribute))
         {
             field.Attribute = script.CreateTable();
         }
         else
         {
             field.Attribute = (script.LoadString("return {" + attribute + "}") as ScriptTable) ?? script.CreateTable();
         }
         string columnType = mDataTable[4][i];   //第4行是字段类型
         string fieldType  = "";
         if (columnType.StartsWith(Util.ArrayString))
         {
             field.Array = true;
             int iFinalIndex = Util.ArrayString.Length;
             fieldType = columnType.Substring(iFinalIndex, columnType.Length - iFinalIndex);
         }
         else
         {
             field.Array = false;
             fieldType   = columnType;
         }
         field.Type = fieldType;
         bool basic = BasicUtil.HasType(fieldType);
         if (!basic && !mCustoms.ContainsKey(fieldType) && !mEnums.ContainsKey(fieldType))
         {
             throw new System.Exception(string.Format("第[{0}]列的 字段类型[{1}] 不能识别", Util.GetLineName(i), columnType));
         }
         if (i == 0 && (field.Array == true || field.Info.BasicIndex != BasicEnum.INT32))
         {
             throw new System.Exception("第一列的数据类型必须为int32类型");
         }
         field.Enum = mEnums.ContainsKey(fieldType);
         //保存使用的自定义结构
         if (!basic && !field.Enum && !mUsedCustoms.Contains(fieldType))
         {
             mUsedCustoms.Add(fieldType);
         }
         mFields.Add(field);
     }
     if (mFields.Count == 0)
     {
         throw new System.Exception("字段个数为0");
     }
     mKeyName = mFields[0].Name;
 }
示例#5
0
 public Int32 GetEventRiseIdbyIndex(int idx)
 {
     if (idx >= 0 && idx < 3)
     {
         return(BasicUtil.DecryptInt32Value(m_EventRiseId[idx]));
     }
     return(-1);
 }
示例#6
0
    private void WriteField(TableWriter writer, object value, PackageField field)
    {
        var basic = BasicUtil.GetType(field.Type);

        if (basic != null)
        {
            if (field.Array)
            {
                var list = value as ScriptArray;
                if (Util.IsEmptyValue(list))
                {
                    writer.WriteInt32(0);
                }
                else
                {
                    int count = list.Count();
                    writer.WriteInt32(count);
                    for (int i = 0; i < count; ++i)
                    {
                        basic.WriteValue(writer, list.GetValue(i).ToString());
                    }
                }
            }
            else
            {
                basic.WriteValue(writer, value.ToString());
            }
        }
        else if (field.Enum)
        {
            if (field.Array)
            {
                var list = value as ScriptArray;
                if (Util.IsEmptyValue(list))
                {
                    writer.WriteInt32(0);
                }
                else
                {
                    int count = list.Count();
                    writer.WriteInt32(count);
                    for (int i = 0; i < count; ++i)
                    {
                        writer.WriteInt32(GetEnumValue(field.Type, value.ToString()));
                    }
                }
            }
            else
            {
                writer.WriteInt32(GetEnumValue(field.Type, value.ToString()));
            }
        }
        else
        {
            WriteCustom(writer, value as ScriptArray, mCustoms[field.Type], field.Array);
        }
    }
示例#7
0
        /// <summary>
        /// Called very early, just after main assemblies are loaded, before logos. Saves have not been scanned and most game data are unavailable.
        /// Full info at https://github.com/Sheep-y/Modnix/wiki/DLL-Specs#SplashMod
        /// </summary>
        /// <param name="api">First param (string) is the query/action. Second param (object) and result (object) varies by action.</param>
        public void SplashMod(ModnixCallback api = null)
        {
            // Technically, SplashMod isn't the right place to init this mod. However, it ensures a VERY
            // early load, and it doesn't cause any issues. This means PPDefModifier can modify it.
            harmInst = HarmonyInstance.Create(typeof(MyMod).FullName);
            harmInst.PatchAll();
            FileLog.logPath = "./Mods/PPWB_Harmony.log";
            FileLog.Log("PPWB...");
            BasicUtil.EnsureAPI(ref api);
            BasicUtil.GetConfig(ref Config, api);
            storedAPI = api;

            DefRepository definitions_repo = GameUtl.GameComponent<DefRepository>();
            List<WeaponDef> WeaponList = definitions_repo.GetAllDefs<WeaponDef>().ToList();
            List<DamageKeywordDef> damageKeywords = definitions_repo.GetAllDefs<DamageKeywordDef>().ToList();

            BasicUtil.Log($"Found {WeaponList.Count} weapons loaded into the game.", api);
            BasicUtil.Log($"Found {damageKeywords.Count} damage types loaded into the game.", api);

            #region DamageTypeSetup
            List<DamageKeywordPair> damageKeywordPairsToAdd = new List<DamageKeywordPair>();
            if (Config.add_bleed) {
                damageKeywordPairsToAdd.Add(new DamageKeywordPair() {
                    Value = 0,
                    DamageKeywordDef = damageKeywords.Find(x => x.name.Contains("Bleed"))
                });
            }
            if (Config.add_pierce) {
                damageKeywordPairsToAdd.Add(new DamageKeywordPair() {
                    Value = 0,
                    DamageKeywordDef = damageKeywords.Find(x => x.name.Contains("Pierc")) // Because it's truncated "Piercing"
                });
            }
            if (Config.add_shred) {
                damageKeywordPairsToAdd.Add(new DamageKeywordPair() {
                    Value = 0,
                    DamageKeywordDef = damageKeywords.Find(x => x.name.Contains("Shred"))
                });
            };
            #endregion

            BasicUtil.Log("Adding damage types to all weapons.", api);
            foreach (WeaponDef weapon in WeaponList) {
                foreach (DamageKeywordPair dkp in damageKeywordPairsToAdd) {
                    if (!weapon.DamagePayload.DamageKeywords.Exists(x => x.DamageKeywordDef == dkp.DamageKeywordDef)) {
                        weapon.DamagePayload.DamageKeywords.Add(dkp.Clone());
#if DEBUG
                        BasicUtil.Log($"Had to add damage type {dkp.DamageKeywordDef.Visuals.DisplayName1.Localize()} to {weapon.GetDisplayName().Localize()}", api);
#endif
                    }
                }
                weapon.DamagePayload.DamageKeywords.Sort( (x, y) => x.CompareTo(y));
            }

            BasicUtil.Log("Done adding damage types.", api);
        }
示例#8
0
    /// <summary> 生成Table类的代码 </summary>
    private void CreateTable(ProgramInfo info)
    {
        var str = info.GenerateTable.Generate(mPackage);

        str = str.Replace("__TableName", TableClassName);
        str = str.Replace("__DataName", DataClassName);
        str = str.Replace("__KeyName", mKeyName);
        str = str.Replace("__KeyType", BasicUtil.GetType(BasicEnum.INT32).GetCode(info.Code));
        str = str.Replace("__MD5", GetClassMD5Code());
        info.CreateFile(TableClassName, str);
    }
示例#9
0
        public void StartUp()
        {
            start = DateTime.Now;

            basicUtil = new BasicUtil();

            //runTimeItems = new CSPortalTesting.Models.General.RunTimeItems(RI)
            //{
            //    driv = this.driv,
            //    basicUtil = this.basicUtil,
            //};
        }
示例#10
0
        public void StartUp()
        {
            start = DateTime.Now;

            basicUtil = new BasicUtil();

            runTimeItems = new Restest.Models.General.RunTimeItems(RI)
            {
                basicUtil = this.basicUtil,
            };
            RestHelper restHelper = new RestHelper();

            token = restHelper.GetAuth("https://10.4.11.78:8443/lod-minor/api/v1/", "116eb1e753aa4cafbe382bf2359f3a8f", "231bbc92870c417f925d52cea3e3a03d");
        }
示例#11
0
        /// <summary>
        /// Skip SetStat if stat is 0
        /// </summary>
        public static bool Prefix(
            UIItemTooltip __instance, MethodInfo __originalMethod,
            LocalizedTextBind statLocalization, bool secondObject, object statValue,
            object statCompareValue = null, UnityEngine.Sprite statIcon = null )
        {
            float svFloat,scvFloat;
            string svType, scvType = "";
            string svString = statValue as string ?? "null" ;
            string scvString = statCompareValue as string ?? "null";
            string zeroPercent = Base.UI.UIUtil.PercentageStat(0f, __instance.PercentageString.Localize(null));

            try {
                svFloat = (float)statValue;
            } catch (InvalidCastException) {
                svFloat = 12.34f;
            }
            try {
                scvFloat = (float)statValue;
            } catch (InvalidCastException) {
                scvFloat = 12.34f;
            }
            try {
                svType = statValue.GetType().ToString();
            } catch (NullReferenceException) {
                svType = "NULL";
            }
            try {
                scvType = statCompareValue.GetType().ToString();
            } catch (NullReferenceException) {
                scvType = "NULL";
            }

            bool svSkip = svString == "0" || svString == zeroPercent || svFloat == 0f;
            bool scvSkip = scvString == "0" || scvString == zeroPercent || scvFloat == 0f;
#if DEBUG
            BasicUtil.Log($"Injected into {__instance.GetType()}.{__originalMethod.Name}()", MyMod.storedAPI);
            BasicUtil.Log($"  {statLocalization.Localize()} [2nd: {secondObject}]", MyMod.storedAPI);
            BasicUtil.Log($"  SV: {statValue ?? 0,4} [{svType}]", MyMod.storedAPI);
            BasicUtil.Log($"  CV: {statCompareValue ?? 0,4} [{scvType}]", MyMod.storedAPI);
            BasicUtil.Log($"  SVSkip: {svSkip}", MyMod.storedAPI);
            BasicUtil.Log($"  CVSkip: {scvSkip}", MyMod.storedAPI);
#endif

            return !(scvSkip && svSkip) || MyMod.Config.show_zeros;
        }
示例#12
0
    public void WriteDateTime(string value)
    {
        double span;

        if (double.TryParse(value, out span))
        {
            writer.Write(BasicUtil.GetTimeSpan(DateTime.FromOADate(span)));
            return;
        }
        DateTime datetime;

        if (DateTime.TryParse(value, out datetime))
        {
            writer.Write(BasicUtil.GetTimeSpan(datetime));
            return;
        }
        throw new Exception("不能识别日志字符串 : " + value);
    }
示例#13
0
        public static void SerializableTable(string[] values, int nKey, Hashtable _hash)
        {
            if (values == null)
            {
                throw TableException.ErrorReader("values is null. Table: {0}  Key:{1}.", GetInstanceFile(), nKey);
            }
            if (values.Length != VALUE_NUM_PER_ROW)
            {
                throw TableException.ErrorReader("Load {0}  error as CodeSize:{1} not Equal DataSize:{2}", GetInstanceFile(), VALUE_NUM_PER_ROW, values.Length);
            }
            Tab_Event tabData = new Tab_Event();

            tabData.m_Content     = values[0];
            tabData.m_EventEffect = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[1]));
            tabData.m_ID          = nKey;

            _hash.Add(nKey, tabData);
        }
示例#14
0
    protected override string Generate_impl()
    {
        var builder = new StringBuilder();

        builder.Append($@"//本文件为自动生成,请不要手动修改
{ClassName} = [");
        foreach (var field in Fields)
        {
            var languageType = field.GetLanguageType(Language);
            languageType = field.IsEnum ? BasicUtil.GetType(BasicEnum.INT32).Name : languageType;
            builder.Append($@"
    /* {field.Comment}  默认值({field.Default}) */
    {{ Index : {field.Index}, Name : ""{field.Name}"", Type : ""{languageType}"", Array : {field.IsArray.ToString().ToLower()}, Attribute : {field.AttributeString} }},
");
        }
        builder.Append(@"
]");
        return(builder.ToString());
    }
示例#15
0
        public static Tab_Rental SerializableTableItem(string[] values, int nKey, Hashtable _hash)
        {
            if (values == null)
            {
                throw TableException.ErrorReader("values is null. Table: {0}  Key:{1}.", GetInstanceFile(), nKey);
            }
            if (values.Length != VALUE_NUM_PER_ROW)
            {
                throw TableException.ErrorReader("Load {0}  error as CodeSize:{1} not Equal DataSize:{2}", GetInstanceFile(), VALUE_NUM_PER_ROW, values.Length);
            }
            Tab_Rental tabData = new Tab_Rental();

            tabData.m_ID        = nKey;
            tabData.m_Introduce = values[0];
            tabData.m_PriceMin  = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[2]));
            tabData.m_Size      = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[1]));

            _hash.Add(nKey, tabData);
            return(tabData);
        }
示例#16
0
 private void WriteFields(TableWriter writer, List <PackageField> fields)
 {
     writer.WriteInt32(fields.Count);
     for (int i = 0; i < fields.Count; ++i)
     {
         var field = fields[i];
         var basic = BasicUtil.GetType(field.Type);
         if (basic != null)
         {
             writer.WriteByte(0);
             writer.WriteByte((sbyte)basic.BasicIndex);
             writer.WriteBool(field.Array);
         }
         else
         {
             writer.WriteByte(1);
             writer.WriteString(field.Type);
             writer.WriteBool(field.Array);
         }
     }
 }
示例#17
0
        public static void SerializableTable(string[] values, int nKey, Hashtable _hash)
        {
            if (values == null)
            {
                throw TableException.ErrorReader("values is null. Table: {0}  Key:{1}.", GetInstanceFile(), nKey);
            }
            if (values.Length != VALUE_NUM_PER_ROW)
            {
                throw TableException.ErrorReader("Load {0}  error as CodeSize:{1} not Equal DataSize:{2}", GetInstanceFile(), VALUE_NUM_PER_ROW, values.Length);
            }
            Tab_PlayerData tabData = new Tab_PlayerData();

            tabData.m_Cash    = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[2]));
            tabData.m_Debt    = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[4]));
            tabData.m_Deposit = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[3]));
            tabData.m_Health  = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[5]));
            tabData.m_Icon    = values[1];
            tabData.m_ID      = nKey;
            tabData.m_Name    = values[0];
            tabData.m_Repute  = BasicUtil.EncryptInt32Value(Convert.ToInt32(values[6]));

            _hash.Add(nKey, tabData);
        }
示例#18
0
    protected override string Generate_impl()
    {
        StringBuilder builder = new StringBuilder();

        builder.Append(@"//本文件为自动生成,请不要手动修改
__ClassName = [");
        foreach (var field in m_Fields)
        {
            string str = @"
    { Index = __Index, Name = ""__Name"", Type = ""__Type"", Array = __Array, Attribute = __Attribute },     /* __Note  默认值(__Default) */";
            str = str.Replace("__Index", field.Index.ToString());
            str = str.Replace("__Name", field.Name);
            str = str.Replace("__Type", field.Enum ? BasicUtil.GetType(BasicEnum.INT32).ScorpioName : field.Type);
            str = str.Replace("__Note", field.Comment);
            str = str.Replace("__Attribute", field.Attribute != null ? field.Attribute.ToJson() : "{}");
            str = str.Replace("__Default", field.Default);
            str = str.Replace("__Array", field.Array ? "true" : "false");
            builder.Append(str);
        }
        builder.Append(@"
]");
        builder = builder.Replace("__ClassName", m_ClassName);
        return(builder.ToString());
    }
示例#19
0
        /// <summary>
        /// Called after basic assets are loaded, before the hottest year cinematic. Virtually the same time as PPML.
        /// Full info at https://github.com/Sheep-y/Modnix/wiki/DLL-Specs#MainMod
        /// </summary>
        /// <param name="api">First param (string) is the query/action. Second param (object) and result (object) varies by action.</param>
        public static void MainMod(ModnixCallback api = null)
        {
            BasicUtil.EnsureAPI(ref api);
            BasicUtil.GetConfig(ref Config, api);

            api("log info", "New MainMod initialized");
            DefRepository gameRootDef = GameUtl.GameComponent <DefRepository>();

            List <TacticalItemDef> tacticalItems = gameRootDef.GetAllDefs <TacticalItemDef>().ToList().FindAll(
                new Predicate <TacticalItemDef>(FilterDefList)
                );

            BasicUtil.Log($"Readied {tacticalItems.Count} Independent tactical items.", api);

            string guid = "";

            I2.Loc.LanguageSourceData langDB = I2.Loc.LocalizationManager.Sources[0];
            int englishKey = langDB.GetLanguageIndex("English");

            foreach (ItemDef item in tacticalItems)
            {
                bool isWeapon = item.GetType() == typeof(WeaponDef);
#if DEBUG
                BasicUtil.Log($"Making Reverse Engineer for: {item.GetDisplayName().Localize()} - {item}", api);
#endif
                ResearchTagDef optional              = (ResearchTagDef)gameRootDef.GetDef("08191866-ff38-9e74-abd7-cb484188911a");
                GeoFactionDef  PhoenixPointFaction   = (GeoFactionDef)gameRootDef.GetDef("8be7e872-0ad2-a2a4-7bee-c980ed304a8a");
                GeoFactionDef  DisciplesOfAnuFaction = (GeoFactionDef)gameRootDef.GetDef("edc6783a-be00-1a84-2b97-2fe1e0fc5448");
                GeoFactionDef  NewJerichoFaction     = (GeoFactionDef)gameRootDef.GetDef("d31c78b9-ff0e-8b94-ab96-9672da73da54");
                GeoFactionDef  SynedrionFaction      = (GeoFactionDef)gameRootDef.GetDef("0e6dc218-e157-5954-c9ab-1a0606e0d914");

                // 1 + length of compatible ammo list
                int       researchUnlockLength = 1 + ((isWeapon) ? ((WeaponDef)item).CompatibleAmmunition.Length : 0);
                ItemDef[] researchUnocks       = new ItemDef[researchUnlockLength];
                researchUnocks[0] = item;
                for (int i = 1; i < researchUnlockLength; i++)
                {
                    researchUnocks[i] = ((WeaponDef)item).CompatibleAmmunition[i - 1];
                }

                string[] guidparts = item.Guid.Split('-');
                string   guidBase  = string.Join("-", guidparts.Take(3));
                string   guidTail  = "deadbeefbabe";
                int      typeInt;

                #region Generate reverse engineering def
                typeInt = (int)ResearchGUIDSegments.ReceiveItemResearchRequirement;
                ReceiveItemResearchRequirementDef rirrDef = ScriptableObject.CreateInstance <ReceiveItemResearchRequirementDef>();
                rirrDef.name    = item.name + "_ReceiveItemResearchRequirementDef";
                rirrDef.Guid    = $"{guidBase}-{typeInt:x4}-{guidTail}";
                rirrDef.ItemDef = item;

                typeInt = (int)ResearchGUIDSegments.ItemResearchCost;
                string I2Key = $"REVERSE_ENGINEER_COSTDEF_{item.name}";
                ItemResearchCostDef ircDef = ScriptableObject.CreateInstance <ItemResearchCostDef>();
                ircDef.name             = item.name + "_ItemResearchCostDef";
                ircDef.Guid             = $"{guidBase}-{typeInt:x4}-{guidTail}";
                ircDef.ItemDef          = item;
                ircDef.Amount           = 1;
                ircDef.LocalizationText = new Base.UI.LocalizedTextBind()
                {
                    LocalizationKey = I2Key
                };
                langDB.AddTerm($"REVERSE_ENGINEER_COSTDEF_{item.name}", I2.Loc.eTermType.Text);
                langDB.GetTermData(I2Key).Languages[englishKey] = "Needed items {0}/{1}";

                typeInt = (int)ResearchGUIDSegments.ManufactureResearchReward;
                ManufactureResearchRewardDef mrdDef = ScriptableObject.CreateInstance <ManufactureResearchRewardDef>();
                mrdDef.name  = item.name + "_ManufactureResearchRewardDef";
                mrdDef.Guid  = $"{guidBase}-{typeInt:x4}-{guidTail}";
                mrdDef.Items = researchUnocks;

                typeInt = (int)ResearchGUIDSegments.Research;
                string      rName = item.name + "_ResearchDef";
                ResearchDef reverseEngineerDef = ScriptableObject.CreateInstance <ResearchDef>();
                reverseEngineerDef.name             = rName;
                reverseEngineerDef.Guid             = $"{guidBase}-{typeInt:X4}-{guidTail}";
                reverseEngineerDef.Id               = rName;
                reverseEngineerDef.Faction          = PhoenixPointFaction;
                reverseEngineerDef.Costs            = new ResearchCostDef[] { ircDef };
                reverseEngineerDef.ResearchCost     = 100;
                reverseEngineerDef.Tags             = new ResearchTagDef[] { optional };
                reverseEngineerDef.ValidForFactions = new List <GeoFactionDef> {
                    PhoenixPointFaction
                };
                reverseEngineerDef.Unlocks       = new ResearchRewardDef[] { mrdDef };
                reverseEngineerDef.InitialStates = new ResearchDef.InitialResearchState[] {
                    new ResearchDef.InitialResearchState {
                        Faction = PhoenixPointFaction,
                        State   = ResearchState.Hidden
                    },
                    new ResearchDef.InitialResearchState {
                        Faction = DisciplesOfAnuFaction,
                        State   = ResearchState.Hidden
                    },
                    new ResearchDef.InitialResearchState {
                        Faction = NewJerichoFaction,
                        State   = ResearchState.Hidden
                    },
                    new ResearchDef.InitialResearchState {
                        Faction = SynedrionFaction,
                        State   = ResearchState.Hidden
                    }
                };
                reverseEngineerDef.RevealRequirements.Container = new ReseachRequirementDefOpContainer[] {
                    new ReseachRequirementDefOpContainer()
                    {
                        Operation    = ResearchContainerOperation.ALL,
                        Requirements = new ResearchRequirementDef[] {
                            rirrDef
                        }
                    }
                };
#if DEBUG
                BasicUtil.Log($"{researchUnocks.Length} items prepared for the rDef.", api);
                BasicUtil.Log(ircDef.LocalizationText.Localize(), api);
#if NOISY
                BasicUtil.Log(reverseEngineerDef.Repr(), api);
#endif
#endif
                #endregion
                gameRootDef.CreateRuntimeDef(rirrDef, rirrDef.GetType(), rirrDef.Guid);
                gameRootDef.CreateRuntimeDef(ircDef, ircDef.GetType(), ircDef.Guid);
                gameRootDef.CreateRuntimeDef(mrdDef, mrdDef.GetType(), mrdDef.Guid);
                gameRootDef.CreateRuntimeDef(reverseEngineerDef, guid: reverseEngineerDef.Guid);
                guid = reverseEngineerDef.Guid;
            }
#if DEBUG
            foreach (GeoFactionDef fact in gameRootDef.GetAllDefs <GeoFactionDef>().ToList())
            {
                BasicUtil.Log(fact.Render(), api);
            }
            BasicUtil.Log($"Looking for GUID: {guid}", api);
            DefRepository temp = GameUtl.GameComponent <DefRepository>();
            ResearchDef   rDef = (ResearchDef)temp.GetDef(guid);
            BasicUtil.Log(rDef.name, api);
            BasicUtil.Log(rDef.Guid, api);
            BasicUtil.Log(rDef.Costs[0].Guid, api);
            BasicUtil.Log(rDef.Unlocks[0].Guid, api);
            BasicUtil.Log(rDef.RevealRequirements.Container[0].Requirements[0].Guid, api);

            BasicUtil.Log(
                rDef.Repr(),
                api);
            BasicUtil.Log(
                // Reverse Engineering example
                ((ResearchDef)temp.GetDef("15d2170b-469b-0341-22d4-a8b4d90eefb8")).Repr(),
                api);
#if COMPAREMANY
            BasicUtil.Log(
                // Capture research
                ((ResearchDef)temp.GetDef("c7b3f8ab-8c90-0343-823b-c966d2c4edb8")).Repr(),
                api);
            BasicUtil.Log(
                // Research that rewards multiple resources
                temp.GetAllDefs <ResearchDef>().ToList().Find(x => x.Resources.Count > 1).Repr(),
                api);
#endif
#endif
        }
示例#20
0
 private DataTable()
 {
     BasicUtil.GenerateCryptPlusValue();
 }
示例#21
0
    public string GetCodeType(string type)
    {
        var b = BasicUtil.GetType(type);

        return(b != null?b.GetCode(m_Code) : type);
    }
示例#22
0
    //生成data文件数据
    private void Transform_impl()
    {
        int         iColums = mMaxColumn;           //数据列数
        int         iRows   = mMaxRow;              //数据行数
        TableWriter writer  = new TableWriter();

        writer.WriteInt32(0);                       //写入行数(最后计算出有效数据然后写入)
        writer.WriteString(GetClassMD5Code());      //写入文件MD5码
        WriteFields(writer, mFields);               //写入表结构
        writer.WriteInt32(mUsedCustoms.Count);      //写入用到的自定义类数量
        foreach (var key in mUsedCustoms)
        {
            writer.WriteString(key);
            WriteFields(writer, mCustoms[key]);
        }
        List <string> keys  = new List <string>();
        int           count = 0;

        for (int i = START_ROW; i < iRows; ++i)
        {
            string ID = "";
            for (int j = 0; j < iColums; ++j)
            {
                string value = mDataTable[i][j];
                var    field = mFields[j];
                try {
                    if (string.IsNullOrEmpty(value))
                    {
                        value = string.IsNullOrEmpty(field.Default) ? Util.EmptyString : field.Default;    //数据为空设置为默认值
                    }
                    if (j == 0)
                    {
                        if (keys.Contains(value))
                        {
                            throw new Exception(string.Format("ID有重复项[{0}]", value));
                        }
                        else if (Util.IsEmptyString(value))
                        {
                            throw new Exception("ID字段不能为空");
                        }
                        ID = value;
                        keys.Add(value);
                    }
                    if (ExecuteField != null)
                    {
                        ExecuteField(field, ID, ref value);
                    }
                    var basic = BasicUtil.GetType(field.Type);
                    if (basic != null || field.Enum)
                    {
                        if (field.Array)
                        {
                            WriteField(writer, Util.ReadValue(mEnums, mDataTable[i].RowNumber, Util.GetLineName(j), value, false, true), field);
                        }
                        else
                        {
                            WriteField(writer, value, field);
                        }
                    }
                    else
                    {
                        WriteCustom(writer, Util.ReadValue(mEnums, mDataTable[i].RowNumber, Util.GetLineName(j), value, true, field.Array), mCustoms[field.Type], field.Array);
                    }
                } catch (System.Exception ex) {
                    throw new SystemException(string.Format("[{0}]行[{1}]列出错 数据内容为[{2}] : {3}", mDataTable[i].RowNumber, Util.GetLineName(j), value, ex.ToString()));
                }
            }
            count++;
        }
        writer.Seek(0);
        writer.WriteInt32(count);
        Create_impl(writer.ToArray());
    }
示例#23
0
    public string GetCodeType(BasicEnum type)
    {
        var b = BasicUtil.GetType(type);

        return(b != null?b.GetCode(m_Code) : type.ToString());
    }
示例#24
0
 public static void Prefix(TacticalItemDef tacItemDef, MethodInfo __originalMethod)
 {
     string str = $"Successfully injected into {__originalMethod.ReflectedType}.{__originalMethod.Name}, object is {tacItemDef.GetDisplayName().Localize()}";
     BasicUtil.Log(str, MyMod.storedAPI);
     FileLog.Log(str);
 }