Major refactor to include tactical combat feed
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
require("PGBase")
|
||||
require("GameManager/Constants")
|
||||
require("GameManager/GUIManager")
|
||||
require("GameManager/GalacticGameClass")
|
||||
require("GameManager/TacticalGameClass")
|
||||
require("GameManager/SkirmishGameClass")
|
||||
@@ -15,25 +14,14 @@ local DebugCounter = 0
|
||||
---Debugging service rate.
|
||||
local ServiceDebugRate = 5
|
||||
|
||||
---The Local Player FoC PlayerWrapper object.
|
||||
local LocalPlayer = nil
|
||||
|
||||
---The GUI Manager.
|
||||
---@type GUIManager
|
||||
local GUIManager = GUIManager:New()
|
||||
|
||||
---The Galactic Game manager.
|
||||
---@type GalacticGameClass|nil
|
||||
local GalacticGame = nil
|
||||
|
||||
---The Tactical Game manager.
|
||||
---@type TacticalGameClass|nil
|
||||
---@type TacticalGameClass|SkirmishGameClass|nil
|
||||
local TacticalGame = nil
|
||||
|
||||
---The Skirmish Game manager.
|
||||
---@type SkirmishGameClass|nil
|
||||
local SkirmishGame = nil
|
||||
|
||||
-- ==================================================
|
||||
-- Script Globals
|
||||
-- ==================================================
|
||||
@@ -59,7 +47,6 @@ function Base_Definitions()
|
||||
DebugMessage("%s -- In Base_Definitions.", tostring(Script))
|
||||
|
||||
DebugCounter = 0
|
||||
LocalPlayer = Find_Player("local")
|
||||
end
|
||||
|
||||
---Main script function. Does event pumps and servicing.
|
||||
@@ -88,18 +75,10 @@ function GameService()
|
||||
|
||||
if GalacticGame then
|
||||
GalacticGame:Service()
|
||||
|
||||
if TacticalGame then
|
||||
TacticalGame:Service()
|
||||
end
|
||||
end
|
||||
|
||||
if SkirmishGame then
|
||||
SkirmishGame:Service()
|
||||
end
|
||||
|
||||
if GUIManager then
|
||||
GUIManager:Service()
|
||||
if TacticalGame then
|
||||
TacticalGame:Service()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -142,6 +121,8 @@ end
|
||||
function Game_Mode_Starting_Event(mode, map)
|
||||
DebugMessage("%s -- Game Mode %s (%s) now starting.", tostring(Script), mode, map)
|
||||
|
||||
LocalPlayer = Find_Player("local")
|
||||
|
||||
if StringCompare(mode, "Galactic") then
|
||||
-- Galactic Campaign
|
||||
Init_Galactic()
|
||||
@@ -169,10 +150,12 @@ function Game_Mode_Ending_Event(oldMode)
|
||||
-- Skirmish mode ending
|
||||
Reset_Skirmish()
|
||||
end
|
||||
|
||||
LocalPlayer = nil
|
||||
end
|
||||
|
||||
---This event is triggered when a player quits the game.
|
||||
---@param player table FoC PlayerWrapper object that just quit.
|
||||
---@param player PlayerObject FoC PlayerWrapper object that just quit.
|
||||
function Player_Quit_Event(player)
|
||||
DebugMessage("%s -- Player %s (%d) has quit.", tostring(Script), player.Get_Name(), player.Get_ID())
|
||||
|
||||
@@ -182,9 +165,9 @@ function Player_Quit_Event(player)
|
||||
end
|
||||
|
||||
---This event is triggered when production has finished in a tactical mode
|
||||
---@param objectType table FoC GameObjectTypeWrapper object that was just built.
|
||||
---@param player table FoC PlayerWrapper object that built the object.
|
||||
---@param location table|nil FoC GameObjectWrapper of the planet.
|
||||
---@param objectType GameObjectType FoC GameObjectTypeWrapper object that was just built.
|
||||
---@param player PlayerObject FoC PlayerWrapper object that built the object.
|
||||
---@param location PlanetObject|nil FoC GameObjectWrapper of the planet.
|
||||
function Tactical_Production_End_Event(objectType, player, location)
|
||||
if location then
|
||||
DebugMessage("%s -- Tactical production of unit %s by %s ended at %s.", tostring(Script), objectType.Get_Name(),
|
||||
@@ -201,20 +184,20 @@ function Tactical_Production_End_Event(objectType, player, location)
|
||||
end
|
||||
|
||||
---This event is triggered when a unit is destroyed in tactical mode.
|
||||
---@param object table FoC GameObjectWrapper object that was just killed.
|
||||
---@param killer table FoC PlayerWrapper object that killed the object.
|
||||
---@param object GameObject FoC GameObjectWrapper object that was just killed.
|
||||
---@param killer PlayerObject FoC PlayerWrapper object that killed the object.
|
||||
function Tactical_Unit_Destroyed_Event(object, killer)
|
||||
DebugMessage("%s -- Tactical unit %s destroyed by %s.", tostring(Script), object.Get_Type().Get_Name(),
|
||||
killer.Get_Name())
|
||||
|
||||
if TacticalGame then
|
||||
TacticalGame:UnitKilled(object)
|
||||
TacticalGame:UnitKilled(object, killer)
|
||||
end
|
||||
end
|
||||
|
||||
---This event is triggered when production has begun on an item at a given planet.
|
||||
---@param planet table FoC GameObjectWrapper object of the planet.
|
||||
---@param objectType table FoC GameObjectTypeWrapper object that was just queued.
|
||||
---@param planet PlanetObject FoC GameObjectWrapper object of the planet.
|
||||
---@param objectType GameObjectType FoC GameObjectTypeWrapper object that was just queued.
|
||||
function Galactic_Production_Begin_Event(planet, objectType)
|
||||
DebugMessage("%s -- Galactic production of %s started at %s.", tostring(Script), objectType.Get_Name(),
|
||||
planet.Get_Type().Get_Name())
|
||||
@@ -222,16 +205,16 @@ end
|
||||
|
||||
---This event is triggered when production has been prematurely canceled
|
||||
---on an item at a given planet.
|
||||
---@param planet table FoC GameObjectWrapper object of the planet.
|
||||
---@param objectType table FoC GameObjectTypeWrapper object that was just canceled..
|
||||
---@param planet PlanetObject FoC GameObjectWrapper object of the planet.
|
||||
---@param objectType GameObjectType FoC GameObjectTypeWrapper object that was just canceled..
|
||||
function Galactic_Production_Canceled_Event(planet, objectType)
|
||||
DebugMessage("%s -- Galactic production of %s canceled at %s.", tostring(Script), objectType.Get_Name(),
|
||||
planet.Get_Type().Get_Name())
|
||||
end
|
||||
|
||||
---This event is triggered when production has finished on an item at a given planet.
|
||||
---@param planet table FoC GameObjectWrapper or of the planet.
|
||||
---@param object table FoC GameObjectWrapper or GameObjectTypeWrapper of the object that was just created.
|
||||
---@param planet PlanetObject FoC GameObjectWrapper or of the planet.
|
||||
---@param object GameObject|GameObjectType FoC GameObjectWrapper or GameObjectTypeWrapper of the object that was just created.
|
||||
function Galactic_Production_End_Event(planet, object)
|
||||
local typeName = ""
|
||||
|
||||
@@ -249,16 +232,16 @@ function Galactic_Production_End_Event(planet, object)
|
||||
end
|
||||
|
||||
---This event is triggered when a unit is destroyed in galactic mode.
|
||||
---@param object table FoC GameObjectWrapper object that was just killed.
|
||||
---@param killer table FoC PlayerWrapper object that killed the object.
|
||||
---@param object GameObject FoC GameObjectWrapper object that was just killed.
|
||||
---@param killer PlayerObject FoC PlayerWrapper object that killed the object.
|
||||
function Galactic_Unit_Destroyed_Event(object, killer)
|
||||
DebugMessage("%s -- Object %s killed by %s.", tostring(Script), object.Get_Type().Get_Name(), killer.Get_Name())
|
||||
end
|
||||
|
||||
---This event is triggered when the level of a starbase changes.
|
||||
---@param planet table FoC GameObjectWrapper object of the planet.
|
||||
---@param oldType table FoC GameObjectTypeWrapper object of the old starbase type.
|
||||
---@param newType table FoC GameObjectTypeWrapper object of the new starbase type.
|
||||
---@param planet PlanetObject FoC GameObjectWrapper object of the planet.
|
||||
---@param oldType GameObjectType FoC GameObjectTypeWrapper object of the old starbase type.
|
||||
---@param newType GameObjectType FoC GameObjectTypeWrapper object of the new starbase type.
|
||||
function Galactic_Starbase_Level_Change(planet, oldType, newType)
|
||||
DebugMessage("%s -- %s Starbase changed from %s to %s.", tostring(Script), planet.Get_Type().Get_Name(),
|
||||
tostring(oldType), tostring(newType))
|
||||
@@ -295,9 +278,9 @@ function Galactic_Starbase_Level_Change(planet, oldType, newType)
|
||||
end
|
||||
|
||||
---This event is called when a planet changes faction in galactic mode.
|
||||
---@param planet table FoC GameObjectWrapper object of the planet.
|
||||
---@param newOwner table FoC PlayerWrapper of the new owner.
|
||||
---@param oldOwner table FoC PlayerWrapper of the old owner.
|
||||
---@param planet PlanetObject FoC GameObjectWrapper object of the planet.
|
||||
---@param newOwner PlayerObject FoC PlayerWrapper of the new owner.
|
||||
---@param oldOwner PlayerObject FoC PlayerWrapper of the old owner.
|
||||
function Galactic_Planet_Faction_Change(planet, newOwner, oldOwner)
|
||||
local planetName = planet.Get_Type().Get_Name()
|
||||
|
||||
@@ -306,8 +289,8 @@ function Galactic_Planet_Faction_Change(planet, newOwner, oldOwner)
|
||||
end
|
||||
|
||||
---This event is called when a hero is neutralized by another hero in galactic mode.
|
||||
---@param heroType table FoC GameObjectTypeWrapper object for the neutralized hero type.
|
||||
---@param killer table FoC GameObjectWrapper object that killed the hero.
|
||||
---@param heroType GameObjectType FoC GameObjectTypeWrapper object for the neutralized hero type.
|
||||
---@param killer GameObject FoC GameObjectWrapper object that killed the hero.
|
||||
function Galactic_Neutralized_Event(heroType, killer)
|
||||
DebugMessage("%s -- Hero %s killed by %s.", tostring(Script), heroType.Get_Name(), killer.Get_Owner().Get_Name())
|
||||
end
|
||||
@@ -317,23 +300,23 @@ end
|
||||
--- ==================================================
|
||||
|
||||
---Returns the number of frags by player for the given object type.
|
||||
---@param objectType table FoC GameObjectTypeWrapper object to query.
|
||||
---@param player table FoC PlayerWrapper object to query.
|
||||
---@param objectType GameObjectType FoC GameObjectTypeWrapper object to query.
|
||||
---@param player PlayerObject FoC PlayerWrapper object to query.
|
||||
---@return integer
|
||||
function Get_Frag_Count_For_Type(objectType, player)
|
||||
return 0
|
||||
end
|
||||
|
||||
---Returns the number of heroes neutralized by player for the given object type.
|
||||
---@param objectType table FoC GameObjectTypeWrapper object to query.
|
||||
---@param player table FoC PlayerWrapper object to query.
|
||||
---@param objectType GameObjectType FoC GameObjectTypeWrapper object to query.
|
||||
---@param player PlayerObject FoC PlayerWrapper object to query.
|
||||
---@return integer
|
||||
function Get_Neutralized_Count_For_Type(objectType, player)
|
||||
return 0
|
||||
end
|
||||
|
||||
---Returns a game stat for the provided control ID.
|
||||
---@param player table FoC PlayerWrapper object to query.
|
||||
---@param player PlayerObject FoC PlayerWrapper object to query.
|
||||
---@param controlId string The Control ID.
|
||||
---@param isTactical boolean Whether the game mode was a tactical mode.
|
||||
---@return number|string
|
||||
@@ -377,7 +360,8 @@ function Update_GameSpy_Game_Stats()
|
||||
end
|
||||
|
||||
---Updates the GameSpy player stats table
|
||||
---@param player table FoC PlayerWrapper object.
|
||||
---@param player PlayerObject FoC PlayerWrapper object.
|
||||
---@deprecated
|
||||
function Update_GameSpy_Player_Stats(player)
|
||||
GameSpy_Player_Stats = {}
|
||||
end
|
||||
@@ -410,7 +394,9 @@ function Init_Tactical(gameMode)
|
||||
DebugMessage("%s -- Initializing Tactical %s rules.", tostring(Script), gameMode)
|
||||
Reset_Tactical_Stats()
|
||||
TacticalGame = TacticalGameClass:New(gameMode)
|
||||
GUIManager:InitTactical(TacticalGame)
|
||||
GUIManager:InitTactical()
|
||||
TextManager:RegisterView(TacticalGame.CombatFeed)
|
||||
TextManager:SetCurrentView("combat_feed")
|
||||
end
|
||||
|
||||
---Resets Tactical mode.
|
||||
@@ -419,6 +405,7 @@ function Reset_Tactical()
|
||||
Reset_Tactical_Stats()
|
||||
TacticalGame = nil
|
||||
GUIManager:Reset()
|
||||
TextManager:Reset()
|
||||
end
|
||||
|
||||
--- ==================================================
|
||||
@@ -428,18 +415,19 @@ end
|
||||
---Initializes Skirmish mode.
|
||||
---@param gameMode string The tactical game mode.
|
||||
function Init_Skirmish(gameMode)
|
||||
DebugMessage("%s -- Initializing Skirmish Tacitcal %s rules.", tostring(Script), gameMode)
|
||||
DebugMessage("%s -- Initializing Skirmish Tactical %s rules.", tostring(Script), gameMode)
|
||||
Reset_Stats()
|
||||
SkirmishGame = SkirmishGameClass:New(gameMode)
|
||||
TacticalGame = SkirmishGame.TacticalGame
|
||||
GUIManager:InitSkirmish(SkirmishGame)
|
||||
TacticalGame = SkirmishGameClass:New(gameMode)
|
||||
GUIManager:InitSkirmish(TacticalGame.IsLocalSpectator)
|
||||
TextManager:RegisterView(TacticalGame.CombatFeed)
|
||||
TextManager:SetCurrentView("combat_feed")
|
||||
end
|
||||
|
||||
---Resets Skirmish mode.
|
||||
function Reset_Skirmish()
|
||||
DebugMessage("%s -- Resetting Skirmish Tactical rules.", tostring(Script))
|
||||
Reset_Stats()
|
||||
SkirmishGame = nil
|
||||
TacticalGame = nil
|
||||
GUIManager:Reset()
|
||||
TextManager:Reset()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user