public CHandle CreateHandle(CR2WExportWrapper in_chunk, string type, string handle, string varname = "") { var var = CreateHandle(type, handle, varname); in_chunk.data.AddVariable(var); return(var); }
public CPtr CreatePtr(CR2WExportWrapper in_chunk, string type, CR2WExportWrapper to_chunk, string varname = "") { var var = CreatePtr(type, to_chunk, varname); in_chunk.data.AddVariable(var); return(var); }
public CVector CreateVector(CR2WExportWrapper in_chunk, string type, string varname = "") { var var = CreateVector(type, varname); in_chunk.data.AddVariable(var); return(var); }
// Does not reindex /TODO public CR2WExportWrapper CreateChunk(string type, int chunkindex = 0, CR2WExportWrapper parent = null, CR2WExportWrapper virtualparent = null, CVariable cvar = null) { var chunk = new CR2WExportWrapper(this, type, parent); if (cvar != null) { chunk.CreateDefaultData(); } else { chunk.CreateDefaultData(cvar); } if (parent != null) { chunk.ParentChunk = parent; } if (virtualparent != null) { chunk.MountChunkVirtually(virtualparent); } Chunks.Insert(chunkindex, chunk); return(chunk); }
public CPtr CreatePtr(CArray in_array, CR2WExportWrapper to_chunk, string varname = "") { var var = CreatePtr("", to_chunk, varname); in_array.AddVariable(var); return(var); }
/// <summary> /// Deep copies a chunk. /// </summary> /// <param name="chunkSource"></param> /// <param name="destinationFile"></param> /// <param name="maxDepth"></param> /// <param name="excludeProperties"></param> /// <param name="excludeChunks"></param> /// <param name="storySceneRemoveUnnessaryTeleportation"></param> /// <param name="storySceneRemoveAddFacts"></param> /// <param name="storySceneCopyDialogsets"></param> /// <param name="storySceneCopyCameras"></param> /// <returns></returns> public static CR2WExportWrapper CopyChunk(CR2WExportWrapper chunkSource, CR2WFile destinationFile, int maxDepth = -1, IEnumerable <string> excludeProperties = null, IEnumerable <string> excludeChunks = null, bool storySceneRemoveUnnessaryTeleportation = false, bool storySceneRemoveAddFacts = false, bool storySceneCopyDialogsets = false, bool storySceneCopyCameras = false) { var context = new CR2WCopyAction { SourceFile = chunkSource.cr2w, DestinationFile = destinationFile, MaxIterationDepth = maxDepth, ExcludeProperties = excludeProperties, ExcludeChunks = excludeChunks, StorySceneRemoveUnnessaryTeleportation = storySceneRemoveUnnessaryTeleportation, StorySceneRemoveAddFacts = storySceneRemoveAddFacts, StorySceneCopyDialogsets = storySceneCopyDialogsets, StorySceneCopyCameras = storySceneCopyCameras }; var result = context.CopyChunk(chunkSource); context.DeepCopy(); return(result); }
public CPtr CreatePtr(string type, CR2WExportWrapper tochunk, string varname = "") { var ptr = new CPtr(this); ptr.Name = varname; ptr.Type = type; if (tochunk != null) { ptr.val = chunks.IndexOf(tochunk) + 1; } return(ptr); }
/// <summary> /// This constructor should be used when manually creating chunks /// </summary> /// <param name="file"></param> /// <param name="redtype"></param> /// <param name="parentchunk"></param> /// <param name="cooked"></param> public CR2WExportWrapper(CR2WFile file, string redtype, CR2WExportWrapper parentchunk, bool cooked = false) { _export = new CR2WExport { objectFlags = (ushort)(cooked ? 8192 : 0), }; AdReferences = new List <IChunkPtrAccessor>(); AbReferences = new List <IChunkPtrAccessor>(); this.cr2w = file; this.REDType = redtype; ParentChunk = parentchunk; }
public CR2WExportWrapper CreateChunk(string type, CVariable data, CR2WExportWrapper parent = null) { var chunk = new CR2WExportWrapper(this); chunk.Type = type; chunk.data = data; if (parent != null) { chunk.ParentChunkId = (uint)chunks.IndexOf(parent) + 1; } chunks.Add(chunk); return(chunk); }
public CR2WExportWrapper CreateChunk(string type, CR2WExportWrapper parent = null) { var chunk = new CR2WExportWrapper(this) { Type = type }; chunk.CreateDefaultData(); if (parent != null) { chunk.ParentChunkId = (uint)chunks.IndexOf(parent) + 1; } chunks.Add(chunk); return(chunk); }
public static CVariable GetVariableByName(this CR2WExportWrapper arr, CR2WFile file, string name) { if (arr.data is CVector) { var vdata = (CVector)arr.data; for (var i = 0; i < vdata.variables.Count; i++) { if (vdata.variables[i].Name == name) { return(vdata.variables[i]); } } } return(null); }
public static CVariable GetVariableByName(this CR2WExportWrapper arr, string name) { if (arr.data is CVector) { var vdata = (CVector)arr.data; var variables = vdata.GetEditableVariables().ToList(); for (var i = 0; i < variables.Count; i++) { if (variables[i].Name == name) { return((CVariable)variables[i]); } } } return(null); }
public static void CreateConnection(this CR2WExportWrapper chunk, string in_name, string out_name, CR2WExportWrapper out_target) { var cachedConnections = (CArray)chunk.GetVariableByName("cachedConnections"); if (cachedConnections == null) { cachedConnections = (CArray)chunk.cr2w.CreateVariable(chunk, "array:2,0,SCachedConnections", "cachedConnections"); } { // connection 1 var connection = (CVector)cachedConnections.array.Find(delegate(CVariable item) { var vec = (CVector)item; if (vec == null) { return(false); } var socketId = (CName)vec.GetVariableByName("socketId"); return(socketId != null && socketId.Value == in_name); }); if (connection == null) { connection = chunk.cr2w.CreateVector(cachedConnections); ((CName)chunk.cr2w.CreateVariable(connection, "CName", "socketId")).Value = in_name; } var blocks = (CArray)connection.GetVariableByName("blocks"); if (blocks == null) { blocks = (CArray)chunk.cr2w.CreateVariable(connection, "array:2,0,SBlockDesc", "blocks"); } var block = chunk.cr2w.CreateVector(blocks); chunk.cr2w.CreatePtr(block, "ptr:CQuestGraphBlock", out_target, "ock"); ((CName)chunk.cr2w.CreateVariable(block, "CName", "putName")).Value = out_name; } }
private void OnCopyStorySceneSection(CR2WExportWrapper chunkcopy) { var storysection = (CStorySceneSection)chunkcopy.data; if (StorySceneRemoveAddFacts) { removeStorySceneAddFacts(storysection); } if (StorySceneRemoveUnnessaryTeleportation) { removeUnnessaryTeleportation(storysection); } if (StorySceneCopyDialogsets) { copyDialogset(storysection); } if (StorySceneCopyCameras) { copyStorySceneCameras(storysection); } }
// Does not reindex /TODO public CR2WExportWrapper CreateChunk(CVariable cvar, int chunkindex = 0, CR2WExportWrapper parent = null, CR2WExportWrapper virtualparent = null) { // checks to see if the variable from which the chunk is built is properly constructed if (cvar == null || cvar.REDName != cvar.REDType || cvar.ParentVar != null) { throw new NotImplementedException(); } var chunk = new CR2WExportWrapper(this, cvar.REDType, parent); chunk.CreateDefaultData(cvar); if (parent != null) { chunk.ParentChunk = parent; } if (virtualparent != null) { chunk.MountChunkVirtually(virtualparent); } Chunks.Insert(chunkindex, chunk); return(chunk); }
private CR2WExportWrapper CopyChunk(CR2WExportWrapper chunk) { if (ExcludeChunks != null && ExcludeChunks.Contains(chunk.Type)) { return(null); } var chunkcopy = chunk.Copy(this); if (chunkcopy != null) { if (chunkcopy.data is CStorySceneSection) { OnCopyStorySceneSection(chunkcopy); } var CStoryScene = DestinationFile.GetChunkByType("CStoryScene"); if (CStoryScene != null) { var controlParts = CStoryScene.GetVariableByName("controlParts") as CArray; // Add this chunk to the controlParts if (controlParts != null) { switch (chunkcopy.Type) { case "CStorySceneInput": case "CStorySceneScript": case "CStorySceneFlowCondition": case "CStorySceneSection": case "CStorySceneCutsceneSection": case "CStorySceneVideoSection": case "CStorySceneRandomizer": case "CStorySceneOutput": case "CStorySceneCutscenePlayer": DestinationFile.CreatePtr(controlParts, chunkcopy); break; default: break; } } var sections = CStoryScene.GetVariableByName("sections") as CArray; // Add this chunk to the sections if (sections != null) { switch (chunkcopy.Type) { case "CStorySceneSection": case "CStorySceneCutsceneSection": case "CStorySceneVideoSection": DestinationFile.CreatePtr(sections, chunkcopy); break; default: break; } } } } return(chunkcopy); }
/// <summary> /// Used when pasting-in-place a chunk, takes care of (virtual) children. /// </summary> /// <param name="sourcechunk"></param> /// <param name="destinationchunk"></param> /// <param name="oldparentinghierarchy"></param> public void AddChildrenChunks( CR2WExportWrapper sourcechunk, CR2WExportWrapper destinationchunk = null, Dictionary <CR2WExportWrapper, (CR2WExportWrapper oldchunkparent, CR2WExportWrapper oldchunkvparent)> oldparentinghierarchy = null)
public bool RemoveChunk(CR2WExportWrapper chunk) { return(chunks.Remove(chunk)); }