//=============================================================================
// WildcardsSuperContainer.
// When a Container is not good enough...
// Besides ContainerX's are generally Useless!
//=============================================================================
class WildcardsSuperContainer expands sgBuilding;

//var bool DoneYet;
var() int StorageAmount;
var() byte HealRadius;
var() int HealAmount;

simulated event Timer()
{
	local sgBuilding building;

	Super.Timer();

	if ( SCount > 0 || Role != ROLE_Authority )
        return;

	foreach RadiusActors(class'sgBuilding', building, 240+(HealRadius*0.25)*Grade)
		if ( sgBaseCore(building) == None && FRand() <= 0.5 + Grade/5
          && building.Team == Team && !bDisabledByEMP && !building.bDisabledByEMP)
        {
					if (SiegeGI(Level.Game).bOverTime)
					{
					building.Energy = FMin(building.Energy + (HealAmount + Grade/5)/2,
                  building.MaxEnergy);
					}
					else
					{
			    building.Energy = FMin(building.Energy + HealAmount + Grade/5,
                  building.MaxEnergy);
				    }
        }
}

simulated function FinishBuilding()
{
	Super.FinishBuilding();
    SetCollision(true, true, true);
    bProjTarget = true;

    if ( SiegeGI(Level.Game) != None )
    {
        SiegeGI(Level.Game).MaxRus[Team] += StorageAmount;
        SiegeGI(Level.Game).MaxRus[Team] =
          FMax(SiegeGI(Level.Game).MaxRUs[Team], 300);
    }
}

event Destroyed()
{
    Super.Destroyed();

    if ( DoneBuilding && SiegeGI(Level.Game) != None )
        SiegeGI(Level.Game).MaxRUs[Team] -= StorageAmount;
}

function Upgraded()
{
    local float percent;
    local float scale;

    if ( SiegeGI(Level.Game) != None )
    {
        if ( Grade < 2 )
            scale = 1;
        else if ( Grade < 3 )
            scale = 2;
        else if ( Grade < 4 )
            scale = 3;
        else if ( Grade < 5 )
            scale = 4;
		else if ( Grade >= 5 )
            scale = 5;
        SiegeGI(Level.Game).MaxRus[Team] -= StorageAmount;
        StorageAmount = default.StorageAmount + 50 * scale;
        SiegeGI(Level.Game).MaxRus[Team] += StorageAmount;
        percent = Energy/MaxEnergy;
        MaxEnergy = default.MaxEnergy * (1 + Grade/2);
        Energy = percent * MaxEnergy;
    }
}

defaultproperties
{
    StorageAmount=1600
    HealRadius=240
    HealAmount=6
    BuildingName="Super Container"
    BuildCost=1600
    UpgradeCost=60
    BuildTime=45.00
    MaxEnergy=7000.00
    SpriteScale=1.35
    Model=LodMesh'Botpack.CubeGem'
    SkinRedTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSkinT0'
    SkinBlueTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSkinT1'
    SkinGreenTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSkinT2'
    SkinYellowTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSkinT3'
    SpriteRedTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSpriteT0'
    SpriteBlueTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSpriteT1'
    SpriteGreenTeam=Texture'SiegeUltimateRC7UB01Media.U.KoalasEffects.SuperContainerSpriteT2'
    SpriteYellowTeam=Texture'SiegeUltimateRC7UB01Media.U.KoalasEffects.SuperContainerSpriteT3'
    DSofMFX=5.00
    MFXrotX=(Pitch=5000,Yaw=5000,Roll=5000),
    bCollideWhenPlacing=False
    MultiSkins(0)=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSpriteT0'
    MultiSkins(1)=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSpriteT1'
    MultiSkins(2)=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSpriteT2'
    MultiSkins(3)=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSpriteT3'
    CollisionRadius=80.00
    CollisionHeight=80.00
}
