Quick fix to Cleaning_workshop + working currentMug in Production_workshop + cleaner Logs

This commit is contained in:
Antoine H 2020-12-10 14:58:15 +01:00
parent c8682b208a
commit 825de9e1b1
3 changed files with 33 additions and 25 deletions

View file

@ -20,36 +20,40 @@ public class Production_workshop : Workshop
{
// Debug.Log(userObject.tag);
//TODO : Gérer Grabable qui ne sont pas des mugs ?
if(userObject.tag=="Grabable")
if(userObject.tag=="Grabable" && currentMug is null)
{
Mug mug = userObject.GetComponent<Mug>();
if (mug!= null && mug.content is null && !mug.dirty && stock>0) //Mug clean & empty + remaining stock in workshop
{
Debug.Log(gameObject.name+" fill "+userObject.name+ " with "+product_name);
mug.fill(new Consumable(product_name,product_value,product_sprite));
stock--;
return false;
Debug.Log(userObject.name+ " stocked in "+gameObject.name);
currentMug=userObject;
return true; //Object taken
}
else
{
Debug.Log(userObject.name+" cannot be filled with "+product_name+ " -stock:"+stock);
return false;
}
}
else if(userObject.tag=="Player" && currentMug != null) //Give tavernkeeper currentMug
{
Tavernkeeper_controller player = userObject.GetComponent<Tavernkeeper_controller>();
return false;
}
else
{
return false;
Mug mug = currentMug.GetComponent<Mug>();
if(player!=null && mug !=null)
{
Debug.Log(gameObject.name+" give "+currentMug.name+" filled with "+product_name+" to "+userObject.name);
//Fill mug
mug.fill(new Consumable(product_name,product_value,product_sprite));
stock--;
//Give mug
player.grab(currentMug);
currentMug=null;
}
}
}
else
{
Debug.Log(gameObject.name+" doesn't handle : "+userObject);
return false;
}
return false; //Object not taken
}
}