XCOM 2
RuntimeReskinAPI
SurferJay  [开发者] 9 月 18 日 下午 10:35
Registering Rules and Mapping Providers
Please refer to this example code, pulled from the classes in the mod. Various inline documentation can be found within the code, though these are the major bits.

For a working sample, please inspect Advent Angels - Steam Workshop.

V2 Rules Provider
/*************************************************************************************************************** * EXAMPLE * ------------------------------------------------------------------------------------------------------------- * A minimal rules provider showing the required functions and common patterns. * ------------------------------------------------------------------------------------------------------------- // AASJ_RRA_RulesProviderV2.uc class AASJ_RRA_RulesProviderV2 extends Object implements(RuntimeReskinAPI.RuntimeReskinRulesInterfaceV2); // ============================================================================================================== // -- Variables ------------------------------------------------------------------------------------------------- // ============================================================================================================== const CHAMPSTATE_ALWAYS_LOST = -1; // RRA's ChampState for when we lost now and just before const CHAMPSTATE_JUST_LOST = 0; // RRA's ChampState for when we lost now but won just before const CHAMPSTATE_JUST_WON = 1; // RRA's ChampState for when we won now but not just before const CHAMPSTATE_STILL_CHAMP = 2; // RRA's ChampState for when we won now and just before //============================================================================================================== // REQUIRED FUNCTIONS - you MUST implement ALL of these in your provider class: // • GetTieBreakPriority - return your rule’s tiebreak value for resolving equal priorities // • ShouldReskin - vote whether this unit should be reskinned (set outPriority) // • OnPostShouldReskin - run cleanup or prep tied to rule decisions, before mapping // // Signatures must match *exactly* (name, return type, arg count/order/types/out-qualifiers). // If you omit or alter ANY of these three functions, your registration WILL FAIL. PERIOD. // Extra helpers are fine, but these three are MANDATORY and must be implemented VERBATIM. // // NOTE: Avoid editing older providers. Add new ones (V2, V3, …) if upgrading, and keep the old alongside them // if you want backwards compatibility for subscribers on older RRA. Otherwise, they won’t reskin at all. //============================================================================================================== // Return your tiebreak priority, for use in tie breaking when multiple rules win with the same outPriority function int GetTieBreakPriority(name context, name subcontext, name templateName, XComGameState_Unit unitState, Actor targetActor, XComGameState gameState) { // use the provided variables and your private helpers to determine your outcome // return an integer } // Return true if you want to reskin this unit. Set OutPriority (0 => default). function bool ShouldReskin(name context, name subcontext, name templateName, XComGameState_Unit unitState, Actor targetActor, XComGameState gameState, out int outPriority){ // use the provided variables and your private helpers to determine your outcome // set outPriority and return true or false } // Post-rules hook. champState = ALWAYS_LOST(-1) / JUST_LOST(0) / JUST_WON(1) / STILL_CHAMP(2) // Use for cleanup or prep tied to rule decisions, before mapping is applied. function OnPostShouldReskin(name context, name subcontext, name templateName, XComGameState_Unit unitState, Actor targetActor, XComGameState gameState, int myChampState) { // use the provided variables and your private helpers to determine your follow-up actions switch (myChampState) { case CHAMPSTATE_JUST_WON: case CHAMPSTATE_STILL_CHAMP: case CHAMPSTATE_JUST_LOST: case CHAMPSTATE_ALWAYS_LOST: default: break; } } // ============================================================================================================== // -- Private Helpers ------------------------------------------------------------------------------------------- // ============================================================================================================== function someHelper() { // do stuff } * END OF EXAMPLE ****************************************************************************************************************/

V2 Mapping Provider
/*************************************************************************************************************** * EXAMPLE * ------------------------------------------------------------------------------------------------------------- * A minimal mapping provider showing the required functions and common patterns. * ------------------------------------------------------------------------------------------------------------- // AASJ_RRA_MappingProviderV2.uc class AASJ_RRA_MappingProviderV2 extends Object implements(RuntimeReskinAPI.RuntimeReskinMappingInterfaceV2); // ============================================================================================================== // -- Variables ------------------------------------------------------------------------------------------------- // ============================================================================================================== const CHAMPSTATE_ALWAYS_LOST = -1; // RRA's ChampState for when we lost now and just before const CHAMPSTATE_JUST_LOST = 0; // RRA's ChampState for when we lost now but won just before const CHAMPSTATE_JUST_WON = 1; // RRA's ChampState for when we won now but not just before const CHAMPSTATE_STILL_CHAMP = 2; // RRA's ChampState for when we won now and just before //============================================================================================================== // REQUIRED FUNCTIONS - you MUST implement ALL of these in your provider class: // • IsInFallbackMode - Ignored until new CHL event added. Request one-time reskin pre-visualization. // • ResolveMapping - choose an archetype path if your rule wins // • OnPostResolveMapping - run attach/detach work after RRA reskins // // Signatures must match *exactly* (name, return type, arg count/order/types/out-qualifiers). // If you omit or alter ANY of these three functions, your registration WILL FAIL. PERIOD. // Extra helpers are fine, but these three are MANDATORY and must be implemented VERBATIM. // // NOTE: Avoid editing older providers. Add new ones (V2, V3, …) if upgrading, and keep the old alongside them // if you want backwards compatibility for subscribers on older RRA. Otherwise, they won’t reskin at all. //============================================================================================================== // Return true to restrict reskinning to pre-visualization. In this mode, players must reload a save to reroll. // Currently ignored; added for forward-compatibility if/once CHL adds OnGetPawnArchetypeString event. Don't return true until then. function bool IsInFallbackMode(name context, name subcontext, name templateName, XComGameState_Unit unitState, Actor targetActor, XComGameState gameState) { // use the provided variables and your private helpers to determine your outcome // return true or false } // Return true and fill OutArcPath when you have a mapping. Is only called if you were the winning rule. function bool ResolveMapping(name context, name subcontext, name templateName, XComGameState_Unit unitState, Actor targetActor, XComGameState gameState, out string outArcPath) { // use the provided variables and your private helpers to determine your outcome // set outArcPath and return true or false } // Post-reskin hook. champState = ALWAYS_LOST(-1) / JUST_LOST(0) / JUST_WON(1) / STILL_CHAMP(2) // Use for attach/detach work that must run after RRA replaces the unit's meshes/animations. function OnPostResolveMapping(name context, name subcontext, name templateName, XComGameState_Unit unitState, Actor targetActor, XComGameState gameState, int myChampState) { // use the provided variables and your private helpers to determine your follow-up actions switch (myChampState) { case CHAMPSTATE_JUST_WON: case CHAMPSTATE_STILL_CHAMP: case CHAMPSTATE_JUST_LOST: case CHAMPSTATE_ALWAYS_LOST: default: break; } } // ============================================================================================================== // -- Private Helpers ------------------------------------------------------------------------------------------- // ============================================================================================================== function someHelper() { // do stuff } * END OF EXAMPLE ****************************************************************************************************************/
最后由 SurferJay 编辑于; 10 月 15 日 下午 6:30
< >
正在显示第 1 - 3 条,共 3 条留言
SurferJay  [开发者] 9 月 18 日 下午 10:35 
Reserved
SurferJay  [开发者] 9 月 18 日 下午 10:36 
Reserved
SurferJay  [开发者] 9 月 18 日 下午 10:36 
Reserved
< >
正在显示第 1 - 3 条,共 3 条留言
每页显示数: 1530 50