Jelajahi Sumber

tools: add state machine types definitions

Daniele Bartolini 4 bulan lalu
induk
melakukan
42226faf48
2 mengubah file dengan 112 tambahan dan 0 penghapusan
  1. 1 0
      docs/changelog.rst
  2. 111 0
      tools/resource/types.vala

+ 1 - 0
docs/changelog.rst

@@ -12,6 +12,7 @@ Changelog
 
 **Fixes**
 
+* Tools: fixed creation of animation state machine resources.
 * Runtime: Windows: fixed a number of misdetected keyboard keys.
 * Lua: fixed a memory leak when executing some script component callbacks.
 * Lua: the ``update()`` script component callback is now optional.

+ 111 - 0
tools/resource/types.vala

@@ -808,6 +808,117 @@ public static void create_object_types(Database database)
 		},
 	};
 	database.create_object_type(OBJECT_TYPE_UNIT, properties);
+
+	properties =
+	{
+		PropertyDefinition()
+		{
+			type = PropertyType.STRING,
+			name = "name",
+			editor = PropertyEditorType.RESOURCE,
+			resource_type = OBJECT_TYPE_MESH_ANIMATION,
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.STRING,
+			name = "weight",
+		}
+	};
+	StringId64 node_animation_type = database.create_object_type(OBJECT_TYPE_NODE_ANIMATION, properties);
+
+	properties =
+	{
+		PropertyDefinition()
+		{
+			type = PropertyType.STRING,
+			name = "event",
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.STRING,
+			name = "mode",
+			editor = PropertyEditorType.ENUM,
+			enum_values = { "immediate", "wait_until_end" },
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.GUID,
+			object_type = StringId64(OBJECT_TYPE_STATE_MACHINE_NODE),
+			name = "to",
+		},
+	};
+	StringId64 node_transition_type = database.create_object_type(OBJECT_TYPE_NODE_TRANSITION, properties);
+
+	properties =
+	{
+		PropertyDefinition()
+		{
+			type = PropertyType.STRING,
+			name = "name",
+			deffault = "New Node",
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.OBJECTS_SET,
+			name = "animations",
+			object_type = node_animation_type,
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.BOOL,
+			name = "loop",
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.STRING,
+			name = "speed",
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.OBJECTS_SET,
+			name = "transitions",
+			object_type = node_transition_type,
+		},
+	};
+	StringId64 state_machine_node_type = database.create_object_type(OBJECT_TYPE_STATE_MACHINE_NODE, properties);
+
+	properties =
+	{
+		PropertyDefinition()
+		{
+			type = PropertyType.STRING,
+			name = "name",
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.DOUBLE,
+			name = "value",
+		},
+	};
+	StringId64 state_machine_variable_type = database.create_object_type(OBJECT_TYPE_STATE_MACHINE_VARIABLE, properties);
+
+	properties =
+	{
+		PropertyDefinition()
+		{
+			type = PropertyType.GUID,
+			object_type = StringId64(OBJECT_TYPE_STATE_MACHINE_NODE),
+			name = "initial_state",
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.OBJECTS_SET,
+			name = "states",
+			object_type = state_machine_node_type,
+		},
+		PropertyDefinition()
+		{
+			type = PropertyType.OBJECTS_SET,
+			name = "variables",
+			object_type = state_machine_variable_type,
+		},
+	};
+	database.create_object_type(OBJECT_TYPE_STATE_MACHINE, properties);
 }
 
 } /* namespace Crown */