game_machine 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +72 -0
- data/Rakefile +38 -0
- data/bin/game_machine +79 -0
- data/config/cluster.conf +65 -0
- data/config/config.example.yml +93 -0
- data/config/game_messages.proto +45 -0
- data/config/messages.proto +339 -0
- data/config/regions.example.yml +9 -0
- data/config/standalone.conf +36 -0
- data/db/do_not_delete +0 -0
- data/game_machine.gemspec +38 -0
- data/games/example/boot.rb +6 -0
- data/games/example/data/game_data.yml +13 -0
- data/games/example/lib/aggressive_npc.rb +176 -0
- data/games/example/lib/authentication_handler.rb +69 -0
- data/games/example/lib/chatbot.rb +61 -0
- data/games/example/lib/combat_controller.rb +145 -0
- data/games/example/lib/example_controller.rb +21 -0
- data/games/example/lib/game.rb +85 -0
- data/games/example/lib/models/attack.rb +9 -0
- data/games/example/lib/models/combat_update.rb +11 -0
- data/games/example/lib/models/player_command.rb +7 -0
- data/games/example/lib/models/user.rb +11 -0
- data/games/example/lib/models/vitals.rb +17 -0
- data/games/example/lib/npc.rb +111 -0
- data/games/example/lib/npc_group.rb +42 -0
- data/games/example/lib/npc_movement.rb +116 -0
- data/games/example/lib/player_manager.rb +58 -0
- data/games/example/lib/player_register.rb +80 -0
- data/games/example/lib/tracking_handler.rb +17 -0
- data/games/example/lib/zone_manager.rb +57 -0
- data/games/preload.rb +8 -0
- data/integration_tests/basic_spec.rb +68 -0
- data/integration_tests/bot_spec.rb +18 -0
- data/integration_tests/chat_spec.rb +45 -0
- data/integration_tests/distributed_spec.rb +34 -0
- data/integration_tests/entity_tracking_spec.rb +48 -0
- data/integration_tests/mono_spec.rb +16 -0
- data/integration_tests/objectdb_spec.rb +55 -0
- data/integration_tests/tcp_client_spec.rb +71 -0
- data/integration_tests/udp_client_spec.rb +61 -0
- data/integration_tests/udp_spec.rb +20 -0
- data/integration_tests/udt_client_spec.rb +23 -0
- data/integration_tests/udt_spec.rb +31 -0
- data/java/.gitignore +1 -0
- data/java/build.gradle +93 -0
- data/java/component.erb +396 -0
- data/java/gradle.properties +6 -0
- data/java/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/java/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/java/gradlew +164 -0
- data/java/gradlew.bat +90 -0
- data/java/local_lib/protostuff-compiler-1.0.7-jarjar.jar +0 -0
- data/java/settings.gradle +2 -0
- data/java/src/main/java/com/game_machine/core/ActorFactory.java +25 -0
- data/java/src/main/java/com/game_machine/core/ActorUtil.java +39 -0
- data/java/src/main/java/com/game_machine/core/CommandProxy.java +9 -0
- data/java/src/main/java/com/game_machine/core/EntitySerializer.java +66 -0
- data/java/src/main/java/com/game_machine/core/EventStreamHandler.java +43 -0
- data/java/src/main/java/com/game_machine/core/GameMachineLoader.java +25 -0
- data/java/src/main/java/com/game_machine/core/Grid.java +195 -0
- data/java/src/main/java/com/game_machine/core/GridValue.java +30 -0
- data/java/src/main/java/com/game_machine/core/IActorFactory.java +7 -0
- data/java/src/main/java/com/game_machine/core/NetMessage.java +28 -0
- data/java/src/main/java/com/game_machine/core/UdpServer.java +97 -0
- data/java/src/main/java/com/game_machine/core/UdpServerHandler.java +90 -0
- data/java/src/main/resources/game_machine.java.stg +738 -0
- data/java/src/main/resources/logback.xml +14 -0
- data/java/src/main/resources/logging.properties +3 -0
- data/java/src/main/resources/protostuff.properties +7 -0
- data/lib/game_machine.rb +85 -0
- data/lib/game_machine/actor.rb +7 -0
- data/lib/game_machine/actor/base.rb +184 -0
- data/lib/game_machine/actor/builder.rb +108 -0
- data/lib/game_machine/actor/development.rb +31 -0
- data/lib/game_machine/actor/factory.rb +35 -0
- data/lib/game_machine/actor/mono_actor.rb +89 -0
- data/lib/game_machine/actor/ref.rb +81 -0
- data/lib/game_machine/actor/reloadable.rb +98 -0
- data/lib/game_machine/actor/system.rb +32 -0
- data/lib/game_machine/akka.rb +98 -0
- data/lib/game_machine/app_config.rb +49 -0
- data/lib/game_machine/application.rb +181 -0
- data/lib/game_machine/auth_handlers/base.rb +21 -0
- data/lib/game_machine/auth_handlers/public.rb +34 -0
- data/lib/game_machine/bot/chat.rb +66 -0
- data/lib/game_machine/bot/client.rb +54 -0
- data/lib/game_machine/client_manager.rb +204 -0
- data/lib/game_machine/clients.rb +4 -0
- data/lib/game_machine/clients/client.rb +45 -0
- data/lib/game_machine/clients/tcp_client.rb +25 -0
- data/lib/game_machine/clients/test_client.rb +151 -0
- data/lib/game_machine/clients/udp_client.rb +25 -0
- data/lib/game_machine/clients/udt_client.rb +34 -0
- data/lib/game_machine/cluster_monitor.rb +115 -0
- data/lib/game_machine/commands.rb +23 -0
- data/lib/game_machine/commands/base.rb +21 -0
- data/lib/game_machine/commands/chat_commands.rb +88 -0
- data/lib/game_machine/commands/datastore_commands.rb +60 -0
- data/lib/game_machine/commands/grid_commands.rb +35 -0
- data/lib/game_machine/commands/message_helper.rb +25 -0
- data/lib/game_machine/commands/misc_commands.rb +29 -0
- data/lib/game_machine/commands/navigation_commands.rb +24 -0
- data/lib/game_machine/commands/player_commands.rb +28 -0
- data/lib/game_machine/commands/proxy.rb +16 -0
- data/lib/game_machine/console.rb +3 -0
- data/lib/game_machine/console/build.rb +74 -0
- data/lib/game_machine/console/install.rb +92 -0
- data/lib/game_machine/console/server.rb +120 -0
- data/lib/game_machine/data_store.rb +52 -0
- data/lib/game_machine/data_stores/couchbase.rb +18 -0
- data/lib/game_machine/data_stores/mapdb.rb +49 -0
- data/lib/game_machine/data_stores/memory.rb +35 -0
- data/lib/game_machine/data_stores/redis.rb +46 -0
- data/lib/game_machine/endpoints.rb +6 -0
- data/lib/game_machine/endpoints/mono_gateway.rb +87 -0
- data/lib/game_machine/endpoints/tcp.rb +51 -0
- data/lib/game_machine/endpoints/tcp_handler.rb +75 -0
- data/lib/game_machine/endpoints/udp.rb +88 -0
- data/lib/game_machine/endpoints/udp_incoming.rb +113 -0
- data/lib/game_machine/endpoints/udp_outgoing.rb +46 -0
- data/lib/game_machine/game_loader.rb +46 -0
- data/lib/game_machine/game_systems.rb +14 -0
- data/lib/game_machine/game_systems/agents/controller.rb +118 -0
- data/lib/game_machine/game_systems/chat.rb +256 -0
- data/lib/game_machine/game_systems/chat_manager.rb +108 -0
- data/lib/game_machine/game_systems/chat_topic.rb +36 -0
- data/lib/game_machine/game_systems/devnull.rb +13 -0
- data/lib/game_machine/game_systems/entity_loader.rb +12 -0
- data/lib/game_machine/game_systems/entity_tracking.rb +133 -0
- data/lib/game_machine/game_systems/local_echo.rb +16 -0
- data/lib/game_machine/game_systems/objectdb_proxy.rb +61 -0
- data/lib/game_machine/game_systems/private_chat.rb +20 -0
- data/lib/game_machine/game_systems/region_manager.rb +91 -0
- data/lib/game_machine/game_systems/region_service.rb +94 -0
- data/lib/game_machine/game_systems/region_settings.rb +13 -0
- data/lib/game_machine/game_systems/remote_echo.rb +14 -0
- data/lib/game_machine/game_systems/stress_test.rb +21 -0
- data/lib/game_machine/grid.rb +60 -0
- data/lib/game_machine/grid_replicator.rb +31 -0
- data/lib/game_machine/handlers/authentication.rb +55 -0
- data/lib/game_machine/handlers/game.rb +63 -0
- data/lib/game_machine/handlers/request.rb +80 -0
- data/lib/game_machine/hashring.rb +48 -0
- data/lib/game_machine/helpers/game_message.rb +159 -0
- data/lib/game_machine/helpers/state_machine.rb +29 -0
- data/lib/game_machine/java_lib.rb +51 -0
- data/lib/game_machine/logger.rb +39 -0
- data/lib/game_machine/message_buffer.rb +58 -0
- data/lib/game_machine/message_queue.rb +63 -0
- data/lib/game_machine/model.rb +125 -0
- data/lib/game_machine/models.rb +3 -0
- data/lib/game_machine/models/player_status_update.rb +8 -0
- data/lib/game_machine/models/region.rb +9 -0
- data/lib/game_machine/mono_server.rb +20 -0
- data/lib/game_machine/navigation.rb +4 -0
- data/lib/game_machine/navigation/detour.rb +20 -0
- data/lib/game_machine/navigation/detour_navmesh.rb +53 -0
- data/lib/game_machine/navigation/detour_path.rb +53 -0
- data/lib/game_machine/navigation/path.rb +31 -0
- data/lib/game_machine/object_db.rb +67 -0
- data/lib/game_machine/protobuf.rb +6 -0
- data/lib/game_machine/protobuf/game_messages.rb +24 -0
- data/lib/game_machine/protobuf/generate.rb +113 -0
- data/lib/game_machine/protobuf_extensions/entity_helper.rb +11 -0
- data/lib/game_machine/reloadable_monitor.rb +26 -0
- data/lib/game_machine/restart_watcher.rb +17 -0
- data/lib/game_machine/ruby_extensions/nilclass.rb +10 -0
- data/lib/game_machine/ruby_extensions/string.rb +17 -0
- data/lib/game_machine/scheduler.rb +23 -0
- data/lib/game_machine/securerandom.rb +6 -0
- data/lib/game_machine/settings.rb +11 -0
- data/lib/game_machine/system_monitor.rb +19 -0
- data/lib/game_machine/system_stats.rb +24 -0
- data/lib/game_machine/uniqueid.rb +23 -0
- data/lib/game_machine/vector.rb +95 -0
- data/lib/game_machine/version.rb +3 -0
- data/lib/game_machine/write_behind_cache.rb +164 -0
- data/mono/bin/csharp/common.xslt +109 -0
- data/mono/bin/csharp/csharp.xslt +628 -0
- data/mono/bin/csharp/descriptor.proto +533 -0
- data/mono/bin/csharp/protobuf-net.dll +0 -0
- data/mono/bin/csharp/protobuf-net.pdb +0 -0
- data/mono/bin/csharp/protobuf-net.xml +2879 -0
- data/mono/bin/csharp/protogen.exe.config +3 -0
- data/mono/bin/csharp/protogen.pdb +0 -0
- data/mono/bin/csharp/protogen_csharp.exe +0 -0
- data/mono/bin/csharp/vb.xslt +745 -0
- data/mono/bin/csharp/xml.xslt +26 -0
- data/mono/server/Makefile +6 -0
- data/mono/server/NLog.config +12 -0
- data/mono/server/NLog.dll +0 -0
- data/mono/server/actor.cs +37 -0
- data/mono/server/build.bat +3 -0
- data/mono/server/cscompmgd.dll +0 -0
- data/mono/server/iactor.cs +11 -0
- data/mono/server/message_router.cs +67 -0
- data/mono/server/message_util.cs +29 -0
- data/mono/server/messages.cs +1888 -0
- data/mono/server/protobuf-net.dll +0 -0
- data/mono/server/proxy_client.cs +73 -0
- data/mono/server/proxy_server.cs +30 -0
- data/mono/server/test_actor.cs +33 -0
- data/pathfinding/bin/premake4 +0 -0
- data/pathfinding/include/mesh_loader.h +28 -0
- data/pathfinding/include/pathfind.h +167 -0
- data/pathfinding/main.cpp +39 -0
- data/pathfinding/mesh_loader.cpp +108 -0
- data/pathfinding/pathfind.cpp +174 -0
- data/pathfinding/pathfinder.cs +66 -0
- data/pathfinding/premake4.lua +109 -0
- data/script/server.sh +109 -0
- data/script/watch.sh +11 -0
- data/spec/actor/actor_spec.rb +73 -0
- data/spec/actor/builder_spec.rb +56 -0
- data/spec/actor/ref_spec.rb +83 -0
- data/spec/application_spec.rb +7 -0
- data/spec/client_manager_spec.rb +171 -0
- data/spec/commands/chat_commands_spec.rb +38 -0
- data/spec/commands/datastore_commands_spec.rb +91 -0
- data/spec/commands/grid_commands_spec.rb +37 -0
- data/spec/commands/navigation_commands_spec.rb +51 -0
- data/spec/commands/player_commands_spec.rb +48 -0
- data/spec/commands_spec.rb +38 -0
- data/spec/data_stores/mapdb_spec.rb +46 -0
- data/spec/data_stores/redis_spec.rb +44 -0
- data/spec/game_systems/agents/controller_spec.rb +84 -0
- data/spec/game_systems/agents/test_agent.rb +10 -0
- data/spec/game_systems/agents/test_agent_config.rb +29 -0
- data/spec/game_systems/chat_manager_spec.rb +66 -0
- data/spec/game_systems/chat_spec.rb +187 -0
- data/spec/game_systems/entity_tracking_spec.rb +64 -0
- data/spec/game_systems/region_manager_spec.rb +138 -0
- data/spec/grid_spec.rb +37 -0
- data/spec/handlers/authentication_spec.rb +36 -0
- data/spec/handlers/game_spec.rb +49 -0
- data/spec/handlers/request_spec.rb +65 -0
- data/spec/hashring_spec.rb +59 -0
- data/spec/integration_helper.rb +120 -0
- data/spec/java_grid_spec.rb +89 -0
- data/spec/message_buffer_spec.rb +67 -0
- data/spec/message_expectations.rb +47 -0
- data/spec/message_queue_spec.rb +23 -0
- data/spec/misc_spec.rb +71 -0
- data/spec/model_spec.rb +103 -0
- data/spec/mono_spec.rb +36 -0
- data/spec/mono_test.rb +18 -0
- data/spec/navigation/detour_navmesh_spec.rb +34 -0
- data/spec/navigation/detour_path_spec.rb +25 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/udp_server_spec.rb +10 -0
- data/spec/write_behind_cache_spec.rb +109 -0
- data/web/app.rb +131 -0
- data/web/config/trinidad.yml +4 -0
- data/web/controllers/auth_controller.rb +19 -0
- data/web/controllers/base_controller.rb +16 -0
- data/web/controllers/index_controller.rb +7 -0
- data/web/controllers/log_controller.rb +47 -0
- data/web/controllers/messages_controller.rb +59 -0
- data/web/controllers/player_register_controller.rb +15 -0
- data/web/log/development.log +1339 -0
- data/web/tmp/restart.txt +0 -0
- data/web/views/game_messages.haml +45 -0
- data/web/views/index.haml +6 -0
- data/web/views/layout.haml +41 -0
- data/web/views/logs.haml +32 -0
- data/web/views/player_register.haml +22 -0
- data/web/views/player_registered.haml +2 -0
- data/web/views/register_layout.haml +22 -0
- data/web/views/restart.haml +35 -0
- metadata +576 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
module GameMachine
|
2
|
+
module Commands
|
3
|
+
class ChatCommands
|
4
|
+
include MessageHelper
|
5
|
+
|
6
|
+
def send_private_message(text,player_id)
|
7
|
+
message = chat_message('private',text,player_id,player_id)
|
8
|
+
entity = entity_with_player(player_id,player_id).
|
9
|
+
set_chat_message(message.chat_message)
|
10
|
+
GameSystems::ChatManager.find.tell(entity)
|
11
|
+
end
|
12
|
+
|
13
|
+
def send_group_message(topic,text,player_id)
|
14
|
+
message = chat_message('group',text,topic,player_id)
|
15
|
+
entity = entity_with_player(player_id,player_id).
|
16
|
+
set_chat_message(message.chat_message)
|
17
|
+
GameSystems::ChatManager.find.tell(entity)
|
18
|
+
end
|
19
|
+
|
20
|
+
def register(chat_id,register_as)
|
21
|
+
message = entity(chat_id).set_chat_register(
|
22
|
+
MessageLib::ChatRegister.new.set_chat_id(chat_id).
|
23
|
+
set_register_as(register_as)
|
24
|
+
)
|
25
|
+
GameSystems::ChatManager.find.tell(message)
|
26
|
+
end
|
27
|
+
|
28
|
+
def join(topic,player_id,invite_id=nil)
|
29
|
+
GameSystems::ChatManager.find.tell(join_message(topic,player_id,invite_id))
|
30
|
+
end
|
31
|
+
|
32
|
+
def leave(topic,player_id)
|
33
|
+
GameSystems::ChatManager.find.tell(leave_message(topic,player_id))
|
34
|
+
end
|
35
|
+
|
36
|
+
def invite(topic,inviter,invitee)
|
37
|
+
GameSystems::ChatManager.find.tell(invite_message(inviter,invitee,topic))
|
38
|
+
end
|
39
|
+
|
40
|
+
def subscribers(topic)
|
41
|
+
GameMachine::GameSystems::Chat.subscribers_for_topic(topic)
|
42
|
+
end
|
43
|
+
|
44
|
+
def invite_message(inviter,invitee,topic)
|
45
|
+
entity_with_player(inviter,inviter).set_chat_invite(
|
46
|
+
MessageLib::ChatInvite.new.set_inviter(inviter).
|
47
|
+
set_invitee(invitee).set_channel_name(topic)
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def join_message(topic,player_id,invite_id=nil)
|
52
|
+
join_msg = MessageLib::JoinChat.new
|
53
|
+
chat_channel = chat_channel(topic)
|
54
|
+
if invite_id
|
55
|
+
chat_channel.set_invite_id(invite_id)
|
56
|
+
end
|
57
|
+
join_msg.add_chat_channel(chat_channel)
|
58
|
+
entity_with_player(player_id,player_id).set_join_chat(join_msg)
|
59
|
+
end
|
60
|
+
|
61
|
+
def leave_message(topic,player_id)
|
62
|
+
entity_with_player(player_id,player_id).set_leave_chat(
|
63
|
+
MessageLib::LeaveChat.new.add_chat_channel(chat_channel(topic))
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def chat_message(type,message_text,topic,sender_id=nil)
|
68
|
+
chat_message = MessageLib::ChatMessage.new.set_chat_channel(
|
69
|
+
chat_channel(topic)
|
70
|
+
).set_message(message_text).set_type(type)
|
71
|
+
|
72
|
+
if sender_id
|
73
|
+
chat_message.set_sender_id(sender_id)
|
74
|
+
end
|
75
|
+
entity(entity_id).set_chat_message(chat_message)
|
76
|
+
end
|
77
|
+
|
78
|
+
def entity_id
|
79
|
+
'0'
|
80
|
+
end
|
81
|
+
|
82
|
+
def chat_channel(topic)
|
83
|
+
MessageLib::ChatChannel.new.set_name(topic)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module GameMachine
|
2
|
+
module Commands
|
3
|
+
class DatastoreCommands
|
4
|
+
|
5
|
+
attr_reader :store
|
6
|
+
def initialize
|
7
|
+
@store = DataStore.instance
|
8
|
+
end
|
9
|
+
|
10
|
+
def define_dbproc(name,&blk)
|
11
|
+
ObjectDb.dbprocs[name] = blk
|
12
|
+
end
|
13
|
+
|
14
|
+
def call_dbproc(name,current_entity_id,update_entity,blocking=true)
|
15
|
+
ref = ObjectDb.find_distributed(current_entity_id)
|
16
|
+
message = MessageLib::ObjectdbUpdate.new.
|
17
|
+
set_current_entity_id(current_entity_id).
|
18
|
+
set_update_method(name).
|
19
|
+
set_update_entity(update_entity)
|
20
|
+
if blocking
|
21
|
+
ref.ask(message, 100)
|
22
|
+
else
|
23
|
+
ref.tell(message)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def put!(entity)
|
28
|
+
store.set(entity.id,entity.to_byte_array)
|
29
|
+
end
|
30
|
+
|
31
|
+
def get!(entity_id)
|
32
|
+
if bytes = store.get(entity_id)
|
33
|
+
MessageLib::Entity.parse_from(bytes)
|
34
|
+
else
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def del!(entity_id)
|
40
|
+
store.delete(entity_id)
|
41
|
+
end
|
42
|
+
|
43
|
+
def put(entity)
|
44
|
+
ref = ObjectDb.find_distributed(entity.get_id)
|
45
|
+
ref.tell(MessageLib::ObjectdbPut.new.set_entity(entity))
|
46
|
+
end
|
47
|
+
|
48
|
+
def get(entity_id,timeout=1000)
|
49
|
+
ref = ObjectDb.find_distributed(entity_id)
|
50
|
+
ref.ask(MessageLib::ObjectdbGet.new.set_entity_id(entity_id), timeout)
|
51
|
+
end
|
52
|
+
|
53
|
+
def delete(entity_id)
|
54
|
+
ref = ObjectDb.find_distributed(entity_id)
|
55
|
+
ref.tell(MessageLib::ObjectdbDel.new.set_entity_id(entity_id))
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module GameMachine
|
2
|
+
module Commands
|
3
|
+
class GridCommands
|
4
|
+
|
5
|
+
attr_reader :aoe_grid, :grid
|
6
|
+
def initialize
|
7
|
+
@aoe_grid = Grid.find_or_create('aoe')
|
8
|
+
@grid = Grid.find_or_create('default')
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_by_id(id)
|
12
|
+
grid.get(id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_neighbors_for(id,entity_type='player')
|
16
|
+
grid.getNeighborsFor(id,entity_type)
|
17
|
+
end
|
18
|
+
|
19
|
+
def neighbors(x,y,type='player')
|
20
|
+
grid.neighbors(x,y,type)
|
21
|
+
end
|
22
|
+
|
23
|
+
def remove(id)
|
24
|
+
grid.remove(id)
|
25
|
+
aoe_grid.remove(id)
|
26
|
+
end
|
27
|
+
|
28
|
+
def track(id,x,y,z,entity_type='npc')
|
29
|
+
grid.set(id,x,y,z,entity_type)
|
30
|
+
aoe_grid.set(id,x,y,z,entity_type)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module GameMachine
|
2
|
+
module Commands
|
3
|
+
module MessageHelper
|
4
|
+
def entity(id)
|
5
|
+
MessageLib::Entity.new.set_id(id)
|
6
|
+
end
|
7
|
+
|
8
|
+
def entity_with_player(id,player_id)
|
9
|
+
entity(id).set_player(MessageLib::Player.new.set_id(player_id))
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_player(entity,player_id)
|
13
|
+
entity.set_player(MessageLib::Player.new.set_id(player_id))
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_component?(obj)
|
17
|
+
obj.respond_to?(:message_name)
|
18
|
+
end
|
19
|
+
|
20
|
+
def is_entity?(obj)
|
21
|
+
obj.is_a?(MessageLib::Entity)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module GameMachine
|
2
|
+
module Commands
|
3
|
+
class MiscCommands
|
4
|
+
|
5
|
+
attr_reader :player_manager
|
6
|
+
def initialize
|
7
|
+
@player_manager = Application.config.player_manager
|
8
|
+
end
|
9
|
+
|
10
|
+
def player_status_change(player_id,status)
|
11
|
+
if player_manager
|
12
|
+
update = Models::PlayerStatusUpdate.new(:player_id => player_id,:status => status)
|
13
|
+
Actor::Base.find(player_manager).tell(update)
|
14
|
+
else
|
15
|
+
GameMachine.logger.info "player manager not defined."
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def client_manager_register(name,events=[])
|
20
|
+
register = MessageLib::ClientManagerRegister.new.
|
21
|
+
set_register_type('actor').set_name(name).set_events(events.join('|'))
|
22
|
+
entity = MessageLib::Entity.new.set_id(name).
|
23
|
+
set_client_manager_register(register)
|
24
|
+
ClientManager.find.ask(entity,5000)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module GameMachine
|
2
|
+
module Commands
|
3
|
+
class NavigationCommands
|
4
|
+
|
5
|
+
def load_navmesh(id,path)
|
6
|
+
if File.exists?(path)
|
7
|
+
navmesh = GameMachine::Navigation::DetourNavmesh.create(id,path)
|
8
|
+
navmesh.load_mesh!
|
9
|
+
return navmesh
|
10
|
+
else
|
11
|
+
raise "Meshfile #{path} does not exist"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def navmesh(id)
|
16
|
+
GameMachine::Navigation::DetourNavmesh.find(1)
|
17
|
+
end
|
18
|
+
|
19
|
+
def query_ref(navmesh_id)
|
20
|
+
GameMachine::Navigation::DetourPath.query_ref(navmesh_id)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GameMachine
|
2
|
+
module Commands
|
3
|
+
class PlayerCommands
|
4
|
+
include MessageHelper
|
5
|
+
|
6
|
+
def send_message(message,player_id)
|
7
|
+
if is_entity?(message)
|
8
|
+
entity = message
|
9
|
+
unless entity.has_player
|
10
|
+
set_player(entity,player_id)
|
11
|
+
end
|
12
|
+
elsif message.kind_of?(GameMachine::Model)
|
13
|
+
entity = entity_with_player(player_id,player_id)
|
14
|
+
entity.set_json_entity(message.to_json_entity)
|
15
|
+
else
|
16
|
+
entity = entity_with_player(player_id,player_id)
|
17
|
+
if is_component?(message)
|
18
|
+
entity.add_component(message)
|
19
|
+
else
|
20
|
+
raise "#{message} is not a valid object to send to a player"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
entity.set_send_to_player(true)
|
24
|
+
ClientManager.send_to_player(entity)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require_relative '../settings'
|
3
|
+
module GameMachine
|
4
|
+
module Console
|
5
|
+
class Build
|
6
|
+
|
7
|
+
attr_reader :command
|
8
|
+
def initialize(argv)
|
9
|
+
@command = argv.shift || ''
|
10
|
+
end
|
11
|
+
|
12
|
+
def java_root
|
13
|
+
ENV['JAVA_ROOT']
|
14
|
+
end
|
15
|
+
|
16
|
+
def java_lib
|
17
|
+
File.join(java_root,'lib')
|
18
|
+
end
|
19
|
+
|
20
|
+
def gradlew
|
21
|
+
File.join(java_root,'gradlew')
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_code
|
25
|
+
system("cd #{java_root} && #{gradlew} build")
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate_csharp_code
|
29
|
+
protogen_path = File.join(ENV['APP_ROOT'],'mono','bin','csharp','protogen_csharp.exe')
|
30
|
+
proto_file = File.join(ENV['APP_ROOT'],'config','combined_messages.proto')
|
31
|
+
messages_out_file = File.join(ENV['APP_ROOT'],'messages.cs')
|
32
|
+
cmd = "#{protogen_path} -i:#{proto_file} -o:#{messages_out_file}"
|
33
|
+
puts "Running #{cmd}"
|
34
|
+
system(cmd)
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_java_code
|
38
|
+
protogen = GameMachine::Protobuf::Generate.new(ENV['APP_ROOT'])
|
39
|
+
protogen.generate
|
40
|
+
end
|
41
|
+
|
42
|
+
def generate_code
|
43
|
+
generate_java_code
|
44
|
+
if Config::CONFIG['target_os'].match(/mswin/)
|
45
|
+
generate_csharp_code
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def remove_libs
|
50
|
+
FileUtils.rm Dir.glob(File.join(java_lib,'*.jar'))
|
51
|
+
end
|
52
|
+
|
53
|
+
def install_libs
|
54
|
+
system("cd #{java_root} && #{gradlew} install_libs")
|
55
|
+
end
|
56
|
+
|
57
|
+
def run!
|
58
|
+
if command == 'code'
|
59
|
+
build_code
|
60
|
+
remove_libs
|
61
|
+
install_libs
|
62
|
+
elsif command == 'messages'
|
63
|
+
generate_code
|
64
|
+
else
|
65
|
+
generate_code
|
66
|
+
build_code
|
67
|
+
remove_libs
|
68
|
+
install_libs
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module GameMachine
|
2
|
+
module Console
|
3
|
+
class Install
|
4
|
+
|
5
|
+
attr_reader :install_path, :help, :install_source_path
|
6
|
+
def initialize(argv,install_source_path)
|
7
|
+
@install_source_path = install_source_path
|
8
|
+
@install_path = argv.shift
|
9
|
+
if argv.find {|v| /--help/ =~ v}
|
10
|
+
@help = true
|
11
|
+
end
|
12
|
+
puts "Installing from #{install_source_path}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def error(reason='')
|
16
|
+
puts "Invalid install path #{install_path} (#{reason})"
|
17
|
+
end
|
18
|
+
|
19
|
+
def valid_input?
|
20
|
+
end
|
21
|
+
|
22
|
+
def run!
|
23
|
+
if help
|
24
|
+
show_help
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
if install_path.nil? || install_path.empty?
|
29
|
+
error("Invalid input")
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
|
+
if File.exists?(install_path)
|
34
|
+
error("Directory exists")
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
@install_path = File.expand_path(install_path)
|
39
|
+
install
|
40
|
+
end
|
41
|
+
|
42
|
+
def show_help
|
43
|
+
puts "new [install directory]"
|
44
|
+
end
|
45
|
+
|
46
|
+
def valid_install_path?
|
47
|
+
if File.exists?(install_path)
|
48
|
+
false
|
49
|
+
else
|
50
|
+
true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def install
|
55
|
+
puts "Installing into #{install_path}"
|
56
|
+
path = File.expand_path(install_path)
|
57
|
+
FileUtils.mkdir(path)
|
58
|
+
FileUtils.cp_r(config_source,path)
|
59
|
+
FileUtils.cp_r(games_source,path)
|
60
|
+
FileUtils.cp_r(java_source,path)
|
61
|
+
FileUtils.cp_r(script_source,path)
|
62
|
+
FileUtils.cp_r(mono_source,path)
|
63
|
+
FileUtils.cp_r(db_source,path)
|
64
|
+
end
|
65
|
+
|
66
|
+
def db_source
|
67
|
+
File.join(install_source_path,'db')
|
68
|
+
end
|
69
|
+
|
70
|
+
def mono_source
|
71
|
+
File.join(install_source_path,'mono')
|
72
|
+
end
|
73
|
+
|
74
|
+
def script_source
|
75
|
+
File.join(install_source_path,'script')
|
76
|
+
end
|
77
|
+
|
78
|
+
def config_source
|
79
|
+
File.join(install_source_path,'config')
|
80
|
+
end
|
81
|
+
|
82
|
+
def games_source
|
83
|
+
File.join(install_source_path,'games')
|
84
|
+
end
|
85
|
+
|
86
|
+
def java_source
|
87
|
+
File.join(install_source_path,'java')
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|