Raised This Month: $32 Target: $400
 8% 

[TUT] Better Methodmaps tut


Post New Thread Reply   
 
Thread Tools Display Modes
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-28-2016 , 03:41   Re: [TUT] Better Methodmaps tut
Reply With Quote #21

Are you breaking up with me?
__________________
Neuro Toxin is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 05-28-2016 , 19:38   Re: [TUT] Better Methodmaps tut
Reply With Quote #22

Quote:
Originally Posted by EasSidezz View Post
It's not you, it's me.
ok, what part are you not understanding? ° ͜ʖ °
__________________
nergal is offline
Chief149
Member
Join Date: Sep 2010
Old 06-09-2016 , 01:37   Re: [TUT] Better Methodmaps tut
Reply With Quote #23

The only part I don't fully understand is when doing stuff like inheriting an ArrayList in a methodmap.

This one guy did upload a "Dynamic" plugin which is designed to allow developers to make the closest thing to objects. Well I figured out it would likely be simpler to just make a methodmap and have it inherit ArrayList like such:

Code:
methodmap BDoor < ArrayList
{
    public BDoor(int doorid)
    {
        ArrayList bdoor = new ArrayList();
        bdoor.Push(doorid); //index 0 is doorid
        bdoor.Push(0); //index 1 holds the locked state
        return view_as<BDoor>(bdoor);
    }
    
    property int doorid
    {
        public get()
        {
            return this.Get(0); //where the door id is stored
        }
    }

    property bool locked
    {
        public get()
        {
            return this.Get(1); //where the lock state is stored
        }
    
        public set(bool isLocked)
        {
            this.Set(1, isLocked);
            if(isLocked)
                AcceptEntityInput(this.doorid, "Lock");
            else
                AcceptEntityInput(this.doorid, "Unlock");
        }
    }
}
I mean, sure it means that basically every custom methodmap is technically an arraylist where someone could just add in code to modify any of the elements, but that's kind of the case with the Dynamic class that one guy made on here. It's just really simple I guess.

Last edited by Chief149; 06-09-2016 at 01:43.
Chief149 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-09-2016 , 05:24   Re: [TUT] Better Methodmaps tut
Reply With Quote #24

Dynamic addresses a few concerns around simply inheriting ArrayList.

1. Blocksize: If you set a blocksize to accommodate for Strings your waisting memory for int/bool/float values.

2. It's nice to share methodmaps between plugins: however; if one plugin orders the indicies differently your corrupting data.

You'd be best to inherit to a trie memory wise. A membername lookup via trie is really fast (dynamic does this internally).

Once again Dynamic is designed to address a few issues when using a trie.

1. You might want to iterate members, this is impossible using a trie alone

2. Dynamic members are typed. Dynamic knows the type of each member and supports full type conversion for all the base pawn tags.

Everything dynamic does is for a good reason. It can do 100k member reads in less than .1 seconds. So you shouldnt be concerned about performance.

I have dynamic classes that have 100+ members and some members running on each frame / usercmd with no issues at all.
__________________
Neuro Toxin is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-09-2016 , 22:59   Re: [TUT] Better Methodmaps tut
Reply With Quote #25

Quote:
Originally Posted by Neuro Toxin View Post
1. You might want to iterate members, this is impossible using a trie alone
That hasn't been true since SM 1.7 came out.

You can iterate over a Trie by getting by getting a snapshot of its keys using CreateTrieSnapshot or StringMap's .Snapshot
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-10-2016 , 00:22   Re: [TUT] Better Methodmaps tut
Reply With Quote #26

Interesting.

Im going to have a play and do some benchmarking against dynamics current iteration support.

Love your work mr lord.
__________________
Neuro Toxin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode