PlatformObject.activate C# (CSharp) Method

activate() public method

public activate ( int activator = -1 ) : void
activator int
return void
	public void activate(int activator = -1) {
		if (activatesOnlyOnce && hasActivated) {return;}
		if (!isPlayerControllable && activator == -2) {return;}
		if (!isMonsterControllable && activator == -3) {return;}

 
		activatedBy = activator;
		active = true;
		// extending = !extending;
		delayedTime = 0;
		if (!delaysBeforeActivation) {delayedTime = delay;}
		hasActivated = true;
		
		foreach (ControlPanel cp in GlobalData.map.controlPanels) {
			if (cp.platformSwitch == parent.id || cp.tagSwitch == mapTag) {
				cp.toggle();
			}
		}

		if (activatesAdjacentPlatformsWhenActivating) {
			MapSegment.Message message = new MapSegment.Message();
			message.activatePlatform = true;
			List<int> exclude = new List<int>();
			if (doesNotActivateParent) {exclude.Add(activator);}
			parent.sendMessage(message, exclude);
		}
		if (deactivatesAdjacentPlatformsWhenActivating) {
			MapSegment.Message message = new MapSegment.Message();
			message.deActivatePlatform = true;
			List<int> exclude = new List<int>();
			if (doesNotActivateParent) {exclude.Add(activator);}
			parent.sendMessage(message, exclude);
		}

		if (activatesLight) {
			foreach (MapSegmentSide s in parent.sides) {
				if (s.upperLight != null) s.upperLight.activate();
				if (s.middleLight != null) s.middleLight.activate();
				if (s.lowerLight != null) s.lowerLight.activate();
			}
			parent.floor.light.activate();
			parent.ceiling.light.activate();

		}


	}

Usage Example

    // returns the length of the created platform
    private PlatformObject spawnPlatform(int localIndex, ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately)
    {
        PlatformObject platform = (PlatformObject)infiniteObjectManager.objectFromPool(localIndex, ObjectType.Platform);

        platform.orient(position + (direction * platformSizes[localIndex].z / 2), Quaternion.LookRotation(direction));

        int            objectIndex     = infiniteObjectManager.localIndexToObjectIndex(localIndex, ObjectType.Platform);
        InfiniteObject prevTopPlatform = infiniteObjectHistory.objectSpawned(objectIndex, 0, location, ObjectType.Platform, platform);

        // the current platform now becames the parent of the previous top platform
        if (prevTopPlatform != null)
        {
            prevTopPlatform.setInfiniteObjectParent(platform);
        }
        else
        {
            infiniteObjectHistory.setBottomInfiniteObject(location, false, platform);
        }
        infiniteObjectHistory.addTotalDistance(platformSizes[localIndex].z, location, false);
        if (activateImmediately)
        {
            platform.activate();
        }

        return(platform);
    }