public static void Postfix(MechComponent __instance, WeaponHitInfo hitInfo, ComponentDamageLevel damageLevel, bool applyEffects)
 {
     try {
         Log.Debug?.TWL(0, "MechComponent.DamageComponent Postfix " + __instance.defId + " DamageLevel:" + __instance.DamageLevel + "/" + damageLevel);
         if ((__instance.DamageLevel >= ComponentDamageLevel.Destroyed) || (damageLevel >= ComponentDamageLevel.Destroyed))
         {
             Statistic isCAEDestroyed = __instance.StatCollection.GetStatistic("CAEDestroyed");
             if (isCAEDestroyed == null)
             {
                 isCAEDestroyed = __instance.StatCollection.AddStatistic("CAEDestroyed", false);
             }
             if (isCAEDestroyed.Value <bool>() == false)
             {
                 isCAEDestroyed.SetValue(true);
                 Log.Debug?.WL(1, "really destroyed at first time");
                 ActivatableComponent activatable = __instance.componentDef.GetComponent <ActivatableComponent>();
                 if (activatable == null)
                 {
                     Log.Debug?.WL(1, "not activatable");
                     return;
                 }
                 ObjectSpawnDataSelf VFX = __instance.PresitantVFX();
                 if (VFX != null)
                 {
                     VFX.CleanupSelf();
                 }
                 ;
                 VFX = __instance.ActivateVFX();
                 if (VFX != null)
                 {
                     VFX.CleanupSelf();
                 }
                 ;
                 VFX = __instance.DestroyedVFX();
                 if (VFX != null)
                 {
                     VFX.SpawnSelf(__instance.parent.Combat);
                 }
                 ;
                 if (activatable.ExplodeOnDamage)
                 {
                     __instance.AoEExplodeComponent();
                 }
                 ;
                 __instance.playDestroySound();
             }
             else
             {
                 Log.Debug?.WL(1, "not a really destroyed");
             }
             __instance.UpdateAuras();
         }
     } catch (Exception e) {
         Log.Debug?.TWL(0, e.ToString(), true);
     }
 }
Exemplo n.º 2
0
 public static void Postfix(MechComponent __instance, WeaponHitInfo hitInfo, ComponentDamageLevel damageLevel, bool applyEffects, ref bool __state)
 {
     if (__state)
     {
         ActivatableComponent activatable = __instance.componentDef.GetComponent <ActivatableComponent>();
         if (activatable == null)
         {
             Log.LogWrite(" not activatable\n");
             return;
         }
         ObjectSpawnDataSelf VFX = __instance.PresitantVFX();
         if (VFX != null)
         {
             VFX.CleanupSelf();
         }
         ;
         VFX = __instance.ActivateVFX();
         if (VFX != null)
         {
             VFX.CleanupSelf();
         }
         ;
         VFX = __instance.DestroyedVFX();
         if (VFX != null)
         {
             VFX.SpawnSelf(__instance.parent.Combat);
         }
         ;
         if (activatable.ExplodeOnDamage)
         {
             __instance.AoEExplodeComponent();
         }
         ;
         __instance.playDestroySound();
     }
     else
     {
         Log.LogWrite(" no additional processing\n");
     }
     __instance.UpdateAuras();
 }