mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
preliminary entId allocation
This commit is contained in:
parent
0f5e761eb8
commit
e570722e88
@ -95,12 +95,11 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
|
|||||||
if __debug__:
|
if __debug__:
|
||||||
# level editors should call this func to tweak attributes of level
|
# level editors should call this func to tweak attributes of level
|
||||||
# entities
|
# entities
|
||||||
def setAttribChange(self, entId, attribName, valueStr):
|
def setAttribChange(self, entId, attribName, value):
|
||||||
value = eval(valueStr)
|
|
||||||
# send a copy to the client-side level obj FIRST
|
# send a copy to the client-side level obj FIRST
|
||||||
# (it may be a message that creates an entity)
|
# (it may be a message that creates an entity)
|
||||||
self.sendUpdate('setAttribChange',
|
self.sendUpdate('setAttribChange',
|
||||||
[entId, attribName, valueStr])
|
[entId, attribName, repr(value)])
|
||||||
self.levelSpec.setAttribChange(entId, attribName, value)
|
self.levelSpec.setAttribChange(entId, attribName, value)
|
||||||
|
|
||||||
self.modified = 1
|
self.modified = 1
|
||||||
|
@ -1,27 +1,7 @@
|
|||||||
"""EditMgr module: contains the EditMgr class"""
|
"""EditMgr module: contains the EditMgr class"""
|
||||||
|
|
||||||
import Entity
|
import EditMgrBase
|
||||||
|
|
||||||
class EditMgr(Entity.Entity):
|
class EditMgr(EditMgrBase.EditMgrBase):
|
||||||
"""This class handles entity/level functionality used by the level editor"""
|
"""This class handles client-side editor-specific functionality"""
|
||||||
def __init__(self, level, entId):
|
pass
|
||||||
Entity.Entity.__init__(self, level, entId)
|
|
||||||
|
|
||||||
def destroy(self):
|
|
||||||
Entity.Entity.destroy(self)
|
|
||||||
self.ignoreAll()
|
|
||||||
|
|
||||||
def setInsertEntity(self, data):
|
|
||||||
self.level.levelSpec.insertEntity(data['entId'],
|
|
||||||
data['entType'],
|
|
||||||
data['parentEntId'],
|
|
||||||
)
|
|
||||||
|
|
||||||
def setRemoveEntity(self, data):
|
|
||||||
self.level.levelSpec.removeEntity(data['entId'],
|
|
||||||
)
|
|
||||||
|
|
||||||
def getSpecSaveEvent(self):
|
|
||||||
return 'requestSave-%s' % self.level.levelId
|
|
||||||
def setRequestSave(self, data):
|
|
||||||
messenger.send(self.getSpecSaveEvent())
|
|
||||||
|
21
direct/src/level/EditMgrAI.py
Executable file
21
direct/src/level/EditMgrAI.py
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
"""EditMgrAI module: contains the EditMgrAI class"""
|
||||||
|
|
||||||
|
import EditMgrBase
|
||||||
|
from PythonUtil import list2dict
|
||||||
|
|
||||||
|
class EditMgrAI(EditMgrBase.EditMgrBase):
|
||||||
|
"""This class handles AI-side editor-specific functionality"""
|
||||||
|
def setRequestNewEntity(self, data):
|
||||||
|
# pick an unused entId
|
||||||
|
spec = self.level.levelSpec
|
||||||
|
entIds = spec.getAllEntIds()
|
||||||
|
entIdDict = list2dict(entIds)
|
||||||
|
# dumb linear search for now
|
||||||
|
id = 100
|
||||||
|
while id in entIdDict:
|
||||||
|
id += 1
|
||||||
|
|
||||||
|
# OK, we've chosen an unused entId. Add the entId to the data
|
||||||
|
# dict and do the insert
|
||||||
|
data.update({'entId': id})
|
||||||
|
self.level.setAttribChange(self.entId, 'insertEntity', data)
|
27
direct/src/level/EditMgrBase.py
Executable file
27
direct/src/level/EditMgrBase.py
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
"""EditMgrBase module: contains the EditMgrBase class"""
|
||||||
|
|
||||||
|
import Entity
|
||||||
|
|
||||||
|
class EditMgrBase(Entity.Entity):
|
||||||
|
"""This class contains EditMgr code shared between AI and client"""
|
||||||
|
def __init__(self, level, entId):
|
||||||
|
Entity.Entity.__init__(self, level, entId)
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
Entity.Entity.destroy(self)
|
||||||
|
self.ignoreAll()
|
||||||
|
|
||||||
|
def setInsertEntity(self, data):
|
||||||
|
self.level.levelSpec.insertEntity(data['entId'],
|
||||||
|
data['entType'],
|
||||||
|
data['parentEntId'],
|
||||||
|
)
|
||||||
|
|
||||||
|
def setRemoveEntity(self, data):
|
||||||
|
self.level.levelSpec.removeEntity(data['entId'],
|
||||||
|
)
|
||||||
|
|
||||||
|
def getSpecSaveEvent(self):
|
||||||
|
return 'requestSave-%s' % self.level.levelId
|
||||||
|
def setRequestSave(self, data):
|
||||||
|
messenger.send(self.getSpecSaveEvent())
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import EntityCreatorBase
|
import EntityCreatorBase
|
||||||
import LogicGateAI
|
import LogicGateAI
|
||||||
import EditMgr
|
import EditMgrAI
|
||||||
import LevelMgrAI
|
import LevelMgrAI
|
||||||
import ZoneEntityAI
|
import ZoneEntityAI
|
||||||
from PythonUtil import Functor
|
from PythonUtil import Functor
|
||||||
@ -43,7 +43,7 @@ class EntityCreatorAI(EntityCreatorBase.EntityCreatorBase):
|
|||||||
|
|
||||||
self.privRegisterTypes({
|
self.privRegisterTypes({
|
||||||
'cutScene': nothing,
|
'cutScene': nothing,
|
||||||
'editMgr': Functor(cLE, EditMgr.EditMgr),
|
'editMgr': Functor(cLE, EditMgrAI.EditMgrAI),
|
||||||
'levelMgr': Functor(cLE, LevelMgrAI.LevelMgrAI),
|
'levelMgr': Functor(cLE, LevelMgrAI.LevelMgrAI),
|
||||||
'logicGate': Functor(cLE, LogicGateAI.LogicGateAI),
|
'logicGate': Functor(cLE, LogicGateAI.LogicGateAI),
|
||||||
'nodepath': nothing,
|
'nodepath': nothing,
|
||||||
|
@ -35,6 +35,7 @@ class EditMgr(Entity):
|
|||||||
type = 'editMgr'
|
type = 'editMgr'
|
||||||
attribs = (
|
attribs = (
|
||||||
('requestSave', None),
|
('requestSave', None),
|
||||||
|
('requestNewEntity', None),
|
||||||
('insertEntity', None),
|
('insertEntity', None),
|
||||||
('removeEntity', None),
|
('removeEntity', None),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user