Original Post
This is more of a question how other people would handle this issue. I am making a sim farm game. I have all logic for animating the player, objects, simple quests and things need need to do etc. I am now thinking of how I am going to interact with different objects. For example, my character when you click 'e' could do a number of things depending on what she is interacting with. If the item is a grass tile she will hoe it, if it's a dirt tile she could put down seeds, if it's a crop then she will water it, if it's a mailbox check the mail or something.
In more simple games I have just had a bit if statement in the update method. I don't want to do this because I want it to be more robust and expandable. I was thinking that when the action button is clicked an action object is sent to whatever objects are clicked and if they can handle them then they will themselves? Almost like a chain of command pattern.
like
WorldAction
HoeAction : BaseAction
WaterAction : BaseAction
CheckMailAction : BaseAction
so
phseudo
update()
if input = e then
selectedTool = selectedinventory
objects = getallselectedobjects()
for each object in objects
handletoolaction()
handlewhateverotheractions
I don't know if this all makes sense, perhaps I just need a bit of a hand organizing and focusing. I appreciate any input from you guys. If any of it is unclear or I am just not making sense I can try to elaborate more with code etc.
In more simple games I have just had a bit if statement in the update method. I don't want to do this because I want it to be more robust and expandable. I was thinking that when the action button is clicked an action object is sent to whatever objects are clicked and if they can handle them then they will themselves? Almost like a chain of command pattern.
like
WorldAction
HoeAction : BaseAction
WaterAction : BaseAction
CheckMailAction : BaseAction
so
phseudo
update()
if input = e then
selectedTool = selectedinventory
objects = getallselectedobjects()
for each object in objects
handletoolaction()
handlewhateverotheractions
I don't know if this all makes sense, perhaps I just need a bit of a hand organizing and focusing. I appreciate any input from you guys. If any of it is unclear or I am just not making sense I can try to elaborate more with code etc.