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);
        }
Beispiel #2
0
        public override void Process(NitroxModel.Packets.ToggleLights packet)
        {
            GameObject   gameObject   = NitroxEntity.RequireObjectFrom(packet.Id);
            ToggleLights toggleLights = gameObject.GetComponent <ToggleLights>();

            if (!toggleLights)
            {
                toggleLights = gameObject.RequireComponentInChildren <ToggleLights>();
            }

            if (packet.IsOn != toggleLights.GetLightsActive())
            {
                using (packetSender.Suppress <NitroxModel.Packets.ToggleLights>())
                    using (FMODSystem.SuppressSounds())
                    {
                        toggleLights.SetLightsActive(packet.IsOn);
                    }
            }
        }
Beispiel #3
0
        static private void CreateDeviceList()
        {
            if (m_deviceList.Count > 0)
            {
                return;
            }

            // Create a bare system object to get the driver count
            FMODSystem system = null;
            RESULT     result = Factory.System_Create(ref system);

            if (result == RESULT.ERR_FILE_BAD)
            {
                MessageBox.Show("Error creating audio device: 32/64 bit incompatibility.");
            }

            int driverCount = 0;

            system.getNumDrivers(ref driverCount);

            if (driverCount > 0)
            {
                // There are audio devices available

                // Create device list
                system.getNumDrivers(ref driverCount);
                StringBuilder sb = new StringBuilder(256);
                int           i;
                for (i = 0; i < driverCount; i++)
                {
                    GUID GUID = new GUID();
                    system.getDriverInfo(i, sb, sb.Capacity, ref GUID);
                    if (!sb.ToString().Contains("DAX"))
                    {
                        m_deviceList.Add(sb.ToString());
                    }
                }
            }

            system.release();
        }
Beispiel #4
0
    public override void Process(MedicalCabinetClicked packet)
    {
        GameObject     gameObject = NitroxEntity.RequireObjectFrom(packet.Id);
        MedicalCabinet cabinet    = gameObject.RequireComponent <MedicalCabinet>();

        bool medkitPickedUp   = !packet.HasMedKit && cabinet.hasMedKit;
        bool doorChangedState = cabinet.doorOpen != packet.DoorOpen;

        cabinet.hasMedKit       = packet.HasMedKit;
        cabinet.timeSpawnMedKit = packet.NextSpawnTime;

        using (packetSender.Suppress <PlayFMODCustomEmitter>())
            using (FMODSystem.SuppressSounds())
            {
                if (doorChangedState)
                {
                    cabinet.Invoke(nameof(MedicalCabinet.ToggleDoorState), 0f);
                }
                else if (medkitPickedUp)
                {
                    cabinet.Invoke(nameof(MedicalCabinet.ToggleDoorState), 2f);
                }
            }
    }
Beispiel #5
0
 public override void Patch(Harmony harmony)
 {
     fmodSystem = NitroxServiceLocator.LocateService <FMODSystem>();
     PatchMultiple(harmony, targetMethod, true, true, false, false);
 }
Beispiel #6
0
 public override void Patch(Harmony harmony)
 {
     fmodSystem = NitroxServiceLocator.LocateService <FMODSystem>();
     PatchMultiple(harmony, TARGET_METHOD, prefix: true, postfix: true);
 }
 public override void Patch(Harmony harmony)
 {
     fmodSystem = NitroxServiceLocator.LocateService <FMODSystem>();
     PatchPrefix(harmony, TARGET_METHOD);
 }
Beispiel #8
0
        static public fmod GetInstance(int deviceIndex = -1)
        {
            if (m_systems.Count == 0)
            {
                FMODSystem system = null;

                CreateDeviceList();

                if (m_deviceList.Count > 0)
                {
                    // Create system instances, one for each device
                    int i;
                    for (i = 0; i < m_deviceList.Count; i++)
                    {
                        if (Factory.System_Create(ref system) == RESULT.ERR_OUTPUT_INIT)
                        {
                            // Remove all devices listed at this index and beyond
                            m_deviceList.RemoveRange(i, m_deviceList.Count - i);
                            break;
                        }
                        else
                        {
                            m_systems.Add(system);
                        }
                    }

                    // Initialize all system instances
                    string paramFile        = Path.Combine(Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), "sound.params");
                    int    dspBufferCount   = 0;
                    uint   streamBufferSize = 32768;

                    // For some parameter tweaking, just in case
                    if (File.Exists(paramFile))
                    {
                        StreamReader reader = new StreamReader(paramFile);
                        string       line;
                        string[]     parts;
                        while ((line = reader.ReadLine()) != null)
                        {
                            parts = line.Split('=');
                            switch (parts[0].Trim().ToLower())
                            {
                            case "dspbuffercount":
                                try {
                                    dspBufferCount = Convert.ToInt32(parts[1].Trim());
                                } catch { }
                                break;

                            case "streambuffersize":
                                try {
                                    streamBufferSize = Convert.ToUInt32(parts[1].Trim());
                                } catch { }
                                break;
                            }
                        }
                        reader.Close();
                        reader.Dispose();
                    }

                    for (i = 0; i < m_systems.Count; i++)
                    {
                        system = m_systems[i];

                        system.setDriver(i);

                        if (dspBufferCount > 0)
                        {
                            // Must be called before init
                            system.setDSPBufferSize(1024, dspBufferCount);
                        }

                        system.init(32, INITFLAGS.NORMAL, IntPtr.Zero);
                        system.setStreamBufferSize(streamBufferSize, TIMEUNIT.RAWBYTES);
                    }
                }
            }

            // Return an instance with the appropriate system instance assignment
            if (deviceIndex == -1)
            {
                deviceIndex = 0;                   // 0 is always primary device?
            }
            if (deviceIndex < m_systems.Count)
            {
                m_refCount++;
                return(new fmod(m_systems[deviceIndex], deviceIndex));
            }
            else
            {
                return(new fmod(null, -1));
            }
        }
Beispiel #9
0
 private fmod(FMODSystem system, int deviceIndex)
 {
     m_system      = system;
     m_deviceIndex = deviceIndex;
     m_channels    = new List <SoundChannel>();
 }
Beispiel #10
0
 public SoundDebugger(FMODSystem fmodSystem) : base(700, null, KeyCode.S, true, false, true, GUISkinCreationOptions.DERIVEDCOPY)
 {
     assetList = fmodSystem.SoundDataList;
     ActiveTab = AddTab("Sounds", RenderTabAllSounds);
 }
Beispiel #11
0
        public override void SaveTemporaryMap()
        {
            FileStream   FS = new FileStream("TempSave.sav", FileMode.Create, FileAccess.Write);
            BinaryWriter BW = new BinaryWriter(FS);

            BW.Write(BattleMapPath);
            BW.Write(typeof(DeathmatchMap).AssemblyQualifiedName);

            BW.Write(DicMapVariables.Count);
            foreach (KeyValuePair <string, double> Variables in DicMapVariables)
            {
                BW.Write(Variables.Key);
                BW.Write(Variables.Value);
            }

            BW.Write(CursorPosition.X);
            BW.Write(CursorPosition.Y);

            BW.Write(CameraPosition.X);
            BW.Write(CameraPosition.Y);

            BW.Write(ActivePlayerIndex);
            BW.Write(GameMode);
            BW.Write(GameTurn);
            BW.Write(VictoryCondition);
            BW.Write(LossCondition);
            BW.Write(SkillPoint);

            BW.Write(sndBattleThemeName);

            BW.Write(FMODSystem.sndActiveBGMName);
            BW.Write(FMODSystem.GetPosition(FMODSystem.sndActiveBGM));

            BW.Write(ListPlayer.Count);
            foreach (Player ActivePlayer in ListPlayer)
            {
                BW.Write(ActivePlayer.Name);
                BW.Write(ActivePlayer.PlayerType);
                BW.Write(ActivePlayer.IsHuman);
                BW.Write(ActivePlayer.Team);
                BW.Write(ActivePlayer.Color.R);
                BW.Write(ActivePlayer.Color.G);
                BW.Write(ActivePlayer.Color.B);

                BW.Write(ActivePlayer.ListSquad.Count);
                foreach (Squad ActiveSquad in ActivePlayer.ListSquad)
                {
                    BW.Write(ActiveSquad.ID);
                    BW.Write(ActiveSquad.CanMove);
                    BW.Write(ActiveSquad.ActionsRemaining);
                    BW.Write(ActiveSquad.X);
                    BW.Write(ActiveSquad.Y);
                    BW.Write(ActiveSquad.Z);
                    BW.Write(ActiveSquad.SquadName);

                    int UnitInSquad = ActiveSquad.UnitsInSquad;

                    BW.Write(UnitInSquad);
                    BW.Write(ActiveSquad.CurrentLeaderIndex);
                    BW.Write(ActiveSquad.CurrentWingmanAIndex);
                    BW.Write(ActiveSquad.CurrentWingmanBIndex);

                    for (int U = 0; U < UnitInSquad; ++U)
                    {
                        ActiveSquad.At(U).QuickSave(BW);
                    }

                    //List of Attacked Teams.
                    BW.Write(ActiveSquad.ListAttackedTeam.Count);
                    for (int U = 0; U < ActiveSquad.ListAttackedTeam.Count; ++U)
                    {
                        BW.Write(ActiveSquad.ListAttackedTeam[U]);
                    }
                }
            }

            BW.Write(ListMapScript.Count);
            for (int S = 0; S < ListMapScript.Count; S++)
            {
                ListMapScript[S].Save(BW);
            }

            FS.Close();
            BW.Close();
        }
Beispiel #12
0
 public override void Patch(Harmony harmony)
 {
     fmodSystem = NitroxServiceLocator.LocateService <FMODSystem>();
     PatchPostfix(harmony, targetMethod);
 }
Beispiel #13
0
        //------------------------------------------------------------------------------
        // Public Functions:
        //------------------------------------------------------------------------------

        public AudioManager()
        {
            ErrorCheck(FMODSystem.create(out fmodStudioSystem));
            ErrorCheck(fmodStudioSystem.initialize(16, INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero));
        }
Beispiel #14
0
        public override void SaveTemporaryMap()
        {
            FileStream   FS = new FileStream("User Data/Saves/TempSave.sav", FileMode.Create, FileAccess.Write);
            BinaryWriter BW = new BinaryWriter(FS);

            BW.Write(BattleMapPath);
            BW.Write(typeof(DeathmatchMap).AssemblyQualifiedName);

            DataScreen.SaveProgression(BW, PlayerRoster);

            BW.Write(DicMapVariables.Count);
            foreach (KeyValuePair <string, double> Variables in DicMapVariables)
            {
                BW.Write(Variables.Key);
                BW.Write(Variables.Value);
            }

            BW.Write(CursorPosition.X);
            BW.Write(CursorPosition.Y);

            BW.Write(CameraPosition.X);
            BW.Write(CameraPosition.Y);

            BW.Write(ActivePlayerIndex);
            BW.Write(GameTurn);
            BW.Write(VictoryCondition);
            BW.Write(LossCondition);
            BW.Write(SkillPoint);

            BW.Write(ListBackground.Count);
            for (int B = 0; B < ListBackground.Count; ++B)
            {
                BW.Write(ListBackground[B].AnimationFullPath);
            }
            BW.Write(ListForeground.Count);
            for (int F = 0; F < ListForeground.Count; ++F)
            {
                BW.Write(ListForeground[F].AnimationFullPath);
            }

            BW.Write(sndBattleThemeName);

            BW.Write(FMODSystem.sndActiveBGMName);
            BW.Write(FMODSystem.GetPosition(FMODSystem.sndActiveBGM));

            BW.Write(ListPlayer.Count);
            foreach (Player ActivePlayer in ListPlayer)
            {
                BW.Write(ActivePlayer.Name);
                BW.Write(ActivePlayer.OnlinePlayerType);
                BW.Write(ActivePlayer.IsPlayerControlled);
                BW.Write(ActivePlayer.Team);
                BW.Write(ActivePlayer.Color.R);
                BW.Write(ActivePlayer.Color.G);
                BW.Write(ActivePlayer.Color.B);

                BW.Write(ActivePlayer.ListSquad.Count);
                foreach (Squad ActiveSquad in ActivePlayer.ListSquad)
                {
                    BW.Write(ActiveSquad.ID);
                    BW.Write(ActiveSquad.CanMove);
                    BW.Write(ActiveSquad.ActionsRemaining);
                    BW.Write(ActiveSquad.X);
                    BW.Write(ActiveSquad.Y);
                    BW.Write(ActiveSquad.Z);
                    BW.Write(ActiveSquad.SquadName);
                    BW.Write(ActiveSquad.CurrentMovement);
                    BW.Write(ActiveSquad.IsFlying);
                    BW.Write(ActiveSquad.IsUnderTerrain);
                    BW.Write(ActiveSquad.IsPlayerControlled);
                    if (ActiveSquad.SquadAI == null || ActiveSquad.SquadAI.Path == null)
                    {
                        BW.Write(string.Empty);
                    }
                    else
                    {
                        BW.Write(ActiveSquad.SquadAI.Path);
                    }

                    int UnitsInSquad = ActiveSquad.UnitsInSquad;

                    BW.Write(UnitsInSquad);
                    BW.Write(ActiveSquad.CurrentLeaderIndex);
                    BW.Write(ActiveSquad.CurrentWingmanAIndex);
                    BW.Write(ActiveSquad.CurrentWingmanBIndex);

                    for (int U = 0; U < UnitsInSquad; ++U)
                    {
                        ActiveSquad.At(U).QuickSave(BW);
                    }

                    //List of Attacked Teams.
                    BW.Write(ActiveSquad.ListAttackedTeam.Count);
                    for (int U = 0; U < ActiveSquad.ListAttackedTeam.Count; ++U)
                    {
                        BW.Write(ActiveSquad.ListAttackedTeam[U]);
                    }
                }
            }

            for (int P = 0; P < ListPlayer.Count; P++)
            {
                for (int S = 0; S < ListPlayer[P].ListSquad.Count; S++)
                {
                    if (!ListPlayer[P].ListSquad[S].IsDead)
                    {
                        for (int U = 0; U < ListPlayer[P].ListSquad[S].UnitsInSquad; ++U)
                        {
                            for (int C = 0; C < ListPlayer[P].ListSquad[S].At(U).ArrayCharacterActive.Length; C++)
                            {
                                Character ActiveCharacter = ListPlayer[P].ListSquad[S].At(U).ArrayCharacterActive[C];
                                ActiveCharacter.Effects.QuickSave(BW);
                            }
                        }
                    }
                }
            }

            BW.Write(ListMapScript.Count);
            for (int S = 0; S < ListMapScript.Count; S++)
            {
                ListMapScript[S].Save(BW);
            }

            FS.Close();
            BW.Close();
        }