home *** CD-ROM | disk | FTP | other *** search
- class GenericObject extends BB
- {
- var linkageID;
- var target;
- var world;
- var onAddToScene;
- var onRemoveFromScene;
- var onChanged;
- var screenX;
- var screenY;
- var onDisplay;
- var objectSoundID;
- var done;
- var length;
- var duration;
- var sector = 0;
- var trackInSectorGrid = true;
- var uniqueID = 0;
- var generatorDisplacement = 0;
- var sounds = {};
- var x = 0;
- var y = 0;
- var z = 0;
- var radius = 50;
- var inScene = false;
- var useMinScale = false;
- var minScreenScale = 10;
- var renderable = true;
- var assetRotation = 0;
- var useRotation = true;
- var cullDistance = 3000;
- var collisionGroup = 0;
- var depthGroup = 1;
- static var soundsCreated = 0;
- function GenericObject()
- {
- super();
- }
- function update()
- {
- }
- function addToScene()
- {
- if(this.inScene || !this.renderable)
- {
- return undefined;
- }
- if(this.linkageID != null)
- {
- this.target = this.world.display.attachMovie(this.linkageID,"O" + this.uniqueID,0);
- }
- else
- {
- this.target = this.world.display.createEmptyMovieClip("O" + this.uniqueID,0);
- }
- this.target.owner = this;
- this.updateDepth();
- if(this.useRotation)
- {
- this.target._rotation = this.assetRotation;
- }
- this.inScene = true;
- this.onAddToScene();
- }
- function removeFromScene()
- {
- if(!this.inScene)
- {
- return undefined;
- }
- this.inScene = false;
- this.onRemoveFromScene();
- this.target.swapDepths(1048575);
- this.target.removeMovieClip();
- }
- function checkSectorLocation()
- {
- if(this.z > this.sector.z && this.sector.next)
- {
- this.sector.removeObject(this);
- while(this.sector = this.sector.next)
- {
- if(this.z <= this.sector.z)
- {
- break;
- }
- }
- this.sector.addObject(this);
- }
- else if(this.sector.previous && this.z <= this.sector.previous.z)
- {
- this.sector.removeObject(this);
- while(this.sector = this.sector.previous)
- {
- if(this.z > this.sector.previous.z)
- {
- break;
- }
- }
- this.sector.addObject(this);
- }
- }
- function moveTo(x, y, z)
- {
- if(x == this.x && y == this.y && z == this.z)
- {
- return undefined;
- }
- this.x = x;
- this.y = y;
- this.z = z;
- this.checkSectorLocation();
- this.updateDepth();
- this.onChanged();
- }
- function moveBy(x, y, z)
- {
- if(x || y || z)
- {
- this.x += x;
- this.y += y;
- this.z += z;
- this.checkSectorLocation();
- this.updateDepth();
- this.onChanged();
- }
- }
- function setAssetRotation(angle)
- {
- this.target._rotation = this.assetRotation = angle;
- }
- function setDisplay(offsetX, offsetY, offsetZ, depthRatio)
- {
- if(!this.renderable)
- {
- return undefined;
- }
- this.screenX = this.target._x = offsetX * depthRatio;
- this.screenY = this.target._y = offsetY * depthRatio;
- this.target._xscale = this.target._yscale = !this.useMinScale ? depthRatio * 100 : Math.max(depthRatio * 100,this.minScreenScale);
- this.onDisplay(offsetX,offsetY,offsetZ,depthRatio);
- }
- function attachSound(soundID, altTarget)
- {
- var _loc2_ = new Sound(!altTarget ? this.target : altTarget);
- _loc2_.attachSound(soundID);
- return _loc2_;
- }
- function setObjectSound(linkageID, altTarget)
- {
- this.objectSoundID = linkageID;
- if(this.sounds[linkageID])
- {
- return undefined;
- }
- var _loc0_ = null;
- var _loc3_ = this.sounds[linkageID] = this.attachSound(linkageID,_root);
- _loc3_.done = true;
- _loc3_.onSoundComplete = function()
- {
- this.done = true;
- this.length = this.duration;
- };
- }
- function playObjectSound()
- {
- var _loc2_ = this.sounds[this.objectSoundID];
- var _loc3_ = _loc2_.position;
- if(_loc2_.done || _loc2_.lastKnownTime != _loc3_ || _loc3_ == 0 || _loc2_.lastPlayAt + _loc2_.duration < getTimer())
- {
- _loc2_.lastKnownTime = _loc3_;
- _loc2_.lastPlayAt = getTimer();
- _loc2_.start();
- _loc2_.done = false;
- }
- }
- function toString()
- {
- return "Generic Object";
- }
- }
-