public static float highBeamEnergyCost = 0.05f; // starts with energy cost for Turbo mode // ###################################################################### // Helper method // ###################################################################### public static void ConsumeHighBeamEnergy(Vehicle thisVehicle, float thisEnergyCost) { EnergyInterface thisEnergyInterface = thisVehicle.GetComponent <EnergyInterface>(); float amount = DayNightCycle.main.deltaTime * thisEnergyCost; thisEnergyInterface.ConsumeEnergy(amount); }
public static void ConsumeOxygenEnergy(Vehicle thisVehicle, float thisEnergyCost) { EnergyInterface thisEnergyInterface = thisVehicle.GetComponent <EnergyInterface>(); //float amount = __instance.oxygenPerSecond * energyCost; float amount = DayNightCycle.main.deltaTime * thisEnergyCost; thisEnergyInterface.ConsumeEnergy(amount); }
public bool OnShoot() { if (TargetObject != null) { Utils.PlayFMODAsset(shootSound, transform, 20f); energyInterface.GetValues(out float charge, out float capacity); float d = Mathf.Min(1f, charge / 4f); energyInterface.ConsumeEnergy(4f); fxControl.Play(0); fxControl.Play(); if (TargetObject.TryGetComponent(out CreatureFrozenMixin creatureFrozenMixin)) { creatureFrozenMixin.FreezeInsideIce(); creatureFrozenMixin.FreezeForTime(20); } else if (TargetObject.TryGetComponent(out FreezeCannonFrozenMixin freezeCannonFrozenMixin)) { freezeCannonFrozenMixin.FreezeInsideIce(); freezeCannonFrozenMixin.FreezeForTime(20); } else { FreezeCannonFrozenMixin component = TargetObject.AddComponent <FreezeCannonFrozenMixin>(); component.FreezeInsideIce(); component.FreezeForTime(20); } ReleaseTargetObject(); fxControl.Stop(); return(true); } else { TargetObject = TraceForTarget(); return(false); } }
public void OnShoot() { EnergyInterface energyInterface = exosuit.GetComponent <EnergyInterface>(); energyInterface.GetValues(out float charge, out float capacity); if (charge > 0f) { float d = Mathf.Clamp01(charge / 4f); Vector3 forward = MainCamera.camera.transform.forward; Vector3 position = MainCamera.camera.transform.position; int hits = UWE.Utils.SpherecastIntoSharedBuffer(position, 1f, forward, 35f, ~(1 << LayerMask.NameToLayer("Player")), QueryTriggerInteraction.UseGlobal); float targetMass = 0f; for (int i = 0; i < hits; i++) { RaycastHit raycastHit = UWE.Utils.sharedHitBuffer[i]; Vector3 point = raycastHit.point; float magnitude = (position - point).magnitude; float d2 = 1f - Mathf.Clamp01((magnitude - 1f) / 35f); GameObject targetObject = UWE.Utils.GetEntityRoot(raycastHit.collider.gameObject); if (targetObject == null) { targetObject = raycastHit.collider.gameObject; } Rigidbody component = targetObject.GetComponent <Rigidbody>(); if (component != null) { targetMass += component.mass; bool flag = true; targetObject.GetComponents(iammo); for (int j = 0; j < iammo.Count; j++) { if (!iammo[j].GetAllowedToShoot()) { flag = false; break; } } iammo.Clear(); if (flag && !(raycastHit.collider is MeshCollider) && (targetObject.GetComponent <Pickupable>() != null || targetObject.GetComponent <Living>() != null || (component.mass <= 2600f && UWE.Utils.GetAABBVolume(targetObject) <= 800f))) { float d3 = 1f + component.mass * 0.005f; Vector3 velocity = forward * d2 * d * 140f / d3; ShootObject(component, velocity); } } } energyInterface.ConsumeEnergy(4f); fxControl.Play(); callBubblesFX = true; Utils.PlayFMODAsset(shootSound, transform, 20f); } }