public static BehaviorscriptCommand Build_x0C(int asmPointer = -1) { var cmd = new BehaviorscriptCommand("0C 00 00 00 00 00 00 00"); if (asmPointer != -1) { BehaviorscriptCommandFunctions.X2A.SetCollisionPointer(cmd, asmPointer); } return(cmd); }
public static BehaviorscriptCommand Build_x2A(int collisionPointer = -1) { var cmd = new BehaviorscriptCommand("2a 00 00 00 00 00 00 00"); if (collisionPointer != -1) { BehaviorscriptCommandFunctions.X2A.SetCollisionPointer(cmd, collisionPointer); } return(cmd); }
public bool Read(BinaryData data, int address) { bool ende = false; bool success = true; var newCmds = new List <BehaviorscriptCommand>(); data.Position = address; while (!ende) { // Get command infos var cmdType = (BehaviorscriptCommandTypes)data.ReadByte(); int cmdLength = BehaviorscriptCommand.GetCommandLength(cmdType); var unknownCmd = cmdLength == -1; bool isEndCmd = unknownCmd || BehaviorscriptCommand.IsEndCommand(cmdType); if (!unknownCmd) { // Reset position data.Position -= 1; // Read full command byte[] buf = new byte[cmdLength]; data.Read(buf); // Create & add command try { newCmds.Add(new BehaviorscriptCommand(buf)); } catch (Exception) { success = false; } } else { data.Position += 3; } ende = isEndCmd; } // Add new Cmds if (success && newCmds.Any()) { Close(); AddRange(newCmds.ToArray()); } return(success); }
public int Write(BinaryData data, int address) { data.Position = address; foreach (BehaviorscriptCommand command in this) { var cmdLength = BehaviorscriptCommand.GetCommandLength(command.CommandType); if (command.Length != cmdLength) { command.SetLength(cmdLength); } data.Write(command.ToArray()); } return((int)data.Position - address); }
public static void SetAsmPointer(BehaviorscriptCommand cmd, int pointer) { cmd.Position = 4; cmd.Write(pointer); }
public static int GetAsmPointer(BehaviorscriptCommand cmd) { cmd.Position = 4; return(cmd.ReadInt32()); }