Exemple #1
0
 public static void Postfix(FMODAsset asset)
 {
     if (fmodSystem.IsWhitelisted(asset.path, out bool isGlobal, out float radius))
     {
         fmodSystem.PlayAsset(asset.path, Player.main.transform.position.ToDto(), 1f, radius, isGlobal);
     }
 }
Exemple #2
0
 public static void Postfix(string eventPath, Vector3 position, float volume)
 {
     if (fmodSystem.IsWhitelisted(eventPath, out bool isGlobal, out float radius))
     {
         fmodSystem.PlayAsset(eventPath, position.ToDto(), volume, radius, isGlobal);
     }
 }
        public static void Postfix(FMOD_CustomEmitter __instance)
        {
            if (fmodSystem.IsWhitelisted(__instance.asset.path, out bool isGlobal, out float radius))
            {
                __instance.GetEventInstance().getDescription(out EventDescription description);
                description.is3D(out bool is3D);

                if (is3D)
                {
                    __instance.TryGetComponent(out NitroxEntity nitroxEntity);
                    if (!nitroxEntity)
                    {
                        nitroxEntity = __instance.GetComponentInParent <NitroxEntity>();
                    }
                    if (nitroxEntity)
                    {
                        fmodSystem.PlayCustomEmitter(nitroxEntity.Id, __instance.asset.path, true);
                    }
                }
                else
                {
                    __instance.GetEventInstance().getVolume(out float volume, out float _);
                    fmodSystem.PlayAsset(__instance.asset.path, __instance.transform.position.ToDto(), volume, radius, isGlobal);
                }
            }
        }
        private void SetUpSound()
        {
            FMODSystem fmodSystem = NitroxServiceLocator.LocateService <FMODSystem>();

            rpmSound = seamoth.engineSound.engineRpmSFX;
            revSound = seamoth.engineSound.engineRevUp;

            rpmSound.followParent = true;
            revSound.followParent = true;

            fmodSystem.IsWhitelisted(rpmSound.asset.path, out bool _, out radiusRpmSound);
            fmodSystem.IsWhitelisted(revSound.asset.path, out bool _, out radiusRevSound);

            rpmSound.GetEventInstance().setProperty(EVENT_PROPERTY.MINIMUM_DISTANCE, 1f);
            revSound.GetEventInstance().setProperty(EVENT_PROPERTY.MINIMUM_DISTANCE, 1f);
            rpmSound.GetEventInstance().setProperty(EVENT_PROPERTY.MAXIMUM_DISTANCE, radiusRpmSound);
            revSound.GetEventInstance().setProperty(EVENT_PROPERTY.MAXIMUM_DISTANCE, radiusRevSound);
        }
        public static void Prefix(FMOD_CustomEmitter __instance)
        {
            if (!fmodSystem.IsWhitelisted(__instance.asset.path, out bool _, out float radius))
            {
                return;
            }

            __instance.GetEventInstance().getDescription(out EventDescription description);
            description.is3D(out bool is3D);
            if (!is3D)
            {
                return;
            }

            if (!__instance.TryGetComponent(out NitroxEntity entity))
            {
                entity = __instance.GetComponentInParent <NitroxEntity>();
                if (!entity)
                {
                    Log.Warn($"[FMOD_CustomEmitter_Start_Patch] - No NitroxEntity for \"{__instance.asset.path}\" found!");
                    return;
                }
            }

            if (!entity.gameObject.TryGetComponent(out FMODEmitterController fmodController))
            {
                fmodController = entity.gameObject.AddComponent <FMODEmitterController>();
            }
            fmodController.AddEmitter(__instance.asset.path, __instance, radius);

            //FMOD_CustomLoopingEmitter has no Start() so we need to check it here
            if (__instance is FMOD_CustomLoopingEmitter looping)
            {
                if (looping.assetStart && fmodSystem.IsWhitelisted(looping.assetStart.path, out bool _, out float radiusStart))
                {
                    fmodController.AddEmitter(looping.assetStart.path, looping, radiusStart);
                }
                if (looping.assetStop && fmodSystem.IsWhitelisted(looping.assetStop.path, out bool _, out float radiusStop))
                {
                    fmodController.AddEmitter(looping.assetStop.path, looping, radiusStop);
                }
            }
        }
Exemple #6
0
 public static void Postfix(FMOD_StudioEventEmitter __instance, bool allowFadeout)
 {
     if (fmodSystem.IsWhitelisted(__instance.asset.path))
     {
         __instance.TryGetComponent(out NitroxEntity nitroxEntity);
         if (!nitroxEntity)
         {
             nitroxEntity = __instance.GetComponentInParent <NitroxEntity>();
         }
         if (nitroxEntity)
         {
             fmodSystem.PlayStudioEmitter(nitroxEntity.Id, __instance.asset.path, false, allowFadeout);
         }
     }
 }
 public static void Postfix(FMOD_CustomLoopingEmitter __instance)
 {
     if (__instance.assetStop && fmodSystem.IsWhitelisted(__instance.assetStop.path))
     {
         __instance.TryGetComponent(out NitroxEntity nitroxEntity);
         if (!nitroxEntity)
         {
             nitroxEntity = __instance.GetComponentInParent <NitroxEntity>();
         }
         if (nitroxEntity)
         {
             fmodSystem.PlayCustomLoopingEmitter(nitroxEntity.Id, __instance.assetStop.path);
         }
     }
 }
 public static void Postfix(FMOD_StudioEventEmitter __instance, float ____lastTimePlayed)
 {
     if (fmodSystem.IsWhitelisted(__instance.asset.path))
     {
         if (____lastTimePlayed == 0.0 || Time.time > ____lastTimePlayed + __instance.minInterval)
         {
             __instance.TryGetComponent(out NitroxEntity nitroxEntity);
             if (!nitroxEntity)
             {
                 nitroxEntity = __instance.GetComponentInParent <NitroxEntity>();
             }
             if (nitroxEntity)
             {
                 fmodSystem.PlayStudioEmitter(nitroxEntity.Id, __instance.asset.path, true, false);
             }
         }
     }
 }
        public static void Postfix(FMOD_StudioEventEmitter __instance)
        {
            if (fmodSystem.IsWhitelisted(__instance.asset.path, out bool _, out float radius))
            {
                if (!__instance.TryGetComponent(out NitroxEntity entity))
                {
                    entity = __instance.GetComponentInParent <NitroxEntity>();
                    if (!entity)
                    {
                        Log.Warn($"[FMOD_CustomEmitter_Start_Patch] - No NitroxEntity for \"{__instance.asset.path}\" found!");
                        return;
                    }
                }

                if (!entity.gameObject.TryGetComponent(out FMODEmitterController fmodController))
                {
                    fmodController = entity.gameObject.AddComponent <FMODEmitterController>();
                }
                fmodController.AddEmitter(__instance.asset.path, __instance, radius);
            }
        }
Exemple #10
0
        public static void Postfix(FMOD_CustomEmitter __instance)
        {
            if (fmodSystem.IsWhitelisted(__instance.asset.path))
            {
                __instance.GetEventInstance().getDescription(out EventDescription description);
                description.is3D(out bool is3D);

                if (is3D)
                {
                    __instance.TryGetComponent(out NitroxEntity nitroxEntity);
                    if (!nitroxEntity)
                    {
                        nitroxEntity = __instance.GetComponentInParent <NitroxEntity>();
                    }
                    if (nitroxEntity)
                    {
                        fmodSystem.PlayCustomEmitter(nitroxEntity.Id, __instance.asset.path, false);
                    }
                }
            }
        }