Explorar o código

tools: fix collider and actor removal when reimporting sprite

Daniele Bartolini %!s(int64=5) %!d(string=hai) anos
pai
achega
ac935d0908
Modificáronse 2 ficheiros con 16 adicións e 1 borrados
  1. 1 0
      docs/changelog.rst
  2. 15 1
      tools/level_editor/project.vala

+ 1 - 0
docs/changelog.rst

@@ -28,6 +28,7 @@ Changelog
 * Fixed a number of dialog boxes that were not centered to the Level Editor's main window
 * Fixed an issue that allowed the user to enter blank names when creating new folders in the Project Browser
 * Fixed an issue that caused Project Browser to show inconsistent folder structured in some circumnstances
+* Fixed an issue that prevented some components from being removed when reimporting sprites
 * Fixed and issue that caused generation of spurious "set-actions" when editing properties in the Properties panel
 * Fixed modifier keys getting stuck in the wrong state in some circumnstances
 * Fixed undo/redo when setting properties of some unit components

+ 15 - 1
tools/level_editor/project.vala

@@ -569,7 +569,6 @@ public class Project
 
 			SJSON.save(sprite, Path.build_filename(_source_dir.get_path(), resource_path) + ".sprite");
 
-
 			// Generate .unit
 			Database db = new Database();
 
@@ -760,6 +759,21 @@ public class Project
 					}
 				}
 			}
+			else /* if (collision_enabled) */
+			{
+				// Destroy collider and actor if any
+				Guid component_id = Guid.new_guid();
+				if (unit.has_component("collider", ref component_id))
+				{
+					db.remove_from_set(GUID_ZERO, "components", component_id);
+					db.destroy(component_id);
+				}
+				if (unit.has_component("actor", ref component_id))
+				{
+					db.remove_from_set(GUID_ZERO, "components", component_id);
+					db.destroy(component_id);
+				}
+			}
 
 			db.save(unit_name);
 		}