Skip to content

Hey #130

@quakec

Description

@quakec

Wondering if you can help, I am new to modding (up to today) but not coding. Do you have any examples of playing custom audio files that come alongside a plugin/mod? What I'm trying to do is play a beeper on loop when a ship is reversing :P.

I've only managed to hook/patch into the Ship class in Stop(), Forward() and Backward() and test the state of [private Speed m_speed] then log that out to the debug window. Ideally it would be better to determine which way the ship is moving which I imagine requires hooking into regular frame updates... my knowledge is limited after only looking at examples for a few hours.

`

    [HarmonyPatch(typeof(Ship), nameof(Ship.Stop))]
    class Stop_Patch
    {
        static void Postfix(ref Speed ___m_speed)
        {
            Debug.Log($"Stop Beeper");
        }
    }

    [HarmonyPatch(typeof(Ship), nameof(Ship.Forward))]
    class Forward_Patch
    {
        static void Postfix(ref Speed ___m_speed)
        {
            Debug.Log($"Stop Beeper");
        }
    }

    [HarmonyPatch(typeof(Ship), nameof(Ship.Backward))]
    class Backward_Patch
    {
        static void Postfix(ref Speed ___m_speed)
        {
            if (___m_speed == Speed.Back)
            {
                Debug.Log($"Start Beeper");
            }
        }
    }

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions