Raised This Month: $51 Target: $400
 12% 

Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]


Post New Thread Reply   
 
Thread Tools Display Modes
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 04-11-2016 , 20:41   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #51

I'm glad you've been making good progress on this.

One suggestion: when using the class builder, if I create a vector named 'origin' the getters and setters should be camel-cased (GetOrigin and SetOrigin) instead of Getorigin and Setorigin.
__________________
splewis is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-11-2016 , 22:43   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #52

I'm thinking of making a post to set naming conventions of members so we all make consistent code.

I'm thinking we should always name members with the camel case.

Eg. The example should be

SomeInt
SomeFloat
SomeBool
SomeString
SomeVector
SomeHandle
SomeObject

Feel free to share your thoughts...
__________________
Neuro Toxin is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 04-12-2016 , 01:07   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #53

Quote:
Originally Posted by Neuro Toxin View Post
I'm thinking of making a post to set naming conventions of members so we all make consistent code.

I'm thinking we should always name members with the camel case.

Eg. The example should be

SomeInt
SomeFloat
SomeBool
SomeString
SomeVector
SomeHandle
SomeObject

Feel free to share your thoughts...
lol...i definitely overwrote the class functions generated by the class generator to be CamelCase in my usage. So, that is my personal preference. I also think it makes it a slight bit easier to read.

The one downside I can see to it is for those that don't prefer it, they have to press shift a little more than otherwise. However, since most all of Sourcepawn syntax requires that anyways, it isn't that different. I'd guess it isn't too much of a bother to those that don't automatically write variable names that way. You could always just make it a check box in your class generator whether or not they want CamelCase...although that defeats your point of consistency you mentioned.

Don't people just name the variables themselves though?
__________________
ThatOneGuy is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-12-2016 , 02:39   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #54

People do name their own variables.

I like the idea of a camel case checkbox.

When doing OO code in .net as an example. The entire framework is camel case.

Considering this built to feel OO that should be the standard for dynamic object members.
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-12-2016 , 19:44   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #55

I'm considering allowing entities to be tied to a dynamic object to allow simple storage of addition entity members.

Eg. You want to store who last pressed button

Code:
OnButtonPressed(int entity, int userid)
{
    Dynamic button = Dynamic.LinkEntity(entity);
    button.SetInt("LastPressee", userid);
}
Link entity would perform a couple of actions.

1. Find previous entity linking and return the linked dynamic object
2. When 1 fails. Create a new dynamic object and link to to the entity

Dynamic would then also hook entity destroyed and dispose dynamic objects that have their linked entity removed.
__________________
Neuro Toxin is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 04-12-2016 , 21:30   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #56

Quote:
Originally Posted by Neuro Toxin View Post
I'm considering allowing entities to be tied to a dynamic object to allow simple storage of addition entity members.

Eg. You want to store who last pressed button

Code:
OnButtonPressed(int entity, int userid)
{
    Dynamic button = Dynamic.LinkEntity(entity);
    button.SetInt("LastPressee", userid);
}
Link entity would perform a couple of actions.

1. Find previous entity linking and return the linked dynamic object
2. When 1 fails. Create a new dynamic object and link to to the entity

Dynamic would then also hook entity destroyed and dispose dynamic objects that have their linked entity removed.
Careful on linking buttons or other entities that can change each round. You may need to clear them out on round start, unless you are using serials and converting back and forth, similar to the reasons for using userid over client index when storing stuff. In newer maps, you could link to Hammer IDs, but old maps didnt require them and retrieving a Hammer ID would return 0. Just a few thoughts.
__________________
ThatOneGuy is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-12-2016 , 22:01   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #57

Thanks for the advice.

I'm all over this one.

When a round ends OnEntityDestroyed is called.

So I would destroy the link and dispose the dynamic object on each related call.

This is very similar to how always weapon skins deals with map based weapons.
__________________
Neuro Toxin is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 04-13-2016 , 00:14   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #58

Quote:
Originally Posted by Neuro Toxin View Post
When a round ends OnEntityDestroyed is called.
So I would destroy the link and dispose the dynamic object on each related call.
So, then they could test with <object>.IsValid? Or how does that work from the coder's point to properly check?
__________________
ThatOneGuy is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-13-2016 , 01:04   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #59

Hmm.

Code:
Dynamic button = Dynamic.LinkEntity(entity);
My current implementation thought is a dynamic object is created if not already linked to the entity.

So you would have no way to identify from this method if the entity was already linked or not.

If you stored the dynamic reference from a previous entity link .IsValid could be used. However: if the dynamic object was re-initialised inbetween linking, disposal and .IsValid it would break logical tests.

I would add a member on linking like LinkedEntity so this could be checked.

I could also add Dynamic.IsEntityLinked(int Entity) which could return INVALID_DYNAMIC_OBJECT when not linked.
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-15-2016 , 04:10   Re: Dynamic Objects and Properties - v.0.0.13 - [2016.04.10]
Reply With Quote #60

I'm bored at work finishing the graveyard shift...

I added a bunch of new comments to the main code base of Dynamic to help others understand how the code works.

The code base isn't exactly simple, however: those who are good with arrays should have an idea of how Dynamic works.

Over the weekend I plan to complete the following changes:

- Reserve view_as<Dynamic>(1-MAXPLAYERS) for player based objects
- Add something like `Dynamic playersettings = Dynamic.GetClientSettings(int client);'
- Add support for Dynamic.LinkEntity(int entity);
__________________
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 05:18.


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