Skip to content

Commit 77833c0

Browse files
committed
继续完善rangelist功能。
1 parent 0548208 commit 77833c0

17 files changed

Lines changed: 631 additions & 35 deletions

‎kbe/src/server/cellapp/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SRCS = \
99
forward_message_over_handler \
1010
entity \
1111
entity_remotemethod \
12+
entity_range_node \
1213
history_event \
1314
main \
1415
space \

‎kbe/src/server/cellapp/cellapp90.vcproj‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@
211211
RelativePath=".\entity.cpp"
212212
>
213213
</File>
214+
<File
215+
RelativePath=".\entity_range_node.cpp"
216+
>
217+
</File>
214218
<File
215219
RelativePath=".\entity_remotemethod.cpp"
216220
>
@@ -311,6 +315,10 @@
311315
RelativePath=".\entity_interface_macros.hpp"
312316
>
313317
</File>
318+
<File
319+
RelativePath=".\entity_range_node.hpp"
320+
>
321+
</File>
314322
<File
315323
RelativePath=".\entity_remotemethod.hpp"
316324
>

‎kbe/src/server/cellapp/entity.cpp‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
2525
#include "profile.hpp"
2626
#include "space.hpp"
2727
#include "all_clients.hpp"
28+
#include "entity_range_node.hpp"
2829
#include "entitydef/entity_mailbox.hpp"
2930
#include "network/channel.hpp"
3031
#include "network/bundle.hpp"
@@ -84,9 +85,11 @@ topSpeedY_(-0.1f),
8485
isWitnessed_(false),
8586
pWitness_(NULL),
8687
allClients_(new AllClients(scriptModule, id, true)),
87-
otherClients_(new AllClients(scriptModule, id, false))
88+
otherClients_(new AllClients(scriptModule, id, false)),
89+
pEntityRangeNode_(NULL)
8890
{
8991
ENTITY_INIT_PROPERTYS(Entity);
92+
pEntityRangeNode_ = new EntityRangeNode(this);
9093
}
9194

9295
//-------------------------------------------------------------------------------------
@@ -105,6 +108,8 @@ Entity::~Entity()
105108
Witness::ObjPool().reclaimObject(pWitness_);
106109
pWitness_ = NULL;
107110
}
111+
112+
S_RELEASE(pEntityRangeNode_);
108113
}
109114

110115
//-------------------------------------------------------------------------------------
@@ -560,8 +565,8 @@ uint16 Entity::addProximity(float range)
560565
}
561566

562567
// 不允许范围大于cell边界
563-
if(range > CELL_BORDER_WIDTH)
564-
range = CELL_BORDER_WIDTH;
568+
if(range > g_kbeSrvConfig.getCellApp().ghostDistance)
569+
range = g_kbeSrvConfig.getCellApp().ghostDistance;
565570

566571
/*
567572
// 在space中投放一个陷阱

‎kbe/src/server/cellapp/entity.hpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
4545
#endif
4646

4747
namespace KBEngine{
48+
4849
class Chunk;
4950
class Entity;
5051
class EntityMailbox;
5152
class Cellapp;
5253
class Witness;
5354
class AllClients;
55+
class EntityRangeNode;
5456

5557
namespace Mercury
5658
{
@@ -369,6 +371,10 @@ class Entity : public script::ScriptObject
369371
INLINE SPACE_ENTITIES::size_type spaceEntityIdx()const;
370372
INLINE void spaceEntityIdx(SPACE_ENTITIES::size_type idx);
371373

374+
/**
375+
获取entity所在节点
376+
*/
377+
INLINE EntityRangeNode* pEntityRangeNode()const;
372378
private:
373379
/**
374380
发送teleport结果到base端
@@ -394,6 +400,8 @@ class Entity : public script::ScriptObject
394400

395401
AllClients* allClients_;
396402
AllClients* otherClients_;
403+
404+
EntityRangeNode* pEntityRangeNode_; // entity节点
397405
};
398406

399407

‎kbe/src/server/cellapp/entity.ipp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,11 @@ INLINE void Entity::pWitness(Witness* w)
147147
pWitness_ = w;
148148
}
149149

150+
//-------------------------------------------------------------------------------------
151+
INLINE EntityRangeNode* Entity::pEntityRangeNode()const
152+
{
153+
return pEntityRangeNode_;
154+
}
155+
150156
//-------------------------------------------------------------------------------------
151157
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
This source file is part of KBEngine
3+
For the latest info, see http://www.kbengine.org/
4+
5+
Copyright (c) 2008-2012 KBEngine.
6+
7+
KBEngine is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU Lesser General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
KBEngine is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#include "entity_range_node.hpp"
22+
#include "entity.hpp"
23+
24+
namespace KBEngine{
25+
26+
27+
//-------------------------------------------------------------------------------------
28+
EntityRangeNode::EntityRangeNode(Entity* pEntity):
29+
RangeNode(NULL),
30+
pEntity_(pEntity)
31+
{
32+
}
33+
34+
//-------------------------------------------------------------------------------------
35+
EntityRangeNode::~EntityRangeNode()
36+
{
37+
}
38+
39+
//-------------------------------------------------------------------------------------
40+
float EntityRangeNode::x()const
41+
{
42+
return pEntity_->getPosition().x;
43+
}
44+
45+
//-------------------------------------------------------------------------------------
46+
float EntityRangeNode::y()const
47+
{
48+
return pEntity_->getPosition().y;
49+
}
50+
51+
//-------------------------------------------------------------------------------------
52+
float EntityRangeNode::z()const
53+
{
54+
return pEntity_->getPosition().z;
55+
}
56+
57+
//-------------------------------------------------------------------------------------
58+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
This source file is part of KBEngine
3+
For the latest info, see http://www.kbengine.org/
4+
5+
Copyright (c) 2008-2012 KBEngine.
6+
7+
KBEngine is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU Lesser General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
KBEngine is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#ifndef __KBE_ENTITY_RANGE_NODE_HPP__
22+
#define __KBE_ENTITY_RANGE_NODE_HPP__
23+
24+
#include "range_node.hpp"
25+
26+
namespace KBEngine{
27+
28+
class Entity;
29+
30+
class EntityRangeNode : public RangeNode
31+
{
32+
public:
33+
EntityRangeNode(Entity* pEntity);
34+
virtual ~EntityRangeNode();
35+
36+
/**
37+
x && z由不同的应用实现(从不同处获取)
38+
*/
39+
virtual float x()const;
40+
virtual float y()const;
41+
virtual float z()const;
42+
43+
Entity* pEntity()const { return pEntity_; }
44+
protected:
45+
Entity* pEntity_;
46+
};
47+
48+
}
49+
50+
#endif

0 commit comments

Comments
 (0)