Beispiel #1
0
        private int FindSteeringImageMatchingDirection(ref RespawnSetting xbRespawnSetting)
        {
            SHETChunk lShet = mMainForm.CurrentLevel.SHET;

              for (int i = 0; i < lShet.SteeringImages.mChildren.Length; i++)
              {
            if (!(lShet.SteeringImages.mChildren[i] is SteeringImageChunk))
            {
              continue;
            }

            SteeringImageChunk lSteeringImage = (SteeringImageChunk)lShet.SteeringImages.mChildren[i];

            if (xbRespawnSetting.MatchToSteeringImage(lSteeringImage))
            {
              return i;
            }
              }

              return int.MinValue;
        }
Beispiel #2
0
        private void SetRespawnPosition(
            int x,
            int y,
            RespawnSetting xiRespawnSetting)
        {
            SHETChunk lShet = mMainForm.CurrentLevel.SHET;

              // eDirection.None is used to mean 'no respawn allowed', which is coded
              // on a different metadata sheet.
              if (xiRespawnSetting.Direction == eDirection.None)
              {
            mSubject.TexMetaData[x][y][(byte)eTexMetaDataEntries.Behaviour] = FlatChunk.BEHAVIOUR_DEFAULTNORESPAWN;
            return;
              }
              else if (Array.IndexOf(sNoRespawnValues, mSubject.TexMetaData[x][y][(byte)eTexMetaDataEntries.Behaviour]) >= 0)
              {
            mSubject.TexMetaData[x][y][(byte)eTexMetaDataEntries.Behaviour] = FlatChunk.BEHAVIOUR_DEFAULT;
              }

              // Find a steering image which can be used for this direction, at one of the four orientations
              int lSteeringId = FindSteeringImageMatchingDirection(ref xiRespawnSetting);

              if (lSteeringId == int.MinValue)
              {
            xiRespawnSetting.RotateTo(eOrientation.North);

            if (lShet.UnusedSteeringImages.Count == 0)
            {
              lSteeringId = lShet.SteeringImages.mChildren.Length;
              SteeringImageChunk lNewSteeringImage = new SteeringImageChunk(
            lSteeringId,
            (byte)xiRespawnSetting.Direction);
              int lSizeIncrease = lShet.AddSteeringImage(lNewSteeringImage);
              lShet.TrailingZeroByteCount -= lSizeIncrease;

              if (lShet.TrailingZeroByteCount < 0)
              {
            MessageBox.Show(string.Format(
              "WARNING: You have just run out of space in your level file - you will need to free up {0} bytes before you can save your changes.",
              -lShet.TrailingZeroByteCount));
              }
            }
            else
            {
              foreach (DictionaryEntry lEntry in lShet.UnusedSteeringImages)
              {
            // Just get the first unused.
            lSteeringId = (int)lEntry.Key;
            SteeringImageChunk lSteeringImage = (SteeringImageChunk)lEntry.Value;
            lSteeringImage.FlushToValue((byte)xiRespawnSetting.Direction);
            break;
              }

              lShet.UnusedSteeringImages.Remove(lSteeringId);
            }
              }

              // Use 4 instead of 0 for orientation North, because orientation 0
              // reverses the directions...
              mSubject.TexMetaData[x][y][(byte)eTexMetaDataEntries.Orientation] =
               xiRespawnSetting.Orientation == eOrientation.North ? (byte)4 : (byte)xiRespawnSetting.Orientation;
              mSubject.TexMetaData[x][y][(byte)eTexMetaDataEntries.Steering] = (byte)lSteeringId;

              // Rotate back to north to set position (layer seven)
              xiRespawnSetting.RotateTo(eOrientation.North);
              byte lRespawnValue = PointToRespawnPos(new Point(xiRespawnSetting.X, xiRespawnSetting.Y));
              mSubject.TexMetaData[x][y][(byte)eTexMetaDataEntries.RespawnPos] = lRespawnValue;
        }