I'm going to be a bit detailed and specific with my request, so I can easily relate to everyone and my request for help.
Allow any objects in my game to "Burn", "Catch fire" and "get destroyed from the fire", not just one object.
What I have done:
I have sucessfully programmed one object to be able to catch Fire, namely an "AppleTree", and it works great! It burns, and after a while, it will change it's animation to show that it is burnt after it's "Health" value reaches 0. I have also successfully created the concept of spreading fires to other AppleTree objects if the burning fire in question is touching another AppleTree.
What I was working on before I got lost:
Since the AppleTree object is the only thing that can burn in my game at the moment, I wanted to expand the possibilities here, so anything can catch on fire. The trouble is; every object has different variables and the event system recognises each object differently for different things. For example, I have not given the object "Shop" the same variables or events as the AppleTree to catch on fire, etc. So I thought what if I changed the AppleTree into "FireCloak". So it would be an invisible object, and the idea of this would be to use the FireCloak object to cover all objects that can catch fire in the game, so then, using the existing events, it can spread or catch Fire to any object. The reason why I changed AppleTree into FireCloak is because the object for AppleTree has all the programming I need for it to catch on fire (of course).
What I am stuck with:
The only thing I need to make sure of here (and correct me here if I'm wrong) is to recognise the visible object that is burning to change it's animation to the appropriate "burnt" animation. Now, I could do something like this, which, apart from the sub-event, I had, except I created the sub-event to consider different types of objects.
Is FireCloak overlapping Fire
Is Health = 0
Is FireCloak overlapping AppleTree
Event Actions (for sub event):
AppleTree Set Animation to "Burnt"
However, in my game, objects, and particularly objects like Trees can overlap each other for a graphical effect. If I used the same code here to change the animation of an AppleTree to burnt when it is overlapping another AppleTree that is not ready to change it's animation, it will pre-maturely happen, and it will likely cause other bugs I do not want. So, I am trying to figure out a way I can match each FireCloak with their respective objects.
Possible solutions I am looking at:
1) I thought about Containers, but this only works effectively if you're talking about the same object and it's instances, I have multiple objects with different variables, I would have to spend a lot of energy and time in changing a lot and this could also cause bugs with other objects, so I am not keen on this.
2) I was seriously thinking I could create a variable under the FireCloak object which will be "Object_UID" and I would then somehow assign the UID of the appropriate object to the FireCloak, then when it comes to changing animations to Burnt, I can just compare the object's UID with the FireCloak's Object_UID variable, and if it matches to change the animation. The only thing I am stuck with here is how do I do this without having to copy FireCloak and then specifically change the object_UID variable to each appropriate object. I suppose this does not matter so much, Flammable objects on a level will not be changing shape, size, or position.
Please tell me what you think, is my solution 2 the best and most effective solution?
Thanks so much in advance!