Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Transformation: Scene Director #3

Open
Albeoris opened this issue May 1, 2024 · 0 comments
Open

Code Transformation: Scene Director #3

Albeoris opened this issue May 1, 2024 · 0 comments

Comments

@Albeoris
Copy link
Owner

Albeoris commented May 1, 2024

One of the main problems that prevents us from writing new scenes is that scene synchronization is entrusted to the Scene Director, and the logic for playing sounds, animations and dialogues is encapsulated in objects on the scene. Without a convenient tool, it is difficult to fix even an existing scene, not to mention adding new one or new participants to it, since this will require manually changing all subsequent events in all scripts of all objects associated with the current phase.

    // Scene Director
    public IEnumerable<IAwaitable> OnLoop()
    {
        switch(@evt.Byte_24)
        {
            case 12:{
                if((@evt.Byte_28[7] == true))
                {
                    @evt.Byte_24 = 13;
                    @evt.Byte_28[7] = false;
                }
                break;
            }
            case 13:{
                if((@evt.Byte_28[7] == true))
                {
                    @evt.Byte_24 = 14;
                    @evt.Byte_28[7] = false;
                }
                break;
            }

            // Cinna
            case 12:{
                CFLAG(_flags: 7)
                @act.SetPosition(positionX: 117, positionY: -555); // POS
                @act.SetAngle(angle: 128); // DIRE
                @act.SetAnimation(AnimationKind.Idle, "ANH_SUB_F0_CNA_TIRED"); // AIDLE
                NECKFLAG(_flags: 0)
                yield return @sys.Wait(frameDuration: 3); // WAIT

                @evt.Byte_26--;
                while((@evt.Byte_26 > 0))
                {
                    @evt.Byte_28[6] = true;
                    yield return @sys.Wait(frameDuration: 1); // WAIT

                }
                while((@evt.Byte_28[6] == true))
                {
                    yield return @sys.Wait(frameDuration: 1); // WAIT

                }
                @evt.Byte_28[7] = true;
                break;
            }

            // Marcus
            case 13:{
                yield return @sys.Wait(frameDuration: 11); // WAIT

                // {W41H1}Whew...{Time 10}
                yield return @mes.ShowAndWait(windowId: 5, ui: 128, text: 46); // MES

                @evt.Byte_26--;
                while((@evt.Byte_26 > 0))
                {
                    @evt.Byte_28[6] = true;
                    yield return @sys.Wait(frameDuration: 1); // WAIT

                }
                while((@evt.Byte_28[6] == true))
                {
                    yield return @sys.Wait(frameDuration: 1); // WAIT

                }
                @evt.Byte_28[7] = true;
                break;

It would be great to have a single synchronization point for describing cutscenes:

    // Scene Director
    public IEnumerable<IAwaitable> AfterBossBattle()
    {
        var cinnaTiered = @cinna + () =>
        {
                CFLAG(_flags: 7)
                @act.SetPosition(positionX: 117, positionY: -555); // POS
                @act.SetAngle(angle: 128); // DIRE
                @act.SetAnimation(AnimationKind.Idle, "ANH_SUB_F0_CNA_TIRED"); // AIDLE
                NECKFLAG(_flags: 0)
                yield return @sys.Wait(frameDuration: 3); // WAIT
        };
        
        var marucsSpeak = @marcus + () =>
        {
                yield return @sys.Wait(frameDuration: 11); // WAIT

                // {W41H1}Whew...{Time 10}
                yield return @mes.ShowAndWait(windowId: 5, ui: 128, text: 46); // MES
        };
        
        foreach (var state in Play([cinnaTiered, marucsSpeak]))
            yield return state;
    }

Yes, it still looks terrible, and such scenes will be difficult to read, but it’s better than having to piece together a cutscene in multiple independent scripts. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant