Просмотр исходного кода

Add World.update/update_animations() and remove Device.update_world()

Daniele Bartolini 11 лет назад
Родитель
Сommit
041a6cf05b
6 измененных файлов с 29 добавлено и 23 удалено
  1. 0 6
      engine/device.cpp
  2. 0 3
      engine/device.h
  3. 0 13
      engine/lua/lua_device.cpp
  4. 19 0
      engine/lua/lua_world.cpp
  5. 7 1
      engine/world/world.cpp
  6. 3 0
      engine/world/world.h

+ 0 - 6
engine/device.cpp

@@ -216,12 +216,6 @@ void Device::update()
 	_frame_count++;
 }
 
-//-----------------------------------------------------------------------------
-void Device::update_world(World* world, float dt)
-{
-	world->update(dt);
-}
-
 //-----------------------------------------------------------------------------
 void Device::render_world(World* world, Camera* camera)
 {

+ 0 - 3
engine/device.h

@@ -117,9 +117,6 @@ struct Device
 	/// Updates all the subsystems
 	void update();
 
-	/// Updates the given @a world and renders it from the given @a camera.
-	void update_world(World* world, float dt);
-
 	/// Renders the given @a world from the point of view of the given @æ camera.
 	void render_world(World* world, Camera* camera);
 

+ 0 - 13
engine/lua/lua_device.cpp

@@ -107,18 +107,6 @@ static int device_destroy_world(lua_State* L)
 	return 0;
 }
 
-//-----------------------------------------------------------------------------
-static int device_update_world(lua_State* L)
-{
-	LuaStack stack(L);
-
-	World* world = stack.get_world(1);
-	const float dt = stack.get_float(2);
-
-	device()->update_world(world, dt);
-	return 0;
-}
-
 //-----------------------------------------------------------------------------
 static int device_render_world(lua_State* L)
 {
@@ -164,7 +152,6 @@ void load_device(LuaEnvironment& env)
 	env.load_module_function("Device", "resolution",               device_resolution);
 	env.load_module_function("Device", "create_world",             device_create_world);
 	env.load_module_function("Device", "destroy_world",            device_destroy_world);
-	env.load_module_function("Device", "update_world",             device_update_world);
 	env.load_module_function("Device", "render_world",             device_render_world);
 	env.load_module_function("Device", "create_resource_package",  device_create_resource_package);
 	env.load_module_function("Device", "destroy_resource_package", device_destroy_resource_package);

+ 19 - 0
engine/lua/lua_world.cpp

@@ -97,6 +97,22 @@ static int world_units(lua_State* L)
 	return 1;
 }
 
+//-----------------------------------------------------------------------------
+static int world_update_animations(lua_State* L)
+{
+	LuaStack stack(L);
+	stack.get_world(1)->update_animations(stack.get_float(2));
+	return 0;
+}
+
+//-----------------------------------------------------------------------------
+static int world_update(lua_State* L)
+{
+	LuaStack stack(L);
+	stack.get_world(1)->update(stack.get_float(2));
+	return 0;
+}
+
 //-----------------------------------------------------------------------------
 static int world_play_sound(lua_State* L)
 {
@@ -290,6 +306,9 @@ void load_world(LuaEnvironment& env)
 	env.load_module_function("World", "num_units",          world_num_units);
 	env.load_module_function("World", "units",              world_units);
 
+	env.load_module_function("World", "update_animations",  world_update_animations);
+	env.load_module_function("World", "update",             world_update);
+
 	env.load_module_function("World", "play_sound",			world_play_sound);
 	env.load_module_function("World", "stop_sound", 		world_stop_sound);
 	env.load_module_function("World", "link_sound",			world_link_sound);

+ 7 - 1
engine/world/world.cpp

@@ -164,9 +164,15 @@ Camera* World::get_camera(CameraId id)
 }
 
 //-----------------------------------------------------------------------------
-void World::update(float dt)
+void World::update_animations(float dt)
 {
 	m_sprite_animation_player.update(dt);
+}
+
+//-----------------------------------------------------------------------------
+void World::update(float dt)
+{
+	update_animations(dt);
 
 	m_physics_world.update(dt);
 

+ 3 - 0
engine/world/world.h

@@ -91,6 +91,9 @@ public:
 	/// Returns the camera @a id.
 	Camera* get_camera(CameraId id);
 
+	/// Update all animations with @a dt.
+	void update_animations(float dt);
+
 	/// Updates all units and sub-systems with the given @a dt delta time.
 	void update(float dt);