AC的Action系统已更新为其v1.73.0更新的一部分。这些更改旨在使Actions更加灵活,减少文件大小,并提高性能。此页面为希望将custom Actions升级到新系统的开发人员提供了指南。

首先,Actions不再具有设置其分类数据(标题、类别等)的构造函数。相反,这些字段现在通过重写属性进行设置:

  • title字符串变量现在是一个Title字符串属性
  • categoryActionCategory枚举变量现在是一个CategoryActionClassegory enum属性
  • description字符串变量现在是Description字符串属性

例如,以下是Engine:Wait Action的分类数据以前是如何声明的:

1
2
3
4
5
6
7
public ActionPause ()
{
this.isDisplayed = true;
category = ActionCategory.Engine;
title = "Wait";
description = "Waits a set time before continuing.";
}

该数据现在设置如下:

1
2
3
public override ActionCategory Category { get { return ActionCategory.Engine; }}
public override string Title { get { return "Wait"; }}
public override string Description { get { return "Waits a set time before continuing."; }}

不再需要isDisplayed bool变量。

此外,Actions现在具有NumSockets整数属性,可用于设置Action具有的输出sockets数量:

1
public override int NumSockets { get { return 3; }}

如果一个Action有多个socket,可以通过重写GetNextOutputIndex函数来设置下一个运行的socket。此函数将目标套接字作为索引返回,即:

1
2
3
4
5
6
7
8
public override int GetNextOutputIndex ()
{
if (someCondition)
{
return 0; // For first socket
}
return 1; // For second socket etc
}

此函数替换旧系统的End函数,该函数将输出套接字作为ActionEnd类返回。

由于这些更改,具有多个套接字的Action(例如,“check”Actions)不再需要从Action子类(如ActionCheck)派生。然而,为了方便起见,ActionCheck仍然存在。当Action派生自ActionCheck时,NumSockets属性自动设置为2,并且可以通过重写CheckCondition函数继续确定输出套接字(true与false)。