Solved hurtevent.entity.destroy > metal window bar (solved)

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
destroying it like that isn't correct though it works.

Try
C#:
NetCull.Destroy((entity.Object as DeployableObject).gameObject);
or Entity.Destory() on a wooden foundation with a furnace on it. you'll see how easy peasy the furnace doesn't get destroyed.

you will have floating items

C#:
NetCull.Destroy((entity.Object as DeployableObject).gameObject);
is only a cheap trick to destroy the metal window bar but i do not advise it to use.
That calls destroy for all clients and should work fine. I recommend you taking a look at the code with dotPeek.

What do you think that Entity.Destoy() uses ?

Entity.Destroy() checks if the object has a death effect. If so, it sends an RPC to all clients calling this effect and then calls Netcull.Destroy(). Finally, if the object should have a corpse, it instantiates it.
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
That being said, if it fails somewhere it calls Netcull.Destroy() directly, as it is in a try-catch.
 

hunternope3

Plugin Developer
Plugin Developer
Mar 22, 2015
36
46
8
35
have you tried using destroy on a wooden foundation with a furnace or any oher item on it?
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
have you tried using destroy on a wooden foundation with a furnace or any oher item on it?
No, but this post is about metal window bars.

Note that DeployableObject and StructureComponent handle destroy in a different way, and as you said before, Metal Window Bars are DeployableObject.
 

hunternope3

Plugin Developer
Plugin Developer
Mar 22, 2015
36
46
8
35
No, but this post is about metal window bars.
ofcouse, it is. but only saying that NetCull.Destroy((entity.Object as DeployableObject).gameObject); works
doesn't really explain why Onkilled() in Entity.Destroy / <DeployableObject> doesn't work properly on the metal window bar
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,065
4,486
113
At your house.
github.com
C#:
if (this.IsDeployableObject())
    NetCull.Destroy(Entity.GetObject<DeployableObject>().networkViewID);
if (this.IsStructureMaster())
    NetCull.Destroy(Entity.GetObject<StructureMaster>().networkViewID);
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
ofcouse, it is. but only saying that NetCull.Destroy((entity.Object as DeployableObject).gameObject); works
doesn't really explain why Onkilled() in Entity.Destroy / <DeployableObject> doesn't work properly on the metal window bar
I didn't ment to explain why it doesn't, I just said a way to do it.

And it will probably not work because handleDeathHere property is false.

You can test that accesing (entity.Object as DeployableObject).handleDeathHere.
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
I didn't ment to explain why it doesn't, I just said a way to do it.

And it will probably not work because handleDeathHere property is false.

You can test that accesing (entity.Object as DeployableObject).handleDeathHere.
And now that I think that again, you can also :

C#:
(entity.Object as DeployableObject).handleDeathhere = true;

entity.Destroy();
 

hunternope3

Plugin Developer
Plugin Developer
Mar 22, 2015
36
46
8
35
I didn't ment to explain why it doesn't, I just said a way to do it.

And it will probably not work because handleDeathHere property is false.

You can test that accesing (entity.Object as DeployableObject).handleDeathHere.
You basicallybasically summarize what i just said in a post explaining why onkilled didn't work for the metla window bar using OnKilled from Entity.Destroy.
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
68
28
45
Poland
Remember guys that probably we all using English as a second language and it's normal that we have problems with understanding and explaining.

Sometimes we all talking about same thing, sometimes we all talking about different things.

Just to clear :)
 
  • Agree
Reactions: Snake and Jakkee