diff options
| author | orwell <orwell@bleipb.de> | 2024-06-12 22:48:56 +0200 |
|---|---|---|
| committer | orwell <orwell@bleipb.de> | 2024-06-12 22:48:56 +0200 |
| commit | 2239ba314b0a39b7e6d2351d582c396df821b281 (patch) | |
| tree | a55d92c1f87b6126387ab07d8e3db5c940c2cb2f /advtrains_signals_ks | |
| parent | dcceb65ff04573375016f2460edcbd349e506a4e (diff) | |
Ks Vorsignal
Diffstat (limited to 'advtrains_signals_ks')
| -rwxr-xr-x | advtrains_signals_ks/init.lua | 112 | ||||
| -rw-r--r-- | advtrains_signals_ks/models/advtrains_signals_ks_distant_smr0.obj | 3293 | ||||
| -rw-r--r-- | advtrains_signals_ks/models/advtrains_signals_ks_distant_smr30.obj | 3291 | ||||
| -rw-r--r-- | advtrains_signals_ks/models/advtrains_signals_ks_distant_smr45.obj | 3296 | ||||
| -rw-r--r-- | advtrains_signals_ks/models/advtrains_signals_ks_distant_smr60.obj | 3293 | ||||
| -rw-r--r-- | advtrains_signals_ks/textures/advtrains_signals_ks_vs_inv.png | bin | 0 -> 4234 bytes |
6 files changed, 13279 insertions, 6 deletions
diff --git a/advtrains_signals_ks/init.lua b/advtrains_signals_ks/init.lua index 6afc66d..d0ba6cd 100755 --- a/advtrains_signals_ks/init.lua +++ b/advtrains_signals_ks/init.lua @@ -122,6 +122,30 @@ local mainaspects_main = { }, } +local applyaspectf_distant = function(rot) + return function(pos, node, main_aspect, dst_aspect, dst_aspect_info) + if main_aspect.halt then + -- halt aspect, set red and don't do anything further + advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:vs_slow_"..rot, param2 = node.param2}) + setzs3v(pos, nil, rot) + return + end + -- select appropriate lamps based on mainaspect and dst + if not dst_aspect_info + or not dst_aspect_info.main + or dst_aspect_info.main == -1 then + advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:vs_free_"..rot, param2 = node.param2}) + setzs3v(pos, nil, rot) + elseif dst_aspect_info.main == 0 then + advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:vs_slow_"..rot, param2 = node.param2}) + setzs3v(pos, nil, rot) + else + advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:vs_nextslow_"..rot, param2 = node.param2}) + setzs3v(pos, dst_aspect_info.main, rot) + end + end +end + --Rangiersignal local applyaspectf_ra = function(rot) -- we get here the full main_aspect table @@ -146,12 +170,14 @@ local mainaspects_shunt = { } for _, rtab in ipairs({ - {rot = "0", sbox = {-1/8, -1/2, -1/2, 1/8, 1/2, -1/4}, ici=true}, - {rot = "30", sbox = {-3/8, -1/2, -1/2, -1/8, 1/2, -1/4},}, - {rot = "45", sbox = {-1/2, -1/2, -1/2, -1/4, 1/2, -1/4},}, - {rot = "60", sbox = {-1/2, -1/2, -3/8, -1/4, 1/2, -1/8},}, + {rot = "0", sbox = {-1/8, -1/2, -1/2, 1/8, 1/2, -1/4}, ici=true, nextrot = "30"}, + {rot = "30", sbox = {-3/8, -1/2, -1/2, -1/8, 1/2, -1/4}, nextrot = "45"}, + {rot = "45", sbox = {-1/2, -1/2, -1/2, -1/4, 1/2, -1/4}, nextrot = "60"}, + {rot = "60", sbox = {-1/2, -1/2, -3/8, -1/4, 1/2, -1/8}, nextrot = "0"}, }) do local rot = rtab.rot + + -- Hauptsignal for typ, prts in pairs({ danger = {asp = advtrains.interlocking.signal.ASPI_HALT, n = "slow", ici=true}, slow = { @@ -219,13 +245,86 @@ for _, rtab in ipairs({ apply_aspect = applyaspectf_main(rot), get_aspect_info = afunc, route_role = "main_distant", + trackworker_next_rot = "advtrains_signals_ks:hs_"..typ.."_"..rtab.nextrot, + trackworker_rot_incr_param2 = (rot=="60") + }, + on_rightclick = advtrains.interlocking.signal.on_rightclick, + can_dig = advtrains.interlocking.signal.can_dig, + after_dig_node = advtrains.interlocking.signal.after_dig, + }) + -- rotatable by trackworker + end + + -- Vorsignal (NEU!) + for typ, prts in pairs({ + -- note: the names are taken from the main signal equivalent so that the same names for the lamp images can be used + slow = {asp = advtrains.interlocking.signal.ASPI_HALT, n = "nextslow", ici=true}, + nextslow = { + asp = function(pos) + return { dst = getzs3v(pos) or 6 } + end, + n = "free" + }, + free = { + asp = function(pos) + return { dst = -1 } + end, + n = "slow" + }, + }) do + local tile = "advtrains_signals_ks_ltm_"..typ..".png" + local afunc = prts.asp + if type(afunc) == "table" then + afunc = function() return prts.asp end + end + if typ == "nextslow" then + tile = { + name = tile, + animation = { + type = "vertical_frames", + aspect_w = 32, + aspect_h = 32, + length = 1, + } + } + end + minetest.register_node("advtrains_signals_ks:vs_"..typ.."_"..rot, { + description = "Ks Distant Signal", + drawtype = "mesh", + mesh = "advtrains_signals_ks_distant_smr"..rot..".obj", + tiles = {"advtrains_signals_ks_mast.png", "advtrains_signals_ks_head.png", "advtrains_signals_ks_head.png", tile}, + + paramtype="light", + sunlight_propagates=true, + light_source = 4, + + paramtype2 = "facedir", + selection_box = { + type = "fixed", + fixed = {rtab.sbox, {-1/4, -1/2, -1/4, 1/4, -7/16, 1/4}} + }, + groups = { + cracky = 2, + advtrains_signal = 2, + not_blocking_trains = 1, + save_in_at_nodedb = 1, + not_in_creative_inventory = (rtab.ici and prts.ici) and 0 or 1, + }, + drop = "advtrains_signals_ks:vs_slow_0", + inventory_image = "advtrains_signals_ks_vs_inv.png", + advtrains = { + -- no mainaspect + apply_aspect = applyaspectf_distant(rot), + get_aspect_info = afunc, + route_role = "distant", + trackworker_next_rot = "advtrains_signals_ks:vs_"..typ.."_"..rtab.nextrot, + trackworker_rot_incr_param2 = (rot=="60") }, on_rightclick = advtrains.interlocking.signal.on_rightclick, can_dig = advtrains.interlocking.signal.can_dig, after_dig_node = advtrains.interlocking.signal.after_dig, }) -- rotatable by trackworker - --TODO add rotation using trackworker end @@ -263,13 +362,14 @@ for _, rtab in ipairs({ apply_aspect = applyaspectf_ra(rot), get_aspect_info = prts.asp, route_role = "shunt", + trackworker_next_rot = "advtrains_signals_ks:ra_"..typ.."_"..rtab.nextrot, + trackworker_rot_incr_param2 = (rot=="60") }, on_rightclick = advtrains.interlocking.signal.on_rightclick, can_dig = advtrains.interlocking.signal.can_dig, after_dig_node = advtrains.interlocking.signal.after_dig, }) -- rotatable by trackworker - --TODO add rotation using trackworker end -- Schilder: diff --git a/advtrains_signals_ks/models/advtrains_signals_ks_distant_smr0.obj b/advtrains_signals_ks/models/advtrains_signals_ks_distant_smr0.obj new file mode 100644 index 0000000..9655dc4 --- /dev/null +++ b/advtrains_signals_ks/models/advtrains_signals_ks_distant_smr0.obj @@ -0,0 +1,3293 @@ +# Blender 3.4.1 +# www.blender.org +mtllib advtrains_signals_ks_distant_smr0.mtl +o KsHauptsignal_Plane.006 +v 0.028888 -0.503378 -0.439591 +v -0.028274 -0.503378 -0.439631 +v -0.028235 -0.503378 -0.496794 +v 0.028928 -0.503378 -0.496754 +v 0.028809 -0.503378 -0.325555 +v 0.028769 -0.503378 -0.268392 +v -0.028394 -0.503378 -0.268432 +v -0.028354 -0.503378 -0.325595 +v 0.028888 -0.299114 -0.439591 +v 0.028888 -0.172218 -0.439591 +v -0.028274 -0.172218 -0.439631 +v -0.028274 -0.299114 -0.439631 +v -0.028235 -0.299114 -0.496794 +v -0.028235 -0.172218 -0.496794 +v 0.028928 -0.172218 -0.496754 +v 0.028928 -0.299114 -0.496754 +v 0.028809 -0.299114 -0.325555 +v 0.028809 -0.172218 -0.325555 +v 0.028769 -0.172218 -0.268392 +v 0.028769 -0.299114 -0.268392 +v -0.028394 -0.299114 -0.268432 +v -0.028394 -0.172218 -0.268432 +v -0.028354 -0.172218 -0.325595 +v -0.028354 -0.299114 -0.325595 +v -0.135201 0.243339 -0.586523 +v -0.135219 0.242789 -0.559563 +v -0.132013 0.253858 -0.639022 +v -0.132068 0.253308 -0.559514 +v -0.126870 0.263561 -0.638975 +v -0.126926 0.263011 -0.559467 +v -0.119933 0.272074 -0.638933 +v -0.119989 0.271524 -0.559424 +v -0.111469 0.279070 -0.638896 +v -0.111524 0.278520 -0.559387 +v -0.101802 0.284280 -0.638865 +v -0.101858 0.283730 -0.559357 +v -0.091305 0.287504 -0.638844 +v -0.091361 0.286954 -0.559335 +v -0.080380 0.288619 -0.638831 +v -0.080436 0.288069 -0.559323 +v -0.069448 0.287581 -0.638828 +v -0.069504 0.287030 -0.559320 +v -0.058929 0.284430 -0.638835 +v -0.058984 0.283880 -0.559327 +v -0.049226 0.279287 -0.638851 +v -0.049281 0.278737 -0.559343 +v -0.040713 0.272350 -0.638876 +v -0.040768 0.271800 -0.559368 +v -0.033717 0.263886 -0.638909 +v -0.033772 0.263336 -0.559401 +v -0.028506 0.254219 -0.638948 +v -0.028562 0.253669 -0.559440 +v -0.025318 0.243722 -0.586445 +v -0.025337 0.243172 -0.559485 +v -0.024183 0.232316 -0.586441 +v -0.024223 0.232252 -0.559532 +v -0.025274 0.221688 -0.586283 +v -0.025260 0.221322 -0.559578 +v -0.028394 0.211344 -0.586324 +v -0.028411 0.210797 -0.559621 +v -0.033537 0.201642 -0.586366 +v -0.033554 0.201094 -0.559663 +v -0.040474 0.193129 -0.586405 +v -0.040491 0.192581 -0.559701 +v -0.048938 0.186134 -0.586439 +v -0.048955 0.185585 -0.559735 +v -0.058604 0.180924 -0.586466 +v -0.058622 0.180374 -0.559762 +v -0.069101 0.177700 -0.586486 +v -0.069119 0.177150 -0.559782 +v -0.080026 0.176585 -0.586498 +v -0.080044 0.176035 -0.559794 +v -0.090958 0.177623 -0.586502 +v -0.090977 0.177073 -0.559798 +v -0.101477 0.180774 -0.586496 +v -0.101497 0.180224 -0.559793 +v -0.111180 0.185916 -0.586483 +v -0.111200 0.185367 -0.559779 +v -0.119693 0.192853 -0.586461 +v -0.119713 0.192304 -0.559758 +v -0.126689 0.201317 -0.586433 +v -0.126709 0.200769 -0.559729 +v -0.131899 0.210983 -0.586398 +v -0.131919 0.210436 -0.559694 +v -0.135091 0.221305 -0.586361 +v -0.135144 0.220938 -0.559656 +v -0.136256 0.231924 -0.586521 +v -0.136258 0.231861 -0.559612 +v -0.137672 0.243790 -0.586520 +v -0.137717 0.243271 -0.523031 +v -0.134343 0.254782 -0.639014 +v -0.134424 0.254264 -0.522977 +v -0.128969 0.264921 -0.638963 +v -0.129050 0.264402 -0.522926 +v -0.121720 0.273816 -0.638916 +v -0.121801 0.273298 -0.522879 +v -0.112875 0.281127 -0.638876 +v -0.112956 0.280609 -0.522839 +v -0.102774 0.286572 -0.638843 +v -0.102855 0.286053 -0.522806 +v -0.091805 0.289941 -0.638820 +v -0.091886 0.289423 -0.522782 +v -0.080389 0.291105 -0.638806 +v -0.080470 0.290587 -0.522769 +v -0.068965 0.290021 -0.638803 +v -0.069047 0.289502 -0.522766 +v -0.057973 0.286728 -0.638811 +v -0.058054 0.286210 -0.522774 +v -0.047834 0.281354 -0.638829 +v -0.047915 0.280836 -0.522792 +v -0.038938 0.274105 -0.638857 +v -0.039019 0.273587 -0.522820 +v -0.031628 0.265261 -0.638893 +v -0.031709 0.264742 -0.522856 +v -0.026183 0.255160 -0.638937 +v -0.026264 0.254641 -0.522900 +v -0.022850 0.244190 -0.586438 +v -0.022895 0.243672 -0.522949 +v -0.021686 0.232775 -0.586437 +v -0.021730 0.232256 -0.523002 +v -0.022771 0.221351 -0.586289 +v -0.022815 0.220833 -0.523056 +v -0.026063 0.210359 -0.586343 +v -0.026107 0.209840 -0.523110 +v -0.031437 0.200220 -0.586394 +v -0.031481 0.199702 -0.523162 +v -0.038686 0.191324 -0.586441 +v -0.038730 0.190806 -0.523209 +v -0.047531 0.184013 -0.586481 +v -0.047575 0.183495 -0.523249 +v -0.057632 0.178569 -0.586514 +v -0.057676 0.178051 -0.523282 +v -0.068601 0.175200 -0.586538 +v -0.068645 0.174682 -0.523305 +v -0.080017 0.174035 -0.586551 +v -0.080061 0.173517 -0.523319 +v -0.091441 0.175120 -0.586554 +v -0.091485 0.174602 -0.523322 +v -0.102433 0.178413 -0.586546 +v -0.102477 0.177894 -0.523314 +v -0.112572 0.183787 -0.586528 +v -0.112616 0.183268 -0.523296 +v -0.121468 0.191035 -0.586500 +v -0.121512 0.190517 -0.523268 +v -0.128778 0.199880 -0.586464 +v -0.128823 0.199362 -0.523231 +v -0.134223 0.209981 -0.586420 +v -0.134267 0.209463 -0.523188 +v -0.137592 0.220950 -0.586371 +v -0.137637 0.220432 -0.523138 +v -0.138757 0.232366 -0.586521 +v -0.138801 0.231848 -0.523086 +v 0.097038 0.383581 -0.586361 +v 0.097019 0.383353 -0.559401 +v 0.098378 0.387932 -0.638861 +v 0.098323 0.387704 -0.559353 +v 0.100505 0.391945 -0.638817 +v 0.100450 0.391717 -0.559308 +v 0.103374 0.395466 -0.638777 +v 0.103319 0.395239 -0.559268 +v 0.106875 0.398360 -0.638743 +v 0.106820 0.398132 -0.559235 +v 0.110874 0.400515 -0.638717 +v 0.110818 0.400287 -0.559209 +v 0.115216 0.401848 -0.638700 +v 0.115160 0.401621 -0.559191 +v 0.119734 0.402309 -0.638692 +v 0.119679 0.402082 -0.559183 +v 0.124256 0.401880 -0.638693 +v 0.124201 0.401652 -0.559185 +v 0.128607 0.400577 -0.638704 +v 0.128552 0.400349 -0.559196 +v 0.132620 0.398450 -0.638724 +v 0.132565 0.398222 -0.559216 +v 0.136141 0.395581 -0.638753 +v 0.136086 0.395353 -0.559244 +v 0.139035 0.392080 -0.638788 +v 0.138980 0.391852 -0.559280 +v 0.141190 0.388081 -0.638830 +v 0.141135 0.387854 -0.559322 +v 0.142487 0.383739 -0.586328 +v 0.142469 0.383512 -0.559367 +v 0.142957 0.379021 -0.586324 +v 0.142930 0.378995 -0.559416 +v 0.142506 0.374626 -0.586166 +v 0.142501 0.374474 -0.559461 +v 0.141215 0.370347 -0.586206 +v 0.141197 0.370121 -0.559502 +v 0.139088 0.366334 -0.586246 +v 0.139070 0.366108 -0.559542 +v 0.136219 0.362813 -0.586282 +v 0.136201 0.362586 -0.559578 +v 0.132718 0.359920 -0.586312 +v 0.132700 0.359693 -0.559608 +v 0.128720 0.357765 -0.586335 +v 0.128702 0.357538 -0.559632 +v 0.124378 0.356431 -0.586351 +v 0.124360 0.356204 -0.559647 +v 0.119860 0.355970 -0.586358 +v 0.119841 0.355743 -0.559655 +v 0.115338 0.356399 -0.586358 +v 0.115319 0.356172 -0.559654 +v 0.110987 0.357703 -0.586348 +v 0.110968 0.357476 -0.559645 +v 0.106974 0.359830 -0.586331 +v 0.106954 0.359603 -0.559627 +v 0.103453 0.362699 -0.586305 +v 0.103433 0.362472 -0.559602 +v 0.100559 0.366200 -0.586274 +v 0.100539 0.365973 -0.559570 +v 0.098404 0.370198 -0.586237 +v 0.098384 0.369972 -0.559533 +v 0.097083 0.374467 -0.586199 +v 0.097050 0.374316 -0.559494 +v 0.096602 0.378860 -0.586358 +v 0.096590 0.378833 -0.559449 +v 0.096016 0.383767 -0.586357 +v 0.095972 0.383553 -0.522868
virtual float getTriggerInterval() = 0;
// Random chance of (1 / return value), 0 is disallowed
virtual u32 getTriggerChance() = 0;
// This is called usually at interval for 1/chance of the nodes
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n){};
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
u32 active_object_count, u32 active_object_count_wider){};
};
struct ABMWithState
{
ActiveBlockModifier *abm;
float timer;
ABMWithState(ActiveBlockModifier *abm_);
};
/*
List of active blocks, used by ServerEnvironment
*/
class ActiveBlockList
{
public:
void update(std::list<v3s16> &active_positions,
s16 radius,
std::set<v3s16> &blocks_removed,
std::set<v3s16> &blocks_added);
bool contains(v3s16 p){
return (m_list.find(p) != m_list.end());
}
void clear(){
m_list.clear();
}
std::set<v3s16> m_list;
private:
};
class IBackgroundBlockEmerger
{
public:
virtual void queueBlockEmerge(v3s16 blockpos, bool allow_generate)=0;
};
/*
The server-side environment.
This is not thread-safe. Server uses an environment mutex.
*/
class ServerEnvironment : public Environment
{
public:
ServerEnvironment(ServerMap *map, lua_State *L, IGameDef *gamedef,
IBackgroundBlockEmerger *emerger);
~ServerEnvironment();
Map & getMap();
ServerMap & getServerMap();
lua_State* getLua()
{ return m_lua; }
IGameDef *getGameDef()
{ return m_gamedef; }
float getSendRecommendedInterval()
{ return m_recommended_send_interval; }
/*
Save players
*/
void serializePlayers(const std::string &savedir);
void deSerializePlayers(const std::string &savedir);
/*
Save and load time of day and game timer
*/
void saveMeta(const std::string &savedir);
void loadMeta(const std::string &savedir);
/*
External ActiveObject interface
-------------------------------------------
*/
ServerActiveObject* getActiveObject(u16 id);
/*
Add an active object to the environment.
Environment handles deletion of object.
Object may be deleted by environment immediately.
If id of object is 0, assigns a free id to it.
Returns the id of the object.
Returns 0 if not added and thus deleted.
*/
u16 addActiveObject(ServerActiveObject *object);
/*
Add an active object as a static object to the corresponding
MapBlock.
Caller allocates memory, ServerEnvironment frees memory.
Return value: true if succeeded, false if failed.
(note: not used, pending removal from engine)
*/
//bool addActiveObjectAsStatic(ServerActiveObject *object);
/*
Find out what new objects have been added to
inside a radius around a position
*/
void getAddedActiveObjects(v3s16 pos, s16 radius,
std::set<u16> ¤t_objects,
std::set<u16> &added_objects);
/*
Find out what new objects have been removed from
inside a radius around a position
*/
void getRemovedActiveObjects(v3s16 pos, s16 radius,
std::set<u16> ¤t_objects,
std::set<u16> &removed_objects);
/*
Get the next message emitted by some active object.
Returns a message with id=0 if no messages are available.
*/
ActiveObjectMessage getActiveObjectMessage();
/*
Activate objects and dynamically modify for the dtime determined
from timestamp and additional_dtime
*/
void activateBlock(MapBlock *block, u32 additional_dtime=0);
/*
ActiveBlockModifiers
-------------------------------------------
*/
void addActiveBlockModifier(ActiveBlockModifier *abm);
/*
Other stuff
-------------------------------------------
*/
// Script-aware node setters
bool setNode(v3s16 p, const MapNode &n);
bool removeNode(v3s16 p);
// Find all active objects inside a radius around a point
std::set<u16> getObjectsInsideRadius(v3f pos, float radius);
// Clear all objects, loading and going through every MapBlock
void clearAllObjects();
// This makes stuff happen
void step(f32 dtime);
//check if there's a line of sight between two positions
bool line_of_sight(v3f pos1, v3f pos2, float stepsize=1.0);
private:
/*
Internal ActiveObject interface
-------------------------------------------
*/
/*
Add an active object to the environment.
Called by addActiveObject.
Object may be deleted by environment immediately.
If id of object is 0, assigns a free id to it.
Returns the id of the object.
Returns 0 if not added and thus deleted.
*/
u16 addActiveObjectRaw(ServerActiveObject *object, bool set_changed, u32 dtime_s);
/*
Remove all objects that satisfy (m_removed && m_known_by_count==0)
*/
void removeRemovedObjects();
/*
Convert stored objects from block to active
*/
void activateObjects(MapBlock *block, u32 dtime_s);
/*
Convert objects that are not in active blocks to static.
If m_known_by_count != 0, active object is not deleted, but static
data is still updated.
If force_delete is set, active object is deleted nevertheless. It
shall only be set so in the destructor of the environment.
*/
void deactivateFarObjects(bool force_delete);
/*
Member variables
*/
// The map
ServerMap *m_map;
// Lua state
lua_State *m_lua;
// Game definition
IGameDef *m_gamedef;
// Background block emerger (the server, in practice)
IBackgroundBlockEmerger *m_emerger;
// Active object list
std::map<u16, ServerActiveObject*> m_active_objects;
// Outgoing network message buffer for active objects
Queue<ActiveObjectMessage> m_active_object_messages;
// Some timers
float m_random_spawn_timer; // used for experimental code
float m_send_recommended_timer;
IntervalLimiter m_object_management_interval;
// List of active blocks
ActiveBlockList m_active_blocks;
IntervalLimiter m_active_blocks_management_interval;
IntervalLimiter m_active_block_modifier_interval;
IntervalLimiter m_active_blocks_nodemetadata_interval;
int m_active_block_interval_overload_skip;
// Time from the beginning of the game in seconds.
// Incremented in step().
u32 m_game_time;
// A helper variable for incrementing the latter
float m_game_time_fraction_counter;
std::list<ABMWithState> m_abms;
// An interval for generally sending object positions and stuff
float m_recommended_send_interval;
};
#ifndef SERVER
#include "clientobject.h"
class ClientSimpleObject;
/*
The client-side environment.
This is not thread-safe.
Must be called from main (irrlicht) thread (uses the SceneManager)
Client uses an environment mutex.
*/
enum ClientEnvEventType
{
CEE_NONE,
CEE_PLAYER_DAMAGE
};
struct ClientEnvEvent
{
ClientEnvEventType type;
union {
struct{
} none;
struct{
u8 amount;
bool send_to_server;
} player_damage;
};
};
class ClientEnvironment : public Environment
{
public:
ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr,
ITextureSource *texturesource, IGameDef *gamedef,
IrrlichtDevice *device);
~ClientEnvironment();
Map & getMap();
ClientMap & getClientMap();
IGameDef *getGameDef()
{ return m_gamedef; }
void step(f32 dtime);
virtual void addPlayer(Player *player);
LocalPlayer * getLocalPlayer();
/*
ClientSimpleObjects
*/
void addSimpleObject(ClientSimpleObject *simple);
/*
ActiveObjects
*/
ClientActiveObject* getActiveObject(u16 id);
/*
Adds an active object to the environment.
Environment handles deletion of object.
Object may be deleted by environment immediately.
If id of object is 0, assigns a free id to it.
Returns the id of the object.
Returns 0 if not added and thus deleted.
*/
u16 addActiveObject(ClientActiveObject *object);
void addActiveObject(u16 id, u8 type, const std::string &init_data);
void removeActiveObject(u16 id);
void processActiveObjectMessage(u16 id, const std::string &data);
/*
Callbacks for activeobjects
*/
void damageLocalPlayer(u8 damage, bool handle_hp=true);
/*
Client likes to call these
*/
// Get all nearby objects
void getActiveObjects(v3f origin, f32 max_d,
std::vector<DistanceSortedActiveObject> &dest);
// Get event from queue. CEE_NONE is returned if queue is empty.
ClientEnvEvent getClientEvent();
std::vector<core::vector2d<int> > attachment_list; // X is child ID, Y is parent ID
std::list<std::string> getPlayerNames()
{ return m_player_names; }
void addPlayerName(std::string name)
{ m_player_names.push_back(name); }
void removePlayerName(std::string name)
{ m_player_names.remove(name); }
private:
ClientMap *m_map;
scene::ISceneManager *m_smgr;
ITextureSource *m_texturesource;
IGameDef *m_gamedef;
IrrlichtDevice *m_irr;
std::map<u16, ClientActiveObject*> m_active_objects;
std::list<ClientSimpleObject*> m_simple_objects;
Queue<ClientEnvEvent> m_client_event_queue;
IntervalLimiter m_active_object_light_update_interval;
IntervalLimiter m_lava_hurt_interval;
std::list<std::string> m_player_names;
};
#endif
#endif
|
