home *** CD-ROM | disk | FTP | other *** search
/ Level 2000 August / Level_2000-08_cd1.bin / Demos / Vampire / Vampire_Demo.exe / Codex.nob / DoorRegion.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-22  |  2.5 KB  |  78 lines

  1. public class DoorRegion extends Codex {
  2.    private float _speed = 10.0F;
  3.    private float _openTime;
  4.    private CodexRegion _triggerDoorRegion;
  5.    private CodexThing door;
  6.    private int doorGuid;
  7.    private int _OpenOnce;
  8.    private boolean bOpen;
  9.    private boolean bActive;
  10.    public static String[] _params = new String[]{"Movement speed;150.0", "Open Time;0", "Open Once;0", "Region"};
  11.  
  12.    public void beginscene(int clientGuid, int captureID) {
  13.       this.door.SetThingFlags(8192);
  14.    }
  15.  
  16.    public void arrived(int thingGuid, int frameNum, int captureId) {
  17.       this.bOpen = frameNum != 0;
  18.       if (this.bOpen && (double)this._openTime > (double)0.0F) {
  19.          ((Codex)this).SetTimer(this._openTime);
  20.       } else if (this._OpenOnce == 0) {
  21.          this.bActive = false;
  22.       } else if (this._OpenOnce == 1) {
  23.          this.door.SetThingFlags(64);
  24.       }
  25.  
  26.       if (!this.bOpen) {
  27.          this.bActive = false;
  28.       }
  29.  
  30.    }
  31.  
  32.    public void restore(int flags) {
  33.       this.bOpen = CodexSequence.RestoreBoolean();
  34.    }
  35.  
  36.    public void entered(int guid, int causeGUID, int captureID) {
  37.       if (Codex.IsActorGuid(causeGUID)) {
  38.          if (!this.bActive) {
  39.             this.bActive = true;
  40.             if (!this.bOpen) {
  41.                this.door.MoveToFrame(1, this._speed);
  42.                this.bOpen = true;
  43.             } else {
  44.                this.door.MoveToFrame(0, this._speed);
  45.                this.bOpen = false;
  46.             }
  47.  
  48.          }
  49.       }
  50.    }
  51.  
  52.    public void save(int flags) {
  53.       CodexSequence.SaveBoolean(this.bOpen);
  54.    }
  55.  
  56.    public void timer(int timerID, float arg0, float arg1, float arg2, float arg3) {
  57.       if (this.bOpen) {
  58.          this.door.MoveToFrame(0, this._speed);
  59.          this.bOpen = false;
  60.       }
  61.  
  62.    }
  63.  
  64.    public DoorRegion(float speed, float openTime, int OpenOnce, CodexThing triggerDoorRegion) {
  65.       this._speed = speed;
  66.       this._openTime = openTime;
  67.       this._triggerDoorRegion = new CodexRegion(((Codex)triggerDoorRegion).GetGUID());
  68.       this._OpenOnce = OpenOnce;
  69.       ((Codex)this).CaptureThing(this._triggerDoorRegion.GetGUID());
  70.       this.doorGuid = ((Codex)this).GetClassThing();
  71.       this.door = new CodexThing(this.doorGuid);
  72.       if (this.door.GetDescriptionID().equalsIgnoreCase("PROP")) {
  73.          this.door.SetDescriptionID("GEN_DOOR");
  74.       }
  75.  
  76.    }
  77. }
  78.