internal static void PostFix(ref ResourceTracker __instance) { bool isDataBox = __instance.overrideTechType == TechType.Databox || __instance.techType == TechType.Databox; if (!isDataBox) { return; // Not a data box, early exit } BlueprintHandTarget blueprint = __instance.GetComponentInParent <BlueprintHandTarget>(); if (blueprint == null) { return; // safety check, but shouldn't happen } if (!blueprint.used) { return; // blueprint still unused } __instance.OnBreakResource(); // call this to invoke the "Unregister" method }
public void OnDrill(Vector3 position, SeaTruckHelper helper, out GameObject hitObject) { float num = 0f; for (int i = 0; i < drillable.health.Length; i++) { num += drillable.health[i]; } this.helper = helper; Vector3 zero = Vector3.zero; int num2 = FindClosestMesh(position, out zero); hitObject = renderers[num2].gameObject; timeLastDrilled = Time.time; if (num > 0f) { float num3 = drillable.health[num2]; drillable.health[num2] = Mathf.Max(0f, drillable.health[num2] - 5f); num -= num3 - drillable.health[num2]; if (num3 > 0f && drillable.health[num2] <= 0f) { renderers[num2].gameObject.SetActive(false); SpawnFX(drillable.breakFX, zero); if (drillable.resources.Length != 0) { StartCoroutine(SpawnLootAsync(zero)); } } if (num <= 0f) { SpawnFX(drillable.breakAllFX, zero); onDrilled?.Invoke(drillable); if (drillable.deleteWhenDrilled) { ResourceTracker component = GetComponent <ResourceTracker>(); if (component) { component.OnBreakResource(); } float time = (!drillable.lootPinataOnSpawn) ? 0f : 6f; drillable.Invoke("DestroySelf", time); } } } BehaviourUpdateUtils.Register(this); }