示例#1
0
 [HarmonyPostfix, HarmonyPatch(typeof(ExosuitDrillArm), "IExosuitArm.Update")]             // energy usage for drill arm
 static void ExosuitDrillArm_Update_Postfix(ExosuitDrillArm __instance)
 {
     if (__instance.drilling && !consumeArmEnergy(__instance, Main.config.armsEnergyUsage.drillArm))
     {
         __instance.gameObject.GetComponent <ToggleableDrillArmPatch.ArmToggle>()?.setUsingArm(false);
         (__instance as IExosuitArm).OnUseUp(out _);
     }
 }
示例#2
0
 public void UseDrill(ExosuitDrillArm drillArm, ExosuitArmAction armAction)
 {
     if (armAction == ExosuitArmAction.startUseTool)
     {
         drillArm.animator.SetBool("use_tool", true);
         drillArm.loop.Play();
     }
     else if (armAction == ExosuitArmAction.endUseTool)
     {
         drillArm.animator.SetBool("use_tool", false);
         drillArm.ReflectionCall("StopEffects");
     }
     else
     {
         Log.Error("Drill arm got an arm action he should not get: " + armAction);
     }
 }
示例#3
0
 public void UseDrill(ExosuitDrillArm drillArm, ExosuitArmAction armAction)
 {
     if (armAction == ExosuitArmAction.START_USE_TOOL)
     {
         drillArm.animator.SetBool("use_tool", true);
         drillArm.loop.Play();
     }
     else if (armAction == ExosuitArmAction.END_USE_TOOL)
     {
         drillArm.animator.SetBool("use_tool", false);
         drillArm.StopEffects();
     }
     else
     {
         Log.Error("Drill arm got an arm action he should not get: " + armAction);
     }
 }
 public static void Prefix(ExosuitDrillArm __instance)
 {
     NitroxServiceLocator.LocateService <ExosuitModuleEvent>().BroadcastArmAction(TechType.ExosuitDrillArmModule, __instance, ExosuitArmAction.endUseTool);
 }
示例#5
0
 static bool ExosuitDrillArm_OnUseUp_Prefix(ExosuitDrillArm __instance) =>
 !__instance.gameObject.ensureComponent <ArmToggle>().isUsingArm();
示例#6
0
 static void ExosuitDrillArm_OnUseDown_Prefix(ExosuitDrillArm __instance) =>
 __instance.gameObject.ensureComponent <ArmToggle>().toggleUsingArm();
 static bool Prefix(ExosuitDrillArm __instance) =>
 !__instance.gameObject.ensureComponent <PrawnSuitDrillArmToggle>().isUsingArm();
 static void Prefix(ExosuitDrillArm __instance) =>
 __instance.gameObject.ensureComponent <PrawnSuitDrillArmToggle>().toggleUsingArm();
        public static void Prefix(ExosuitDrillArm __instance)
        {
            try
            {
                var damage = Config.Instance.AddOtherDamage;
                if (damage <= 0)
                {
                    return;
                }

                var exosuit = ExosuitField.GetValue(__instance) as Exosuit;

                if (exosuit == null)
                {
                    QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Error, "Error: exosuit is null", null, true);
                    return;
                }

                if (exosuit.CanPilot() && exosuit.GetPilotingMode())
                {
                    Vector3    zero       = Vector3.zero;
                    GameObject gameObject = null;
                    Vector3    vector;
                    UWE.Utils.TraceFPSTargetPosition(exosuit.gameObject, 5f, ref gameObject, ref zero, out vector, true);

                    if (gameObject != null && gameObject && (bool)DrillingField.GetValue(__instance))
                    {
                        Drillable drillable = gameObject.FindAncestor <Drillable>();

                        if (!drillable)
                        {
                            LiveMixin liveMixin = gameObject.FindAncestor <LiveMixin>();
                            if (liveMixin)
                            {
                                liveMixin.IsAlive();
                                liveMixin.TakeDamage(damage, zero, DamageType.Drill, null);

                                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "Drill Extra Damaging: " + damage, null, true);

                                // Leave this for the real one
                                // this.drillTarget = gameObject;
                            }
                            return;
                        }

                        var maxHealth = Config.Instance.MaxDrillHealth;
                        var healths   = drillable.health;

                        QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, $"Hitting drillable with healths: " + healths.Length, null, true);

                        for (int i = 0; i < healths.Length; i++)
                        {
                            if (healths[i] > maxHealth)
                            {
                                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, $"Drillable health reduced from {healths[i]} to {maxHealth}", null, true);

                                healths[i] = maxHealth;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Error, "Error: " + ex.ToString(), ex, true);
            }
        }