public MapCharacterAnimationState(TileReferences tileReferences, byte[] stateBytes) { Debug.Assert(stateBytes.Length == 0x8); // _tile1 = stateBytes[0] + 0x100; _tile2 = stateBytes[1] + 0x100; Tile1Ref = tileReferences.GetTileReference(_tile1); Tile2Ref = tileReferences.GetTileReference(_tile2); X = stateBytes[2]; Y = stateBytes[3]; Floor = stateBytes[4]; Depends1 = stateBytes[5]; Depends2 = stateBytes[6]; Depends3 = stateBytes[7]; }
/// <summary> /// Build the character state based on existing conditions /// This is called when entering a new map within the game - as opposed to loading from disk /// </summary> /// <param name="tileReferences"></param> /// <param name="npcRef"></param> /// <param name="nCharacterAnimationStateIndex"></param> /// <param name="timeOfDay"></param> public MapCharacterState(TileReferences tileReferences, NonPlayerCharacterReference npcRef, int nCharacterAnimationStateIndex, TimeOfDay timeOfDay) { NPCIndex = npcRef.DialogIndex; TileRef = tileReferences.GetTileReference(npcRef.NPCKeySprite); CharacterAnimationStateIndex = nCharacterAnimationStateIndex; // if you are adding by hand then we can assume that the character is active TheCharacterPosition = npcRef.Schedule.GetCharacterDefaultPositionByTime(timeOfDay); Active = true; }
/// <summary> /// Build the character state from data retrieved from disk /// </summary> /// <param name="tileReferences"></param> /// <param name="stateUInts"></param> /// <param name="nNPCIndex"></param> public MapCharacterState(TileReferences tileReferences, UInt16[] stateUInts, int nNPCIndex) { Debug.Assert(stateUInts.Length == 0x8); NPCIndex = nNPCIndex; TheCharacterPosition.X = stateUInts[1]; TheCharacterPosition.Y = stateUInts[2]; TheCharacterPosition.Floor = stateUInts[3]; TileRef = tileReferences.GetTileReference(stateUInts[4] + 0x100); CharacterAnimationStateIndex = stateUInts[6]; Active = stateUInts[7] > 0; }