示例#1
0
        //
        // Harmony Library Patches
        //

        /// <summary> Patches GetEnemyInstance so that SoG can create modded enemy instances. </summary>
        private static bool GetEnemyInstance_PrefixPatch(ref Enemy __result, EnemyCodex.EnemyTypes enType, Level.WorldRegion enOverrideContent)
        {
            if (!enType.IsModEnemy())
            {
                return(true); // Executes original method
            }

            EnemyDescription xDesc = EnemyCodex.denxDescriptionDict[enType];

            __result = new Enemy()
            {
                xEnemyDescription = xDesc,
                enType            = enType
            };

            __result.xRenderComponent.xOwnerObject = __result;

            ModEnemyData xModData = ModLibrary.EnemyDetails[enType];

            xModData.InstanceBuilder?.Invoke(__result);

            __result.xBaseStats.iLevel = __result.xEnemyDescription.iLevel;
            __result.xBaseStats.iHP    = (__result.xBaseStats.iBaseMaxHP = __result.xEnemyDescription.iMaxHealth);
            if (__result.xEnemyDescription.enCategory == EnemyDescription.Category.Regular)
            {
                __result.rcRegularHPRenderComponent = new RegularEnemyHPRenderComponent(__result);
            }
            __result.xRenderComponent.bReSortHeight = true;
            __result.xRenderComponent.GetCurrentAnimation().Reset();
            foreach (DropChance xDrop in __result.xEnemyDescription.lxLootTable)
            {
                __result.lxLootTable.Add(new DropChance(xDrop.iChance, xDrop.enItemToDrop, xDrop.iRolls));
                ItemCodex.GetItemDescription(xDrop.enItemToDrop);
            }

            return(false); // Skips original method
        }