-
Notifications
You must be signed in to change notification settings - Fork 0
07 Create .ai and .per files
Satoshi Teshiba edited this page Jan 17, 2021
·
7 revisions
A .ai and a .per file(or some additional per files) are needed to place in a specific folder.
The following C # code outputs three files into the AI directory of AoE2DE.
Those name are AIFileSample.ai, AIFileSample.per, and AIFileSamplePerFileSample.per.
The folder path is for Definitive Edition on Steam. The path can be changed if necessary.
In this code, set some AI command class instances to the return value of the GetCommandGroups() method of the PerFile class.
Those codes output the AI script to the .per file instead of a console output by the ToScript() method.
using System.Collections.Generic;
using System.Collections.ObjectModel;
using LibAoe2AISharp.Framework;
using LibAoe2AISharp.Specifications;
namespace Aoe2AISharpSample
{
class Program
{
static void Main(string[] args)
{
new AIFileSample(
@"C:\Program Files (x86)\Steam\steamapps\common\AoE2DE\resources\_common\ai",
"Author Name"
).OutputFiles();
}
}
class AIFileSample : AIFile
{
public AIFileSample(string pathName, string author)
: base(pathName, author, new PerFileSample())
{
}
protected override Collection<DefconstCollection> GetDefconsts()
{
return new Collection<DefconstCollection>() {
};
}
protected override Dictionary<GoalId, GoalValue> GetGoalIdInitValues()
{
return new Dictionary<GoalId, GoalValue>() {
};
}
}
class PerFileSample : PerFile
{
protected override CommandGroupCollection GetCommandGroups()
{
var commandCollections1 = new CommandCollection("sample command group1"){
new BuildHouse(3),
};
var commandCollections2 = new CommandCollection("sample command group2"){
new TrainVillager(24),
};
return new CommandGroupCollection() {
commandCollections1,
commandCollections2,
};
}
}
}