L B Posted July 4, 2010 Share Posted July 4, 2010 Just thought of it, and since I'm not in the C# dev scene at the moment, thought maybe someone who has access to the source could make this available. Add the following in Entity.cs: public Entity this[int index] { get { return new Entity(Core.GetChild(this.Pointer, index)); } } public Entity this[string name] { get { return new Entity(Core.FindChild(this.Pointer, name)); } } Lets you do awesome things for parented entities. Let's say you load an apple parented to a tree in your scene. You can access it this way: myScene["MyTree"]["MyApple"].DoSomething(); //By name or myScene["MyTree"][0].DoSomething(); //By index Enjoy? Quote Link to comment Share on other sites More sharing options...
TylerH Posted July 4, 2010 Share Posted July 4, 2010 Done. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
L B Posted July 4, 2010 Author Share Posted July 4, 2010 Thanks. Quote Link to comment Share on other sites More sharing options...
L B Posted July 6, 2010 Author Share Posted July 6, 2010 You may want to remove the two "GetChilds" too. Quote Link to comment Share on other sites More sharing options...
ZioRed Posted July 6, 2010 Share Posted July 6, 2010 I'd say to leave them with the Obsolete attribute: [Obsolete("Use the new syntax: Entity[0]", false)] public Entity GetChild(int index) { return new Entity(Core.GetChild(this.Pointer, index)); } [Obsolete("Use the new syntax: Entity[\"YourEntityName\"]", false)] public Entity GetChild(string name) { return new Entity(Core.FindChild(this.Pointer, name)); } ..just not to break any project already working, for at least a couple of revisions. Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
TylerH Posted July 9, 2010 Share Posted July 9, 2010 I just realized this makes it more difficult to allow get/set of entity keys with the this[] accessor now... Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
ZioRed Posted July 9, 2010 Share Posted July 9, 2010 In my opinion the syntax Entity["Child1"] is ugly, I would prefer a more readable way: Entity.Children[index] and Entity.FindChildren(name). Well, eventually I find that the standard GetChild(index or name) is the most readable. Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
Rick Posted July 9, 2010 Share Posted July 9, 2010 I like something like Entity.Children["name"]. I think that's nice syntax. Quote Link to comment Share on other sites More sharing options...
ZioRed Posted July 9, 2010 Share Posted July 9, 2010 Yes I'd agree with Entity.Children[index] and Entity.Children["name"] instead of Entity[index] and Entity["name"], it's much more intuitive and readable. Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
L B Posted July 9, 2010 Author Share Posted July 9, 2010 Easy to do. I'll add it tonight when I sync some changes. I agree, Entity.Children[int/string] is better. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.