diff --git a/Documentation/ScriptEngine API [russian].txt b/Documentation/ScriptEngine API [russian].txt
index 6231fb1..70badb9 100644
--- a/Documentation/ScriptEngine API [russian].txt
+++ b/Documentation/ScriptEngine API [russian].txt
@@ -25,13 +25,13 @@ Object -> Item (Небольшой предмет) -> Gun -> Taser.
Точки передачи управления (колбеки, которые вызывает движок):
Модуль Map: FillMap()
-Модуль EngineHook: OnPlayerJoined()
+Модуль Engine.Hooks: OnPlayerJoined()
// more soon
-
+
// * * * * *
//
-// Модуль Engine_Server
+// Модуль Engine.Server
//
// * * * * *
@@ -75,7 +75,7 @@ ItemSpriteState(enumeration)
// * * * * *
//
-// Модуль Engine_World
+// Модуль Engine.World
//
// * * * * *
@@ -123,7 +123,9 @@ Object
Функции:
AddVerb(string id, function() action) - добавить действие объекту (можно запихать аргументом любую функцию без аргументов)
Update(duration timeDelta) - вызывается каждый такт обновления мира движком
- InteractedBy(Object) - вызывается, когда вызвано взаимодействие с объектом другим объектом (щелкнули по объекту: в аргументе то, что было в руке или сама рука)
+ InteractedBy(Object) -> bool // вызывается, когда вызвано взаимодействие с объектом другим объектом (щелкнули по объекту: в аргументе то, что было в руке или сама рука)
+ BumpedTo(Object) -> bool // вызывается, когда объект натыкается на другой объект (пока это возможно только для объектов, которым явно задали speed).
+ // При Move объект не начинает двигаться в препятствие
IsCloseTo(Object) - проверяет, находится ли объект рядом с тем, который передан в аргументе
Move(Vec2i) - передвинуть объект в заданном направлении. Все компоненты вектора должны быть == 1 ({1, 0}, {1, 1} например)
diff --git a/GameLogic/Engine/Hooks.py b/GameLogic/Engine/Hooks.py
new file mode 100644
index 0000000..f0ef1a5
--- /dev/null
+++ b/GameLogic/Engine/Hooks.py
@@ -0,0 +1,6 @@
+from Engine.Server import Player
+from Objects.Creatures.Ghost import Ghostize
+
+def OnPlayerJoined(player: Player):
+ print(player.ckey + " has joined! Yay!")
+ player.AddVerb("ghost", Ghostize)
diff --git a/GameLogic/Engine/HooksRawArgs.py b/GameLogic/Engine/HooksRawArgs.py
new file mode 100644
index 0000000..7e6e294
--- /dev/null
+++ b/GameLogic/Engine/HooksRawArgs.py
@@ -0,0 +1,4 @@
+from Engine.Hooks import *
+
+def rawOnPlayerJoined(player):
+ OnPlayerJoined(Player(player))
\ No newline at end of file
diff --git a/GameLogic/Engine/Server.py b/GameLogic/Engine/Server.py
new file mode 100644
index 0000000..35aa3a4
--- /dev/null
+++ b/GameLogic/Engine/Server.py
@@ -0,0 +1,52 @@
+from Engine_Server import *
+from Engine.World import World, Control
+
+from enum import Enum
+
+class Game(eGame):
+ def __new__(cls, parent):
+ return parent
+
+ @property
+ def world() -> World:
+ return World(eGGame.world)
+
+
+class Player(ePlayer):
+ def __new__(cls, parent):
+ return parent
+
+ @property
+ def ckey(self) -> str:
+ return super().ckey
+
+ @property
+ def control(self) -> Control:
+ return Control(super().control)
+
+ @control.setter
+ def control(self, value):
+ super(Player, self.__class__).control.fset(self, value)
+
+ def IsConnected(self) -> bool:
+ return super().IsConnected()
+
+
+class ResourceManager(eResourceManager):
+ def __new__(cls, parent):
+ return parent
+
+ def GetIcon(title, state) -> eIcon:
+ eGServer.RM.GetIcon(title, state)
+
+
+gServer = eGServer
+gGame = Game(eGGame)
+gRM = ResourceManager(eGServer.RM)
+
+
+class ItemSpriteState(eItemSpriteState):
+ DEFAULT = eItemSpriteState.DEFAULT
+ ON_MOB = eItemSpriteState.ON_MOB
+ IN_HAND_LEFT = eItemSpriteState.IN_HAND_LEFT
+ IN_HAND_RIGHT = eItemSpriteState.IN_HAND_RIGHT
diff --git a/GameLogic/Engine/Utils.py b/GameLogic/Engine/Utils.py
new file mode 100644
index 0000000..0a76dd1
--- /dev/null
+++ b/GameLogic/Engine/Utils.py
@@ -0,0 +1,8 @@
+import contextlib
+from datetime import timedelta
+from typing import Callable
+
+from Engine_Server import eGGame
+
+def spawn(delay: timedelta, activity: Callable[[], None]) -> None:
+ eGGame.AddDelayedActivity(delay, activity)
diff --git a/GameLogic/Engine/World.py b/GameLogic/Engine/World.py
new file mode 100644
index 0000000..f106ed7
--- /dev/null
+++ b/GameLogic/Engine/World.py
@@ -0,0 +1,295 @@
+from __future__ import annotations
+
+from Engine_World import *
+from Engine_Geometry import *
+
+from datetime import timedelta
+from typing import Callable
+
+class World(eWorld):
+ def __new__(cls, parent):
+ return parent
+
+ def GetObjectById(self, id: int) -> Object:
+ return super().GetObjectById(id)
+
+ def GetMap(self) -> Map:
+ return super().GetMap()
+
+
+class Map(eMap):
+ def __new__(cls, parent):
+ return parent
+
+ @property
+ def size(self) -> Vec3i:
+ return super().size()
+
+ def GetTile(pos: Vec3i) -> Tile:
+ return Tile(super().GetTile(pos))
+
+
+class Tile(eTile):
+ def __new__(cls, parent):
+ return parent
+
+ @property
+ def x(self) -> int:
+ return super().x
+ @property
+ def y(self) -> int:
+ return super().y
+ @property
+ def z(self) -> int:
+ return super().z
+
+ @property
+ def pos(self) -> Vec3i:
+ return super().pos
+
+ @property
+ def map(self) -> Map:
+ return Map(super().map)
+
+ def IsDense(self, directions: DirectionSet) -> bool:
+ return super().IsDense(directions)
+
+ def IsSpace(self) -> bool:
+ return super().IsSpace()
+
+ def GetDenseObject(self, directions: DirectionSet) -> Object:
+ return Object(super().GetDenseObject(directions))
+
+
+class Object(eObject):
+ def __init__(self):
+ super().__init__()
+
+ @property
+ def name(self) -> str:
+ return super().name
+ @name.setter
+ def name(self, value: str):
+ super(Object, self.__class__).name.fset(self, value)
+
+ @property
+ def sprite(self) -> str:
+ return super().sprite
+ @sprite.setter
+ def sprite(self, value):
+ super(Object, self.__class__).sprite.fset(self, value)
+
+ @property
+ def layer(self) -> int:
+ return super().layer
+ @layer.setter
+ def layer(self, value: int):
+ super(Object, self.__class__).layer.fset(self, value)
+
+ @property
+ def density(self) -> bool:
+ return super().density
+ @density.setter
+ def density(self, value: bool):
+ super(Object, self.__class__).density.fset(self, value)
+
+ @property
+ def solidity(self) -> DirectionSet:
+ return super().solidity
+ @solidity.setter
+ def solidity(self, value: DirectionSet):
+ super(Object, self.__class__).solidity.fset(self, value)
+
+ @property
+ def invisibility(self) -> int:
+ return super().invisibility
+ @invisibility.setter
+ def invisibility(self, value: int):
+ super(Object, self.__class__).invisibility.fset(self, value)
+
+ @property
+ def tile(self) -> Tile:
+ return Tile(super().tile)
+ @tile.setter
+ def tile(self, value: Tile):
+ super(Object, self.__class__).tile.fset(self, value)
+
+ @property
+ def position(self) -> Vec2i:
+ return super().position
+ @position.setter
+ def position(self, value: Vec2i):
+ super(Object, self.__class__).position.fset(self, value)
+
+ @property
+ def speed(self) -> Vec2f:
+ return super().speed
+ @speed.setter
+ def speed(self, value: Vec2f):
+ super(Object, self.__class__).speed.fset(self, value)
+
+ @property
+ def moveSpeed(self) -> float:
+ return super().moveSpeed
+ @moveSpeed.setter
+ def moveSpeed(self, value: float):
+ super(Object, self.__class__).moveSpeed.fset(self, value)
+
+ @property
+ def isFloor(self) -> bool:
+ return super().isFloor
+ @isFloor.setter
+ def isFloor(self, value: bool):
+ super(Object, self.__class__).isFloor.fset(self, value)
+
+ @property
+ def isWall(self) -> bool:
+ return super().isWall
+ @isWall.setter
+ def isWall(self, value: bool):
+ super(Object, self.__class__).isWall.fset(self, value)
+
+ def Update(self, timeElapsed: timedelta):
+ pass
+
+ def InteractedBy(self, obj: Object) -> bool:
+ return False
+
+ def BumpedTo(self, obj: Object) -> bool:
+ print(self.name + " bumped to " + obj.name)
+ return False
+
+ def IsCloseTo(self, obj: Object) -> bool:
+ return super().IsCloseTo(obj)
+
+ def Move(self, dir: Vec2i):
+ super().Move(dir)
+
+ def MoveZ(self, dir: int):
+ super().MoveZ(dir)
+
+ def AddComponent(self, type: str):
+ super().AddComponent(type)
+
+ def GetComponent(self, type: str) -> Component:
+ return Component(super().GetComponent(type))
+
+ def AddObject(self, obj: Object):
+ super().AddObject(obj)
+
+ def RemoveObject(self, obj: Object) -> bool:
+ return super().RemoveObject(obj)
+
+ def SetSpriteState(self, state: ItemSpriteState):
+ super().SetSpriteState(state)
+
+ def PlayAnimation(self, id: str, callback: Callable[[], None] = None) -> bool:
+ return super().PlayAnimation(id, callback)
+
+ def Delete(self):
+ super().Delete()
+
+ def _updateIcons(self):
+ super()._updateIcons()
+
+ def _pushToIcons(self, icon):
+ super()._pushToIcons(icon)
+
+
+def CreateObject(type: str, tile: Tile) -> Object:
+ return eCreateObject(type, tile)
+
+
+class Component(eComponent):
+ def __new__(cls, parent):
+ return parent
+
+ def Update(self, timeElapsed: timedelta):
+ super().Update(timedelta)
+
+ def GetOwner() -> Object:
+ return Object(super().GetOwner())
+
+
+class Control(eControl, Component):
+ def __new__(cls, parent):
+ return parent
+
+ @property
+ def seeInvisibleAbility(self) -> int:
+ return super().seeInvisibleAbility
+ @seeInvisibleAbility.setter
+ def seeInvisibleAbility(self, value: int):
+ super(Control, self.__class__).seeInvisibleAbility.fset(self, value)
+
+ def GetAndDropMoveOrder() -> Vec2i:
+ return super().GetAndDropMoveOrder()
+
+ def GetAndDropMoveZOrder() -> int:
+ return super().GetAndDropMoveZOrder()
+
+ def GetAndDropClickedObject() -> Object:
+ return Object(super().GetAndDropClickedObject())
+
+
+class ControlUI(eControlUI):
+ def __new__(cls, parent):
+ return parent
+
+ @property
+ def resolution(self) -> Vec2i:
+ return super().resolution
+
+ @property
+ def center(self) -> Vec2i:
+ return super().center
+
+ @property
+ def iconSize(self) -> Vec2i:
+ return super().iconSize
+
+
+ def UpdateElement(self, element: ControlUIElement):
+ super().UpdateElement(element)
+
+ def RemoveElement(self, elementId: str):
+ super().RemoveElement(elementId)
+
+
+class ControlUIElement(eControlUIElement):
+ def __init__(self):
+ super().__init__()
+
+ @property
+ def id(self) -> str:
+ return super().id
+ @id.setter
+ def id(self, value: str):
+ super(ControlUIElement, self.__class__).id.fset(self, value)
+
+ @property
+ def position(self) -> Vec2i:
+ return super().position
+ @position.setter
+ def position(self, value: Vec2i):
+ super(ControlUIElement, self.__class__).position.fset(self, value)
+
+ def RegisterCallback(self, action: Callable[[], None]):
+ super().RegisterCallback(action)
+
+ def AddIcon(self, name: str):
+ super().AddIcon(name)
+
+ def PopIcon(self):
+ super().PopIcon()
+
+ def ClearIcons(self):
+ super().ClearIcons()
+
+
+class VerbsHolder(eVerbsHolder):
+ def __new__(cls, parent):
+ return parent
+
+ def AddVerb(self, name: str, action: Callable[[], None]):
+ super().AddVerb(name, action)
diff --git a/GameLogic/Engine/__init__.py b/GameLogic/Engine/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/GameLogic/Engine/__init__.py
@@ -0,0 +1 @@
+
diff --git a/GameLogic/EngineHook.py b/GameLogic/EngineHook.py
deleted file mode 100644
index 54605ac..0000000
--- a/GameLogic/EngineHook.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from Objects.Creatures.Ghost import Ghostize
-
-def OnPlayerJoined(player):
- print(player.ckey + " has joined! Yay!")
- player.AddVerb("ghost", Ghostize)
diff --git a/GameLogic/GameLogic.pyproj b/GameLogic/GameLogic.pyproj
index 5e9961b..ec2efea 100644
--- a/GameLogic/GameLogic.pyproj
+++ b/GameLogic/GameLogic.pyproj
@@ -22,13 +22,27 @@
10.0
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
Code
-
Code
@@ -44,7 +58,6 @@
Code
-
Code
@@ -68,11 +81,12 @@
Code
-
+
Code
+
diff --git a/GameLogic/Map.py b/GameLogic/Map.py
index eebbaf5..4cd7d45 100644
--- a/GameLogic/Map.py
+++ b/GameLogic/Map.py
@@ -1,4 +1,4 @@
-from Engine_World import Map, CreateObject
+from Engine.World import Map, CreateObject, Object
from Engine_Geometry import Vec3i
from Objects.Turfs.Airlock import Airlock
diff --git a/GameLogic/Object.py b/GameLogic/Object.py
deleted file mode 100644
index 3f8835e..0000000
--- a/GameLogic/Object.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from datetime import timedelta
-
-from Engine_World import Object as EngineObject
-
-class Object(EngineObject):
- def __init__(self):
- super().__init__()
-
- def Update(self, timeElapsed):
- pass
-
- def InteractedBy(self, object):
- return False
-
- def BumpedTo(self, object):
- print(self.name + " bumped to " + object.name)
- return False
diff --git a/GameLogic/Objects/Creature.py b/GameLogic/Objects/Creature.py
index ab05c0e..38f72c8 100644
--- a/GameLogic/Objects/Creature.py
+++ b/GameLogic/Objects/Creature.py
@@ -1,5 +1,5 @@
-from Engine_Server import Server, ResourceManager, ItemSpriteState
-from Object import Object
+from Engine.Server import gRM, ItemSpriteState
+from Engine.World import Object
from Objects.Item import Item
from Objects.Items.Clothing import Clothing, MobSlot
from Objects.Creatures.IHasOrgans import IHasOrgans
@@ -154,8 +154,7 @@ def _pushStateToIcons(self, slot):
elif slot == MobSlot.RHAND:
state = ItemSpriteState.IN_HAND_RIGHT
- rm = Server.RM
- icon = rm.GetIcon(item.sprite, state)
+ icon = gRM.GetIcon(item.sprite, state)
if icon:
super()._pushToIcons(icon)
diff --git a/GameLogic/Objects/Creatures/Ghost.py b/GameLogic/Objects/Creatures/Ghost.py
index b092e74..1706e94 100644
--- a/GameLogic/Objects/Creatures/Ghost.py
+++ b/GameLogic/Objects/Creatures/Ghost.py
@@ -1,5 +1,5 @@
from Objects.Creature import Creature
-from Engine_World import CreateObject
+from Engine.World import CreateObject, Object
from Engine_Geometry import Vec2i
class Ghost(Creature):
diff --git a/GameLogic/Objects/Creatures/Human.py b/GameLogic/Objects/Creatures/Human.py
index a359a21..264191e 100644
--- a/GameLogic/Objects/Creatures/Human.py
+++ b/GameLogic/Objects/Creatures/Human.py
@@ -1,6 +1,6 @@
import types
-from Engine_World import CreateObject, ControlUIElement
+from Engine.World import CreateObject, ControlUIElement
from Engine_Geometry import Vec2i
from Objects.Creature import Creature
from Objects.Item import Item
diff --git a/GameLogic/Objects/Item.py b/GameLogic/Objects/Item.py
index af9dffd..69f8e35 100644
--- a/GameLogic/Objects/Item.py
+++ b/GameLogic/Objects/Item.py
@@ -1,4 +1,4 @@
-from Object import Object
+from Engine.World import Object
class Item(Object):
def __init__(self):
diff --git a/GameLogic/Objects/Items/Taser.py b/GameLogic/Objects/Items/Taser.py
index bc249e4..34133ce 100644
--- a/GameLogic/Objects/Items/Taser.py
+++ b/GameLogic/Objects/Items/Taser.py
@@ -1,6 +1,6 @@
from Objects.Item import Item
from Objects.Projectile import Projectile
-from Engine_World import CreateObject
+from Engine.World import CreateObject, Object
class Taser(Item):
def __init__(self):
diff --git a/GameLogic/Objects/Projectile.py b/GameLogic/Objects/Projectile.py
index 09c92c3..8d3f7e5 100644
--- a/GameLogic/Objects/Projectile.py
+++ b/GameLogic/Objects/Projectile.py
@@ -1,6 +1,6 @@
from Engine_Geometry import DirectionSet, Direction
+from Engine.World import Object
-from Object import Object
from Objects.Creature import Creature
class Projectile(Object):
diff --git a/GameLogic/Objects/Turf.py b/GameLogic/Objects/Turf.py
index ca48b3c..5b2b636 100644
--- a/GameLogic/Objects/Turf.py
+++ b/GameLogic/Objects/Turf.py
@@ -1,4 +1,4 @@
-from Object import Object
+from Engine.World import Object
class Turf(Object):
def __init__(self):
diff --git a/GameLogic/Objects/Turfs/Window.py b/GameLogic/Objects/Turfs/Window.py
index e8a6b9d..315121c 100644
--- a/GameLogic/Objects/Turfs/Window.py
+++ b/GameLogic/Objects/Turfs/Window.py
@@ -1,4 +1,5 @@
from Engine_Geometry import Direction
+from Engine.World import Object
from Objects.Turf import Turf
diff --git a/GameLogic/Utils.py b/GameLogic/Utils.py
deleted file mode 100644
index 4b480bb..0000000
--- a/GameLogic/Utils.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import contextlib
-from datetime import timedelta
-
-from Engine_Server import GGame
-
-def spawn(delay, activity):
- GGame.AddDelayedActivity(delay, activity)
diff --git a/OSS13 Server/Sources/ScriptEngine/Module/ServerModule.cpp b/OSS13 Server/Sources/ScriptEngine/Module/ServerModule.cpp
index e88d3c6..8f82497 100644
--- a/OSS13 Server/Sources/ScriptEngine/Module/ServerModule.cpp
+++ b/OSS13 Server/Sources/ScriptEngine/Module/ServerModule.cpp
@@ -3,6 +3,7 @@
#include
#include
#include
+#include
#include
#include
@@ -16,26 +17,26 @@
namespace py = pybind11;
PYBIND11_EMBEDDED_MODULE(Engine_Server, m) {
- py::class_(m, "Server")
+ py::class_(m, "eServer")
.def_property_readonly_static("RM", [](py::object) { return IServer::RM(); }, py::return_value_policy::reference);
- m.attr("GServer") = GServer;
+ m.attr("eGServer") = GServer;
- py::class_(m, "Game")
+ py::class_(m, "eGame")
.def_property_readonly("world", &Game::GetWorld)
.def("AddDelayedActivity", &Game::AddDelayedActivity);
- m.attr("GGame") = GGame;
+ m.attr("eGGame") = GGame;
- py::class_(m, "Player")
+ py::class_(m, "ePlayer")
.def_property_readonly("ckey", &Player::GetCKey)
.def_property("control", &Player::GetControl, &Player::SetControl, "", py::return_value_policy::reference)
.def("IsConnected", &Player::IsConnected);
- py::class_(m, "ResourceManager")
+ py::class_(m, "eResourceManager")
.def("GetIcon", &ResourceManager::GetIconInfo);
- py::class_(m, "Icon");
+ py::class_(m, "eIcon");
- py::enum_(m, "ItemSpriteState")
+ py::enum_(m, "eItemSpriteState")
.value("DEFAULT", Global::ItemSpriteState::DEFAULT)
.value("ON_MOB", Global::ItemSpriteState::ON_MOB)
.value("IN_HAND_LEFT", Global::ItemSpriteState::IN_HAND_LEFT)
diff --git a/OSS13 Server/Sources/ScriptEngine/Module/WorldModule.cpp b/OSS13 Server/Sources/ScriptEngine/Module/WorldModule.cpp
index 18eb72b..52f1e35 100644
--- a/OSS13 Server/Sources/ScriptEngine/Module/WorldModule.cpp
+++ b/OSS13 Server/Sources/ScriptEngine/Module/WorldModule.cpp
@@ -20,15 +20,15 @@ namespace py = pybind11;
namespace se = script_engine;
PYBIND11_EMBEDDED_MODULE(Engine_World, m) {
- py::class_(m, "World")
+ py::class_(m, "eWorld")
.def("GetObjectById", &World::GetObject)
.def("GetMap", &World::GetMap);
- py::class_