paintitem.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. class PaintItem
  2. {
  3. //! WIll open the 'item_target' by spawning a new entity and transferring item variables to the new one
  4. static void Paint(ItemBase item_tool, ItemBase item_target, string base_name, PlayerBase player, float specialty_weight = 0)
  5. {
  6. string spray_color = item_tool.ConfigGetString("color");
  7. string item_color = item_target.ConfigGetString("color");
  8. string new_class_name = base_name + "_" + spray_color;
  9. PaintItem.SwitchItems(item_target, new_class_name, player);
  10. }
  11. static bool CanPaintItem(ItemBase item_tool, ItemBase item_target)
  12. {
  13. string spray_color = item_tool.ConfigGetString("color");
  14. string item_color = item_target.ConfigGetString("color");
  15. if( spray_color != item_color )
  16. {
  17. return true;
  18. }
  19. else
  20. {
  21. return false;
  22. }
  23. }
  24. //! Will switch the 'item' for a new game entity, the new entity's classname will be formed by adding the 'suffix' to the classname of the old 'item'
  25. static void SwitchItems (EntityAI old_item, string new_item, PlayerBase player)
  26. {
  27. MiscGameplayFunctions.TurnItemIntoItemEx(player, new PaintItemLambda(old_item, new_item, player));
  28. }
  29. };
  30. class PaintItemLambda : TurnItemIntoItemLambda
  31. {
  32. void PaintItemLambda (EntityAI old_item, string new_item_type, PlayerBase player) { }
  33. };