108 lines
3.1 KiB
C
108 lines
3.1 KiB
C
/**
|
|
* @file config.c
|
|
* @author 稻草人
|
|
* @version 1.0
|
|
* @date 2025-02-12
|
|
* @copyright Copyright (c) 2025
|
|
*
|
|
* @brief This file contains the configuration for the custom revival suit feature.
|
|
*/
|
|
static ref CustomRevivalSuitCfg g_CustomRevivalSuitCfg;
|
|
static ref CustomRevivalSuitCfg GetCustomRevivalSuitCfg()
|
|
{
|
|
if ( !g_CustomRevivalSuitCfg )
|
|
{
|
|
g_CustomRevivalSuitCfg = new ref CustomRevivalSuitCfg();
|
|
g_CustomRevivalSuitCfg.loadConfig();
|
|
}
|
|
return g_CustomRevivalSuitCfg;
|
|
}
|
|
|
|
class CustomRevivalSuitCfg
|
|
{
|
|
string profileDir = "$profile:DcrServerModCfg\\CustomRevivalSuitCfg";
|
|
string profileName = "\\CustomRevivalSuitCfg.json";
|
|
string profilePath = profileDir + profileName;
|
|
string desc = "上面的变量不要修改, 由于1.27的更新,导致上述变量在外部.c文件中无法被引用";
|
|
|
|
ref array< ref PlayerRevivalEquipmentData > PlayerRevivalEquipmentDataList;
|
|
|
|
void loadConfig()
|
|
{
|
|
if ( !FileExist( profilePath ) )
|
|
makeConfig();
|
|
|
|
JsonFileLoader< ref CustomRevivalSuitCfg >.JsonLoadFile( profilePath, this );
|
|
}
|
|
|
|
void makeConfig()
|
|
{
|
|
PlayerRevivalEquipmentDataList = new ref array< ref PlayerRevivalEquipmentData >();
|
|
ref PlayerRevivalEquipmentData playerData = new ref PlayerRevivalEquipmentData( "76561198422667486" );
|
|
PlayerRevivalEquipmentDataList.Insert( playerData );
|
|
|
|
MakeDirectory( "$profile:DcrServerModCfg/" );
|
|
MakeDirectory( profileDir + "/" );
|
|
|
|
SaveConfig();
|
|
}
|
|
|
|
void SaveConfig()
|
|
JsonFileLoader< ref CustomRevivalSuitCfg >.JsonSaveFile( profilePath, this );
|
|
|
|
ref PlayerRevivalEquipmentData GetPlayerRevivalEquipmentData( string steamid )
|
|
{
|
|
foreach ( ref PlayerRevivalEquipmentData playerData : PlayerRevivalEquipmentDataList )
|
|
{
|
|
if ( !playerData ) continue;
|
|
ref TStringArray TeamMembers = playerData.TeamMembers;
|
|
if ( TeamMembers && TeamMembers.Find( steamid ) > -1 )
|
|
return playerData;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
class PlayerRevivalEquipmentData
|
|
{
|
|
// string SteamId;
|
|
string TeamName;
|
|
ref TStringArray TeamMembers; // 兼容个人和队伍,单人玩家 == 单人队伍
|
|
|
|
ref TStringArray Equipments;
|
|
ref TStringArray ItemList;
|
|
ref WeaponCfg WeaponData;
|
|
|
|
void PlayerRevivalEquipmentData( string steamid )
|
|
{
|
|
// SteamId = steamid;
|
|
TeamName = "小队名字";
|
|
TeamMembers = new TStringArray();
|
|
TeamMembers.Insert( steamid );
|
|
|
|
Equipments = { "WoolGloves_White", "BaseballCap_Black",
|
|
"Jeans_Blue", "Wellies_Black", "TShirt_Black"
|
|
};
|
|
ItemList = { "Apple" };
|
|
WeaponData = new ref WeaponCfg();
|
|
}
|
|
}
|
|
|
|
class WeaponCfg
|
|
{
|
|
string WeaponName;
|
|
string Desc;
|
|
|
|
ref TStringArray WeaponComponents;
|
|
|
|
void WeaponCfg()
|
|
{
|
|
WeaponName = "FAL";
|
|
Desc = "武器配件中,一级配件(比如枪托,弹夹)放在前排,二级配件(比如电池)其次 以此类推"
|
|
WeaponComponents = {
|
|
"Fal_FoldingBttstck",
|
|
"Mag_FAL_20Rnd"
|
|
};
|
|
}
|
|
} |