public void InitFrom(ScriptedActionInfo info){ // initialize members from deserialized info gameObject.name = info.unityObjectName; comment = info.comment; objectName = info.objectName; type = info.type; role = info.role; // in a multi-role script, which role performs this action stringParam = info.stringParam; // used for a lot of different things //info.audioClipName = sa.audioClipName; fadeLength = info.fadeLength; // also used for wait, move desiredAlpha = info.desiredAlpha; desiredColor = info.desiredColor; // public Texture2Dname texture2D = null; // used for enableInteraction; // public Transform moveTo; moveToName = info.moveToName; offset = info.offset; // offset from transform for move, in transform's reference frame orientation = info.orientation; // if (info.scriptToExecuteName != null && info.scriptToExecuteName){ // this probably need a redesign, where the search occurs at Start() time, since the script // info.scriptToExecuteName = scriptToExecute.name; // } ease = info.ease; negate = info.negate; // use to turn enable to disable, stop audio, etc. loop = info.loop; waitForCompletion = info.waitForCompletion; // signal complete after audio, fade, etc. sequenceEnd = info.sequenceEnd; executeOnlyOnce = info.executeOnlyOnce; block = info.block; dialogIfThen = info.dialogIfThen; breakpoint = info.breakpoint; preAttributes = info.preAttributes; // processed when the line is begun postAttributes = info.postAttributes; // processed when the line completes stringParam2 = info.stringParam2; stringParam3 = info.stringParam3; stringParam4 = info.stringParam4; attachmentOverride = info.attachmentOverride; eventScript = info.eventScript; voiceTag = info.voiceTag; heading = info.heading; speed = info.speed; if (info.gameMsgFormInfo != null){ gameMsgForm = gameObject.AddComponent<GameMsgForm>(); gameMsgForm.InitFrom(info.gameMsgFormInfo); // info.gameMsg = sa.gameMsgForm.ToGameMsg(this); // how to handle message subclasses ? if (info.map != null){ gameMsgForm.map = gameObject.AddComponent<InteractionMapForm>(); gameMsgForm.map.InitFromMap(info.map); } } syncToTasksIndex = info.syncToTasksIndex; if (syncToTasksIndex != null) syncToTasks = new ScriptedAction[syncToTasksIndex.Length]; // will init when script is fully loaded. else syncToTasks = new ScriptedAction[0]; }
public ScriptedActionInfo ToInfo(ScriptedAction sa){ // saves values to an info for serialization (to XML) ScriptedActionInfo info = new ScriptedActionInfo(); info.unityObjectName = sa.name; info.comment = sa.comment; info.objectName = sa.objectName; info.type = sa.type; info.role = sa.role; // in a multi-role script, which role performs this action info.stringParam = sa.stringParam; // used for a lot of different things //info.audioClipName = sa.audioClipName; info.fadeLength = sa.fadeLength; // also used for wait, move info.desiredAlpha = sa.desiredAlpha; info.desiredColor = sa.desiredColor; // public Texture2Dname texture2D = null; // used for enableInteraction; // public Transform moveTo; info.moveToName = sa.moveToName; info.offset = sa.offset; // offset from transform for move, in transform's reference frame info.orientation = sa.orientation; if (scriptToExecute != null) info.stringParam2 = scriptToExecute.name; //name is in info.ease = sa.ease; info.negate = sa.negate; // use to turn enable to disable, stop audio, etc. info.loop = sa.loop; info.waitForCompletion = sa.waitForCompletion; // signal complete after audio, fade, etc. info.sequenceEnd = sa.sequenceEnd; info.executeOnlyOnce = sa.executeOnlyOnce; info.block = sa.block; info.dialogIfThen = sa.dialogIfThen; info.breakpoint = false; // always clear when saving. sa.breakpoint; info.preAttributes = sa.preAttributes; // processed when the line is begun info.postAttributes = sa.postAttributes; // processed when the line completes info.stringParam2 = sa.stringParam2; info.stringParam3 = sa.stringParam3; info.stringParam4 = sa.stringParam4; info.attachmentOverride = sa.attachmentOverride; info.eventScript = sa.eventScript; info.voiceTag = sa.voiceTag; info.heading = sa.heading; info.speed = sa.speed; if (sa.gameMsgForm != null){ info.gameMsgFormInfo = sa.gameMsgForm.ToInfo(sa.gameMsgForm); // info.gameMsg = sa.gameMsgForm.ToGameMsg(this); // how to handle message subclasses ? if (sa.gameMsgForm.map != null){ info.map = sa.gameMsgForm.map.GetMap(); } } if (sa.type==actionType.characterTask && sa.syncToTasks != null && sa.syncToTasks.Length > 0){ info.syncToTasksIndex = new int[sa.syncToTasks.Length]; for (int t = 0; t<sa.syncToTasks.Length; t++){ if (sa.syncToTasks[t]==null){ Debug.LogError("null sync task encountered in scripted action"+name); info.syncToTasksIndex[t] = sa.GetLineNumber(); } else { info.syncToTasksIndex[t] = sa.syncToTasks[t].GetLineNumber(); } } } // info.gameMsg = gameMsgForm.ToMessage(); //gameMsg; //map; return info; }