-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathaddon_game_mode.lua
45 lines (39 loc) · 1.24 KB
/
addon_game_mode.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- Generated from template
require("config")
require("sandbox")
require("rounds")
require("commands")
if CAddonTemplateGameMode == nil then
CAddonTemplateGameMode = class({})
end
function Precache(context)
--[[
Precache things we know we'll use. Possible file types include (but not limited to):
PrecacheResource( "model", "*.vmdl", context )
PrecacheResource( "soundfile", "*.vsndevts", context )
PrecacheResource( "particle", "*.vpcf", context )
PrecacheResource( "particle_folder", "particles/folder", context )
]]
end
-- Create the game mode when we activate
function Activate()
GameRules.AddonTemplate = CAddonTemplateGameMode()
GameRules.AddonTemplate:InitGameMode()
print("Game Activate")
end
function CAddonTemplateGameMode:InitGameMode()
print( "Template addon is loaded." )
Rounds:InitGameMode()
local game_mode = GameRules:GetGameModeEntity()
game_mode:SetThink( "OnThink", self, "GlobalThink", 2 )
game_mode:SetFogOfWarDisabled(true)
end
-- Evaluate the state of the game
function CAddonTemplateGameMode:OnThink()
if GameRules:State_Get() == DOTA_GAMERULES_STATE_GAME_IN_PROGRESS then
Rounds:InitFromServerAndBeginGame()
elseif GameRules:State_Get() >= DOTA_GAMERULES_STATE_POST_GAME then
return nil
end
return 1
end