mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
preliminary entId allocation
This commit is contained in:
parent
0f5e761eb8
commit
e570722e88
@ -95,12 +95,11 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
|
||||
if __debug__:
|
||||
# level editors should call this func to tweak attributes of level
|
||||
# entities
|
||||
def setAttribChange(self, entId, attribName, valueStr):
|
||||
value = eval(valueStr)
|
||||
def setAttribChange(self, entId, attribName, value):
|
||||
# send a copy to the client-side level obj FIRST
|
||||
# (it may be a message that creates an entity)
|
||||
self.sendUpdate('setAttribChange',
|
||||
[entId, attribName, valueStr])
|
||||
[entId, attribName, repr(value)])
|
||||
self.levelSpec.setAttribChange(entId, attribName, value)
|
||||
|
||||
self.modified = 1
|
||||
|
@ -1,27 +1,7 @@
|
||||
"""EditMgr module: contains the EditMgr class"""
|
||||
|
||||
import Entity
|
||||
import EditMgrBase
|
||||
|
||||
class EditMgr(Entity.Entity):
|
||||
"""This class handles entity/level functionality used by the level editor"""
|
||||
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())
|
||||
class EditMgr(EditMgrBase.EditMgrBase):
|
||||
"""This class handles client-side editor-specific functionality"""
|
||||
pass
|
||||
|
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 LogicGateAI
|
||||
import EditMgr
|
||||
import EditMgrAI
|
||||
import LevelMgrAI
|
||||
import ZoneEntityAI
|
||||
from PythonUtil import Functor
|
||||
@ -43,7 +43,7 @@ class EntityCreatorAI(EntityCreatorBase.EntityCreatorBase):
|
||||
|
||||
self.privRegisterTypes({
|
||||
'cutScene': nothing,
|
||||
'editMgr': Functor(cLE, EditMgr.EditMgr),
|
||||
'editMgr': Functor(cLE, EditMgrAI.EditMgrAI),
|
||||
'levelMgr': Functor(cLE, LevelMgrAI.LevelMgrAI),
|
||||
'logicGate': Functor(cLE, LogicGateAI.LogicGateAI),
|
||||
'nodepath': nothing,
|
||||
|
@ -35,6 +35,7 @@ class EditMgr(Entity):
|
||||
type = 'editMgr'
|
||||
attribs = (
|
||||
('requestSave', None),
|
||||
('requestNewEntity', None),
|
||||
('insertEntity', None),
|
||||
('removeEntity', None),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user