Jump to content

Functions on timeline


Recommended Posts

M2 Download Center

Download Here ( Internal )

Hey guys,

 

It was really a long ago I did any activity on a forum so I decided to release a small but usefull class.

This can be used to place functions you want to run on every frame for a period of time with a progress on a "timeline". This can be used for example to roll the yang up or down when changing it (a normal way and not creating threads or wtf others doing) or anything else when you animating something in code.

So add this 2 files (download link at the end of this post) to your project and go to PythonApplication.cpp and find the Process function.

Add this line after like OnUIUpdate();:

Timeline::GetInstance()->DoEvents();

 

You can add functions like (it's an example for the mentioned yang stuff):

            auto currentGold = rkPlayer.GetStatus(POINT_GOLD);
            auto goldChange = PointChange.value - currentGold;
            Timeline::GetInstance()->AddFunction(0.5f, 
                [currentGold, goldChange](float p)
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + (goldChange * p));
                },
                [currentGold, goldChange]()
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + goldChange);
                }
            );

Download: https://distraught.hu/download/m2dev/Timeline.rar

 

Good luck!

 

 

-----------------------

Oh and if you can't compile it because the compiler does not find ModernSingleton then here it is:

template<typename T>
struct ModernSingleton
{
    static T* GetInstance()
    {
        static T _instance;
        return &_instance;
    }
};

(just add it to like singleton.h)

  • Love 3

AxgtRfG.png
C++ programmer at Gameloft

Link to post
On 7/12/2020 at 8:31 PM, Distraught said:

Hey guys,

It was really a long ago I did any activity on a forum so I decided to release a small but usefull class.

This can be used to place functions you want to run on every frame for a period of time with a progress on a "timeline". This can be used for example to roll the yang up or down when changing it (a normal way and not creating threads or wtf others doing) or anything else when you animating something in code.

So add this 2 files (download link at the end of this post) to your project and go to PythonApplication.cpp and find the Process function.

Add this line after like OnUIUpdate();:

Timeline::GetInstance()->DoEvents();

 

You can add functions like (it's an example for the mentioned yang stuff):

            auto currentGold = rkPlayer.GetStatus(POINT_GOLD);
            auto goldChange = PointChange.value - currentGold;
            Timeline::GetInstance()->AddFunction(0.5f, 
                [currentGold, goldChange](float p)
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + (goldChange * p));
                },
                [currentGold, goldChange]()
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + goldChange);
                }
            );

Download: https://distraught.hu/download/m2dev/Timeline.rar

 

Good luck!

 

 

-----------------------

Oh and if you can't compile it because the compiler does not find ModernSingleton then here it is:

 

template<typename T>
struct ModernSingleton
{
    static T* GetInstance()
    {
        static T _instance;
        return &_instance;
    }
};

 

(just add it to like singleton.h)

where did you put the POINT_GOLD function ?

Edited by Mafuyu
Link to post
On 7/14/2020 at 4:56 PM, Distraught said:

That was just an example, it's not a tutorial for that specific stuff.

But put it in CPythonNetworkStream::RecvPointChange in the if (PointChange.Type == POINT_GOLD) condition.

yeah thats what i was trying but it didnt worked for me, it didnt change anything ingame.

can you show the full edit function how it would work? i tried some changes but no effect on it, so i dont know if i made mistaks or if the system doesnt work

Edited by Mafuyu
Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



Shoutbox

Shoutbox

Chatroom Rules

 

Join our Discord

A request for help = Shoutbox Ban

Be respectful & Respect the rules

 

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.