import jagdx.IDirect3DDevice;
import jagdx.IUnknown;
import java.nio.ByteBuffer;

public class Class341_Sub1 extends Class341 {

   Class545_Sub2_Sub1 aClass545_Sub2_Sub1_8149;
   long aLong8150 = 0L;


   void method13101(ByteBuffer var1, short var2, short var3, byte var4, byte var5, byte var6, byte var7) {
      var1.putShort(var2);
      var1.putShort(var3);
      var1.put(var4);
      var1.put(var5);
      var1.put(var6);
      var1.put(var7);
   }

   void method13102() {
      this.method13104();
   }

   void method13103() {
      if(this.aLong8150 != 0L) {
         this.aClass545_Sub2_Sub1_8149.method15858(this.aLong8150);
         this.aLong8150 = 0L;
      }

   }

   void method13104() {
      if(this.aLong8150 != 0L) {
         this.aClass545_Sub2_Sub1_8149.method15858(this.aLong8150);
         this.aLong8150 = 0L;
      }

   }

   public void finalize() {
      this.method13104();
   }

   public void method8() {
      if(this.aLong8150 != 0L) {
         IUnknown.Release(this.aLong8150);
         this.aLong8150 = 0L;
      }

      this.aClass545_Sub2_Sub1_8149.method15169(this);
   }

   public void method9() {
      if(this.aLong8150 != 0L) {
         IUnknown.Release(this.aLong8150);
         this.aLong8150 = 0L;
      }

      this.aClass545_Sub2_Sub1_8149.method15169(this);
   }

   void method13105() {
      this.method13104();
   }

   Class341_Sub1(Class545_Sub2_Sub1 var1, Class348[] var2) {
      super(var2);
      this.aClass545_Sub2_Sub1_8149 = var1;
      byte var3 = 0;
      ByteBuffer var4 = this.aClass545_Sub2_Sub1_8149.aByteBuffer9763;
      var4.clear();

      for(short var5 = 0; var5 < this.aClass348Array4375.length; ++var5) {
         short var6 = 0;
         Class348 var7 = this.aClass348Array4375[var5];

         for(int var8 = 0; var8 < var7.method6350(); ++var8) {
            Class347 var9 = var7.method6347(var8);
            if(var9 == Class347.aClass347_4429) {
               this.method13101(var4, var5, var6, (byte)2, (byte)0, (byte)0, (byte)0);
            } else if(var9 == Class347.aClass347_4435) {
               this.method13101(var4, var5, var6, (byte)2, (byte)0, (byte)3, (byte)0);
            } else if(var9 == Class347.aClass347_4445) {
               this.method13101(var4, var5, var6, (byte)4, (byte)0, (byte)10, (byte)0);
            } else if(var9 == Class347.aClass347_4439) {
               this.method13101(var4, var5, var6, (byte)0, (byte)0, (byte)5, var3++);
            } else if(var9 == Class347.aClass347_4440) {
               this.method13101(var4, var5, var6, (byte)1, (byte)0, (byte)5, var3++);
            } else if(var9 == Class347.aClass347_4432) {
               this.method13101(var4, var5, var6, (byte)2, (byte)0, (byte)5, var3++);
            } else if(var9 == Class347.aClass347_4433) {
               this.method13101(var4, var5, var6, (byte)3, (byte)0, (byte)5, var3++);
            }

            var6 = (short)(var6 + var9.anInt4431);
         }
      }

      this.method13101(var4, (short)255, (short)0, (byte)17, (byte)0, (byte)0, (byte)0);
      this.aLong8150 = IDirect3DDevice.CreateVertexDeclaration(this.aClass545_Sub2_Sub1_8149.aLong10294, this.aClass545_Sub2_Sub1_8149.aLong9730);
      this.aClass545_Sub2_Sub1_8149.method15120(this);
   }

   void method13106() {
      this.method13104();
   }

   void method13107() {
      if(this.aLong8150 != 0L) {
         this.aClass545_Sub2_Sub1_8149.method15858(this.aLong8150);
         this.aLong8150 = 0L;
      }

   }

   public void method10() {
      if(this.aLong8150 != 0L) {
         IUnknown.Release(this.aLong8150);
         this.aLong8150 = 0L;
      }

      this.aClass545_Sub2_Sub1_8149.method15169(this);
   }
}
