//============================================================
// TTeamFixRules.uc	- Class for managing GameRule specific events
//============================================================
//	TitanTeamFix
//		- A modular team balancing tool initially coded for the Titan servers:
//			http://ut2004.titaninternet.co.uk/
//
//	Copyright (C) 2007-2008 John "Shambler" Barrett (JBarrett847@Gmail.com or Shambler@OldUnreal.com)
//
//	This program is free software; you can redistribute and/or modify
//	it under the terms of the Open Unreal Mod License version 1.1.
//
//============================================================
Class TTeamFixRules extends GameRules;

var TTeamFix Master;

var bool bPreSpawnEvent;
var bool bKillEvent;


function InitializeEvents(TTeamFix Caller)
{
	// Some checking statements
	if (Caller == none)
	{
		WarnInternal("TTeamFixRules::InitializeEvents Caller is none");
		return;
	}

	if (Master != none && Master != Caller)
		WarnInternal("TTeamFixRules::InitializeEvents Master was already set, initializing from new Caller and disregarding old Master");

	Master = Caller;

	bPreSpawnEvent = Master.bNeedPreSpawnEvent;
	bKillEvent = Master.bNeedKilledEvent;
}

function NavigationPoint FindPlayerStart(Controller Player, optional byte InTeam, optional string incomingName)
{
	if (bPreSpawnEvent && Master != none && Player != none)
		Master.PlayerSpawning(Player, InTeam);

	return Super.FindPlayerStart(Player, InTeam, incomingName);
}

function ScoreKill(Controller Killer, Controller Killed)
{
	if (bKillEvent && Master != none && Killed != none)
		Master.PlayerKilled(Killed);

	Super.ScoreKill(Killer, Killed);
}

/*
function bool HandleRestartGame()
{
	// Note: If another GameRules does handle this, then TitanTeamFix will break. May need to find a better way to force the mutator on.
	if (Super.HandleRestartGame())
		return True;

	if (Master != none)
		return Master.NotifyRestartGame();

	return false;
}
*/