Jump to content
Leadwerks Community

Recommended Posts

Posted

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? :)

Posted

Done. :)

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Posted

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.

?? FRANCESCO CROCETTI ??

http://skaredcreations.com

Posted

I just realized this makes it more difficult to allow get/set of entity keys with the this[] accessor now...

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Posted

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.

?? FRANCESCO CROCETTI ??

http://skaredcreations.com

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.   Paste as plain text instead

  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.

×
×
  • Create New...