diff --git a/GameLogic/Engine/Server.py b/GameLogic/Engine/Server.py
index aa8c779..53d5be5 100644
--- a/GameLogic/Engine/Server.py
+++ b/GameLogic/Engine/Server.py
@@ -28,7 +28,7 @@ def __init__(self, impl):
def world() -> Engine.World.World:
return Engine.World.World(eGGame.world)
-class Player(ePlayer, Engine.World.VerbsHolder):
+class Player(ePlayer):
"""
Player class is persistent until restart. When player re-logins, existed Player instance is used.
@@ -47,10 +47,18 @@ class Player(ePlayer, Engine.World.VerbsHolder):
IsConnected() -> bool
returns True when player is online
+ AddVerb(name: str, action: Callable[[Player], None])
+ add new verb
+
+ Parametres
+ ----------
+ name: str
+ verb's key. Use name to call verb from console
+
"""
def __init__(self, impl):
- Engine.World.VerbsHolder.__init__(self, impl)
+ self._impl = impl
@property
def ckey(self) -> str:
@@ -66,6 +74,10 @@ def control(self, value: Engine.World.Control):
def IsConnected(self) -> bool:
return self._impl.IsConnected()
+ def AddVerb(self, name: str, action: Callable[[Engine.Server.Player], None]):
+ wrapper = lambda player: action(Engine.Server.Player(player))
+ self._impl.AddVerb(name, wrapper)
+
class ResourceManager(eResourceManager):
"""
diff --git a/GameLogic/Engine/World.py b/GameLogic/Engine/World.py
index 3cdda0d..522a2ef 100644
--- a/GameLogic/Engine/World.py
+++ b/GameLogic/Engine/World.py
@@ -125,37 +125,7 @@ def GetDenseObject(self, directions: DirectionSet) -> Object:
return self._impl.GetDenseObject(directions._impl)
-class VerbsHolder(eVerbsHolder):
- """
- Inheritance from this class allow to define special actions without
- arguments which can be called with command from console
-
- VerbsHolder is registrated with unique name, so player can call it's verbs.
-
- For example, class Player registrated with name "Player".
- So player's verb "Drop" can be called with next command: "Player.Drop"
-
- Methods
- -------
- AddVerb(name: str, action: Callable[[Player], None])
- add new verb
-
- Parametres
- ----------
- name: str
- verb's key. Use name to call verb from console
-
- """
-
- def __init__(self, impl):
- self._impl = impl
-
- def AddVerb(self, name: str, action: Callable[[Engine.Server.Player], None]):
- wrapper = lambda player: action(Engine.Server.Player(player))
- eVerbsHolder.AddVerb(self._impl, name, wrapper)
-
-
-class Object(eObject, VerbsHolder):
+class Object(eObject):
"""
Any game object
@@ -313,6 +283,14 @@ class Object(eObject, VerbsHolder):
Note: "animation" is animated sprite. Thus "id" is sprite id.
+ AddVerb(name: str, action: Callable[[Player], None])
+ add new verb
+
+ Parametres
+ ----------
+ name: str
+ verb's key. Use name to call verb from console
+
Delete(self):
delete object
@@ -343,7 +321,6 @@ class Object(eObject, VerbsHolder):
def __init__(self):
eObject.__init__(self)
- VerbsHolder.__init__(self, self)
self.name = str(self.defName)
self.sprite = str(self.defSprite)
self.description = str(self.defDescription)
@@ -490,6 +467,10 @@ def SetSpriteState(self, state: ItemSpriteState):
def PlayAnimation(self, id: str, callback: Callable[[], None] = None) -> bool:
return super().PlayAnimation(id, callback)
+ def AddVerb(self, name: str, action: Callable[[Engine.Server.Player], None]):
+ wrapper = lambda player: action(Engine.Server.Player(player))
+ super().AddVerb(name, wrapper)
+
def Delete(self):
super().Delete()
diff --git a/OSS13 Client/OSS13 Client.vcxproj b/OSS13 Client/OSS13 Client.vcxproj
index f8ac7e4..9214260 100644
--- a/OSS13 Client/OSS13 Client.vcxproj
+++ b/OSS13 Client/OSS13 Client.vcxproj
@@ -77,7 +77,7 @@
/ignore:4099 %(AdditionalOptions)
- opengl32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)
+ opengl32.lib;%(AdditionalDependencies)
mainCRTStartup
Windows
@@ -88,7 +88,7 @@
/ignore:4099 %(AdditionalOptions)
- opengl32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)
+ opengl32.lib;%(AdditionalDependencies)
mainCRTStartup
Windows
@@ -102,7 +102,7 @@
true
true
- opengl32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)
+ opengl32.lib;%(AdditionalDependencies)
mainCRTStartup
Windows
@@ -116,7 +116,7 @@
true
true
- opengl32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)
+ opengl32.lib;%(AdditionalDependencies)
mainCRTStartup
Windows
diff --git a/OSS13 Client/Sources/Graphics/TileGrid/Object.cpp b/OSS13 Client/Sources/Graphics/TileGrid/Object.cpp
index 2041310..c8e7e4b 100644
--- a/OSS13 Client/Sources/Graphics/TileGrid/Object.cpp
+++ b/OSS13 Client/Sources/Graphics/TileGrid/Object.cpp
@@ -10,13 +10,14 @@
#include
#include
-Object::Object(const network::protocol::ObjectInfo &objectInfo) {
+Object::Object(network::protocol::ObjectInfo &&objectInfo) {
for (auto &sprite : objectInfo.spriteIds) {
AddSprite(uint(sprite));
}
+ static_cast(*this) = std::move(objectInfo.fields);
+
id = objectInfo.id;
- name = objectInfo.name;
layer = objectInfo.layer;
direction = objectInfo.direction;
density = objectInfo.density;
diff --git a/OSS13 Client/Sources/Graphics/TileGrid/Object.hpp b/OSS13 Client/Sources/Graphics/TileGrid/Object.hpp
index a2e57f8..0837f01 100644
--- a/OSS13 Client/Sources/Graphics/TileGrid/Object.hpp
+++ b/OSS13 Client/Sources/Graphics/TileGrid/Object.hpp
@@ -10,6 +10,7 @@
#include
#include
#include
+#include
class Sprite;
class Tile;
@@ -22,9 +23,9 @@ namespace sf {
#include "iostream"
-class Object {
+class Object : public network::sync::ObjectSyncFields {
public:
- explicit Object(const network::protocol::ObjectInfo &objectInfo);
+ explicit Object(network::protocol::ObjectInfo &&objectInfo);
Object &operator=(Object &) = default;
~Object();
@@ -62,7 +63,6 @@ class Object {
private:
uint id{};
- std::string name;
std::vector<::Sprite> sprites;
::Sprite animation;
bool animationProcess{};
diff --git a/OSS13 Client/Sources/Graphics/TileGrid/Tile.cpp b/OSS13 Client/Sources/Graphics/TileGrid/Tile.cpp
index 95da6c0..8cedeff 100644
--- a/OSS13 Client/Sources/Graphics/TileGrid/Tile.cpp
+++ b/OSS13 Client/Sources/Graphics/TileGrid/Tile.cpp
@@ -15,7 +15,7 @@ Tile::Tile(TileGrid *tileGrid) :
overlay.setCharacterSize(10);
}
-Tile::Tile(TileGrid *tileGrid, const network::protocol::TileInfo &tileInfo) :
+Tile::Tile(TileGrid *tileGrid, network::protocol::TileInfo &&tileInfo) :
Tile(tileGrid)
{
sprite = CC::Get()->RM.CreateSprite(uint(tileInfo.sprite));
@@ -23,12 +23,14 @@ Tile::Tile(TileGrid *tileGrid, const network::protocol::TileInfo &tileInfo) :
for (auto &objInfo : tileInfo.content) {
auto &objects = GetTileGrid()->GetObjects();
- auto iter = objects.find(objInfo.id);
+ auto id = objInfo.id;
+
+ auto iter = objects.find(id);
if (iter == objects.end()) {
- objects[objInfo.id] = std::make_unique