summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/SubclumpShape.java
blob: 000786fdf2811faf0aa9a2f81766c8d7bdc91061 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package NET.worlds.scape;

public class SubclumpShape extends Shape implements ShapeLoaderListener {
   private Material pendingMaterial = null;
   private static final boolean debug = false;

   @Override
   public void setMaterial(Material m) {
      SuperRoot parentObj = this.getOwner();
      if (!(parentObj instanceof Shape)) {
         super.setMaterial(m);
      } else {
         Shape parent = (Shape)parentObj;
         if (!parent.isFullyLoaded()) {
            parent.addLoadListener(this);
            this.pendingMaterial = m;
         } else {
            super.setMaterial(m);
         }
      }
   }

   @Override
   protected synchronized void addRwChildren(WObject container) {
      SuperRoot o = this.getOwner();
      if (o instanceof Shape) {
         Shape parent = (Shape)o;
         if (!parent.isFullyLoaded()) {
            this.setState(LOADING, null);
            parent.addLoadListener(this);
         }
      }

      super.addRwChildren(container);
   }

   @Override
   public void notifyShapeLoaded(Shape s) {
      this.setState(NORMAL, null);
      this.shapeRedraw();
      if (this.pendingMaterial != null) {
         super.setMaterial(this.pendingMaterial);
      }

      this.pendingMaterial = null;
   }
}