Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

KFGui.GUIShowable


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
class GUIShowable extends Object;

var Mesh showMesh;              //Mesh to show in Info
var StaticMesh myShowMesh;      //Actual staticmesh to show in info
var int cost;                   //Cost to buy
var float weight;                 //Heaviness
var class<GUIPanel> InfoPanel;  //Panel to show Info in- should actually be KFInfoPanel
var class<Inventory> relatedInventory; //For inventory sellables,
									   //the associated class.

var rotator infoDrawRotation;          //Rotation in the Info panel
var vector infoDrawOffset;             //Offset in the info panel
var float infoDrawScale;               //Generally, size
var int infoSpinRate;                  //rate our weapon spins at.  0 by default.
                                        //alex, change the damn default.

var string ItemName;            //Sale name of object
var string Description;         //Flavor text, etc.

var int PurchasedQuantity;      //Have we bought one of these?
var int OwnedQuantity;          //Amount player already has

var float GameDifficulty;




enum eLibCat
{
	Lib_Story,
	Lib_Enemy,
	Lib_Equipment,
};



//We might want different panel types for different
//categories.
function class<GUIPanel> GetPanelType(eLibCat category)
{
	return InfoPanel;
}



function bool CanButtonMe(PlayerController pc,bool buying)
{
	if(buying)
		return CanBuyMe(pc);
	else
		return CanSellMe(pc);
}

function bool CanBuyMe(PlayerController pc)
{
	if(KFPlayerController(pc) == None || KFHumanPawn(pc.Pawn) == None)
	{
	  Log ("PC == none or PC.pawn == none");
          return false;
        }

	return true;
}

function bool CanSellMe(PlayerController pc)
{
	if(KFPlayerController(pc) == None || KFHumanPawn(pc.Pawn) == None)
		return false;
	return true;
}

function string GetBuyCaption(eLibCat index)
{
	Return "";
}

function ProcessComplete(PlayerController pc)
{


	if(PurchasedQuantity > 0)
	{
		GiveMe(pc);
		return;
	} else if(PurchasedQuantity < 0)
	{
		TakeMe(pc);
		return;
	}
}

//Hand it over to the player (once he hits complete)
function GiveMe(PlayerController pc)
{
}

//The slink giveth, the slink taketh away
function TakeMe(PlayerController pc)
{
}

//Consider ourselves bought
function BuyMe(out int score, out float oweight, pawn servUpdatePawn)
{
	score -= cost;
	oweight += weight;
	PurchasedQuantity++;

//	(KFPawn(servUpdatePawn)).setCreds(score) ;
}

//Consider ourselves sold
function SellMe(out int score, out float oweight, pawn servUpdatePawn)
{
      if (PlayerController(servUpdatePawn.Controller).GameReplicationInfo != none)
     {
        GameDifficulty = KFGameReplicationInfo(PlayerController(servUpdatePawn.Controller).GameReplicationInfo).GameDiff;
       // Log(KFGameReplicationInfo(PlayerOwner().GameReplicationInfo).GameDiff);
     }

        
        
        if(PurchasedQuantity > 0)
		score += cost;
	else
		score += (cost / GameDifficulty);
	oweight -= weight;
	PurchasedQuantity--;
	



   //   (KFPawn(servUpdatePawn)).setCreds(score) ;

}

//Subclasses should return true if the buyable
//should show up under the index'th list for pawn p.
//This implementation just returns whether or not the pawn
//already has an item of class relatedInventory.

// ParentMenu parameter is a kludge so ammo can find out if any stuff
// has been bought and sold in the main buy menu. It is a relatively
// well contained kludge however, so I won't panic
function bool ShowMe(Pawn p, eLibCat index, GUILibraryMenu ParentMenu)
{
	//cost *= 10;
        return true;
}

//returns the combined weight of all owned items of type
function float InitOwnedQuantity(Pawn p)
{
	local Inventory inv;
	local int quant;

	//log("INITOWNEDQUANTITY",'KFMessage');

	if(p == None)
		return 0;
	for(inv = p.Inventory;inv != None;inv = inv.Inventory)
	{
		if(inv.IsA(relatedInventory.Name))
		{
			quant++;
		}
	}
	OwnedQuantity=quant;
	return weight*OwnedQuantity;
}

function bool HasMe(Pawn p)
{
	return (OwnedQuantity+PurchasedQuantity>0);
}

defaultproperties
{
     myShowMesh=StaticMesh'KillingFloorStatics.DeagleAmmo'
     InfoPanel=Class'XInterface.GUIPanel'
     infoDrawRotation=(Pitch=-5461,Yaw=-16384,Roll=32768)
     infoDrawOffset=(X=100.000000,Y=-20.000000,Z=-10.000000)
     infoDrawScale=0.700000
     infoSpinRate=20000
     ItemName="Buyable Object"
     Description="This object appears to be for sale."
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fri 13-10-2023 03:17:26.000 - Creation time: Fri 13-10-2023 03:19:02.544 - Created with UnCodeX