Unit factory - exclusively for UnitManager use
@param {SC2APIProtocol.Unit} unitData
@param {World} world
@returns {Unit}
354344
function createUnit(unitData, { data, resources }) {
    const { frame, units, actions } = resources.get();

    const { alliance } = unitData;

    const blueprint = {
        tag: unitData.tag,
        lastSeen: frame.getGameLoop(),
        noQueue: unitData.orders.length === 0,
        labels: new Map(),
        _availableAbilities: [],
        async burrow() {
            if (this.is(UnitType.WIDOWMINE)) {
                return actions.do(Ability.BURROWDOWN, this.tag);
            }
        },
        async toggle(options = {}) {
            const opts = {
                queue: true,
                ...options
            };

            if (this.is(UnitType.WARPPRISM)) {
                return actions.do(Ability.MORPH_WARPPRISMPHASINGMODE, this.tag, opts);
            } else if (this.is(UnitType.WARPPRISMPHASING)) {
                return actions.do(Ability.MORPH_WARPPRISMTRANSPORTMODE, this.tag, opts);
            } else if (this.is(UnitType.LIBERATOR)) {
                return actions.do(Ability.MORPH_LIBERATORAGMODE, this.tag, opts);
            } else if (this.is(UnitType.LIBERATORAG)) {
                return actions.do(Ability.MORPH_LIBERATORAAMODE, this.tag, opts);
            }
        },
        addLabel(name, value) {
            return this.labels.set(name, value);
        },
        hasLabel(name) {
            return this.labels.has(name);
        },
        removeLabel(name) {
            return this.labels.delete(name);
        },
        hasNoLabels() {
            return [...this.labels.keys()].length <= 0;
        },
        getLabel(name) {
            return this.labels.get(name);
        },
        abilityAvailable(id) {
            return this._availableAbilities.includes(id);
        },
        availableAbilities() {
            return this._availableAbilities;
        },
        data() {
            return data.getUnitTypeData(this.unitType);
        },
        is(type) {
            return this.unitType === type;
        },
        isConstructing() {
            return this.orders.some(o => constructionAbilities.includes(o.abilityId));
        },
        isCombatUnit() {
            return combatTypes.includes(this.unitType);
        },
        isFinished() {
            return this.buildProgress >= 1;
        },
        isHolding() {
            return this.orders.some(o => o.abilityId === Ability.HOLDPOSITION);
        },
        isTownhall() {
            return townhallTypes.includes(this.unitType);
        },
        isWorker() {
            return workerTypes.includes(this.unitType);
        },
        isMineralField() {
            return mineralFieldTypes.includes(this.unitType);
        },
        isGasMine() {
            return gasMineTypes.includes(this.unitType);
        },
        isReturning() {
            return this.orders.some(o => returningAbilities.includes(o.abilityId));
        },
        isGathering(type) {
            return this.orders.some(o => {
                if (gatheringAbilities.includes(o.abilityId)) {
                    if (!type) return true;

                    const gatherTarget = units.getByTag(o.targetUnitTag);

                    if (gatherTarget) {
                        if (type === 'minerals') {
                            return gatherTarget.isMineralField();
                        }
    
                        if (type === 'vespene') {
                            return gatherTarget.isGasMine();
                        }
                    }
                }
            });
        },
        isCurrent() {
            // if this unit wasn't updated this frame, this will be false
            return this.lastSeen === frame.getGameLoop();
        },
        isStructure() {
            return this.data().attributes.includes(Attribute.STRUCTURE);
        },
        hasReactor() {
            const addon = units.getByTag(this.addOnTag);
            return reactorTypes.includes(addon.unitType);
        },
        hasTechLab() {
            const addon = units.getByTag(this.addOnTag);
            return techLabTypes.includes(addon.unitType);
        },
        canMove() {
            return this._availableAbilities.includes(Ability.MOVE);
        },
        canShootUp() {
            return this.data().weapons.some(w => w.type !== WeaponTargetType.GROUND);
        },
        update(unit) {
            Object.assign(this, unit, {
                noQueue: unit.orders.length === 0,
                lastSeen: frame.getGameLoop(),
            });

            /**
             * so this is a perf thing - depending on the version of node it actually
             * made a pretty big difference... but as of v10 it seems okay? keeping
             * for posterity -
             *
             * this.displayType = unit.displayType;
             * this.alliance = unit.alliance;
             * this.unitType = unit.unitType;
             * this.owner = unit.owner;
             * this.pos = unit.pos;
             * this.facing = unit.facing;
             * this.radius = unit.radius;
             * this.buildProgress = unit.buildProgress;
             * this.cloak = unit.cloak;
             * this.detectRange = unit.detectRange;
             * this.radarRange = unit.radarRange;
             * this.isSelected = unit.isSelected;
             * this.isOnScreen = unit.isOnScreen;
             * this.isBlip = unit.isBlip;
             * this.isPowered = unit.isPowered;
             * this.health = unit.health;
             * this.healthMax = unit.healthMax;
             * this.shield = unit.shield;
             * this.shieldMax = unit.shieldMax;
             * this.energy = unit.energy;
             * this.energyMax = unit.energyMax;
             * this.mineralContents = unit.mineralContents;
             * this.vespeneContents = unit.vespeneContents;
             * this.isFlying = unit.isFlying;
             * this.isBurrowed = unit.isBurrowed;
             * this.orders = unit.orders;
             * this.addOnTag = unit.addOnTag;
             * this.passengers = unit.passengers;
             * this.cargoSpaceTaken = unit.cargoSpaceTaken;
             * this.cargoSpaceMax = unit.cargoSpaceMax;
             * this.buffIds = unit.buffIds;
             * this.assignedHarvesters = unit.assignedHarvesters;
             * this.idealHarvesters = unit.idealHarvesters;
             * this.weaponCooldown = unit.weaponCooldown;
             * this.engagedTargetTag = unit.engagedTargetTag;
             * this.noQueue = unit.orders.length === 0;
             * this.lastSeen = frame.getGameLoop();
             */
        },
    };

    // i promise there's a reason for this that one day i'll figure out
    switch (alliance) {
        case Alliance.ALLY:
        case Alliance.SELF: {
            return {
                ...unitData,
                ...blueprint,
            };
        }
        case Alliance.ENEMY: {
            return {
                ...unitData,
                ...blueprint,
            };
        }
        case Alliance.NEUTRAL: {
            return {
                ...unitData,
                ...blueprint,
            };
        }
        default: {
            throw new Error('CANT CREATE A UNIT WITH NO ALLIANCE, THIS SHOULD NEVER HAPPEN');
        }
    }
}
753857
function (oldData) {
    var data = this.data;
    var el = this.el;
    var raycaster = this.raycaster;

    // Set raycaster properties.
    raycaster.far = data.far;
    raycaster.near = data.near;

    // Draw line.
    if (data.showLine &&
        (data.far !== oldData.far || data.origin !== oldData.origin ||
         data.direction !== oldData.direction || !oldData.showLine)) {
      // Calculate unit vector for line direction. Can be multiplied via scalar to performantly
      // adjust line length.
      this.unitLineEndVec3.copy(data.origin).add(data.direction).normalize();
      this.drawLine();
    }

    if (!data.showLine && oldData.showLine) {
      el.removeAttribute('line');
    }

    if (data.objects !== oldData.objects && !OBSERVER_SELECTOR_RE.test(data.objects)) {
      warn('[raycaster] Selector "' + data.objects +
           '" may not update automatically with DOM changes.');
    }

    if (!data.objects) {
      warn('[raycaster] For performance, please define raycaster.objects when using ' +
           'raycaster or cursor components to whitelist which entities to intersect with. ' +
           'e.g., raycaster="objects: [data-raycastable]".');
    }

    if (data.autoRefresh !== oldData.autoRefresh && el.isPlaying) {
      data.autoRefresh
        ? this.addEventListeners()
        : this.removeEventListeners();
    }

    if (oldData.enabled && !data.enabled) { this.clearAllIntersections(); }

    this.setDirty();
  }
92550
function( world ){

            if ( this.disconnect && this._world ){
                this.disconnect( this._world );
            }

            this._world = world;

            if ( this.connect && world ){
                this.connect( world );
            }

            return this;
        }
955645
function factory(BaseClass, mapFunction) {
  function subject(value) {
    if (typeof mapFunction === 'function') {
      value = mapFunction.apply(undefined, arguments);
    } else if (typeof mapFunction !== 'undefined') {
      value = mapFunction;
    }
    subject.onNext(value);
    return value;
  }
  
  for (var key in BaseClass.prototype) {
    subject[key] = BaseClass.prototype[key];
  }

  BaseClass.apply(subject, [].slice.call(arguments, 2));

  return subject;
}
723084
function createPlatformFactory(parentPlaformFactory, name, providers) {
	        if (providers === void 0) { providers = []; }
	        var marker = new OpaqueToken("Platform: " + name);
	        return function (extraProviders) {
	            if (extraProviders === void 0) { extraProviders = []; }
	            if (!getPlatform()) {
	                if (parentPlaformFactory) {
	                    parentPlaformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
	                }
	                else {
	                    createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
	                }
	            }
	            return assertPlatform(marker);
	        };
	    }
726397
function getAbbr(wofData) {
  const iso2 = getPropertyValue(wofData, 'wof:country');

  // sometimes there are codes set to XX which cause an exception so check if it's a valid ISO2 code
  if (iso2 !== false && iso3166.is2(iso2)) {
    return iso3166.to3(iso2);
  }

  return null;
}
433872
function loadUnit(
  {
    name,
    character,
    color,
    maxHealth,
    reward,
    enemy,
    bound,
    abilities,
    effects,
    playTurn,
    position,
  },
  floor,
) {
  const unit = new Unit(
    name,
    character,
    color,
    maxHealth,
    reward,
    enemy,
    bound,
  );
  loadAbilities(unit, abilities);
  loadEffects(unit, effects);
  unit.playTurn = playTurn;
  floor.addUnit(unit, position);
}
900938
function groupsFactory() {
  let list = []

  const getGroupsByRoot = function(root) {
    for (let i = 0; i < list.length; i++) {
      let groups = list[i]
      if (groups.rootEl === root) {
        return groups
      }
    }
    return null
  }

  return {
    add: function(root, group) {
      let groups = getGroupsByRoot(root)
      if (!groups) {
        groups = new Groups(root, [])
        list.push(groups)
      }
      if (group) {
        group._list = groups
        group.resolve()

        groups.add(group)
      }
    },
    groups: function() {
      return list.length === 1 ? list[0] : list
    }
  }
}
931978
function createPlatformFactory(parentPlatformFactory, name, providers) {
    if (providers === void 0) { providers = []; }
    var desc = "Platform: " + name;
    var marker = new InjectionToken(desc);
    return function (extraProviders) {
        if (extraProviders === void 0) { extraProviders = []; }
        var platform = getPlatform();
        if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
            if (parentPlatformFactory) {
                parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
            }
            else {
                var injectedProviders = providers.concat(extraProviders).concat({ provide: marker, useValue: true });
                createPlatform(Injector.create({ providers: injectedProviders, name: desc }));
            }
        }
        return assertPlatform(marker);
    };
}
1283172
function xhrSimpleDataSerializer(data) {
  var uri = [];
  var key;
  for (key in data) {
    uri.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
  }
  return uri.join('&');
}
922560
function getAdjustedUnit(ms, fn) {
  var unitIndex = 0, value = 0;
  iterateOverDateUnits(function(unit, i) {
    value = abs(fn(unit));
    if (value >= 1) {
      unitIndex = i;
      return false;
    }
  });
  return [value, unitIndex, ms];
}
866617
function getUnit(property, unit) {
  let propertyUnit = unit || DEFAULT_UNIT;

  if (ANGLE_PROPERTIES.indexOf(property) >= 0) {
    propertyUnit = unit || DEFAULT_ANGLE_UNIT;
  }

  return propertyUnit;
}
309144
private World world(IBlockAccess world)
	{
		if (world instanceof World)
			return (World) world;
		else if (world instanceof ChunkCache)
			return ((ChunkCache) world).world;

		if (!FMLClientHandler.instance().hasOptifine())
			return null;
		if (chunkCacheClass == null || chunkCacheField != null)
			return null;
		if (!chunkCacheClass.isAssignableFrom(world.getClass()))
			return null;

		return world(Silenced.get(() -> ((ChunkCache) chunkCacheField.get(world))));
	}
838856
function getHeapStatistics(unitInfo) {
  const data = v8.getHeapStatistics();
  const keys = Object.keys(data);
  const result = {};
  keys.forEach((key) => {
    result[key] = format(data[key], unitInfo);
  });
  return result;
}
272905
def create(*units):
    """"""
    ret = []
    for unit in units: # implemented using sc2simulator.ScenarioUnit
        x, y = unit.position[:2]
        pt = Point2D(x=x, y=y)
        unit.tag = 0 # forget any tag because a new unit will be created
        new = DebugCommand(create_unit=DebugCreateUnit(
            unit_type   = unit.code,
            owner       = unit.owner,
            pos         = pt,
            quantity    = 1,
        ))
        ret.append(new)
    return ret
1345411
function _getWorldRotationFromLocalRotation(transform) {
  if(transform.parent === undefined)
    return transform.localRotation;
  else
    return transform.parent.rotation.mul(transform.localRotation);
}
359342
def wa(self, chamber):
        
        if isinstance(chamber, int):
            chamber = str(chamber)
        return WorldAssembly(chamber, self)