Jump to content

Quick code tip


L B
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...