public override void OnInitialized() { bodyofwater = worlditem.GetComponent <BodyOfWater> (); bool flooded = false; MissionStatus status = MissionStatus.Dormant; if (Missions.Get.MissionStatusByName(MissionName, ref status)) { if (Flags.Check((uint)MissionStatus.Dormant, (uint)status, Flags.CheckType.MatchAny)) { //if the mission hasn't started, water level is normal //Debug.Log ("Mission status was dormant, water is flooded"); flooded = true; } else { //if the mission has started OR been completed, water level is based on variable if (Missions.Get.GetVariableValue(MissionName, VariableName) <= 0) { //Debug.Log ("Mission variable was less than or equal to zero, water is flooded"); flooded = true; } } } mCurrentWaterLevel = 0f; if (flooded) { worlditem.OnVisible += OnVisible; worlditem.OnInvisible += OnInvisible; TargetWaterLevel = State.LakeWaterLevelHigh; } else { TargetWaterLevel = State.LakeWaterLevelNormal; } StartCoroutine(SetFlooded(flooded)); if (flooded) { Debug.Log("Subscribing to mission variable change in behemoth dam"); Player.Get.AvatarActions.Subscribe(AvatarAction.MissionVariableChange, new ActionListener(MissionVariableChange)); } }
protected void FindWater() { if (Physics.Raycast(worlditem.Position + Vector3.up * 10, Vector3.down, out mWaterHit, 100f, Globals.LayerFluidTerrain)) { WorldItem bodyOfWaterWorlditem = null; BodyOfWater bodyOfWater = null; Ocean ocean = null; if (mWaterHit.collider.attachedRigidbody.gameObject.HasComponent <WorldItem>(out bodyOfWaterWorlditem) && bodyOfWaterWorlditem.Is <BodyOfWater>(out bodyOfWater)) { Water = bodyOfWater; } else if (mWaterHit.collider.attachedRigidbody.gameObject.HasComponent <Ocean>(out ocean)) { Water = ocean; } else { State.IsSubmerged = false; enabled = false; return; } } }
protected IEnumerator WaitForBodiesOfWater() { bool waitForTop = !string.IsNullOrEmpty(State.TopBodyOfWaterPath); bool waitForBottom = !string.IsNullOrEmpty(State.BottomBodyOfWaterPath); while (waitForTop | waitForBottom) { if (waitForTop) { WorldItem bodyOfWaterWorlditem = null; if (WIGroups.FindChildItem(State.TopBodyOfWaterPath, out bodyOfWaterWorlditem)) { BodyOfWater bodyOfWater = bodyOfWaterWorlditem.Get <BodyOfWater> (); WaterfallTopFollow = bodyOfWater.WaterPivot.transform; waitForTop = false; } } if (waitForBottom) { WorldItem bodyOfWaterWorlditem = null; if (WIGroups.FindChildItem(State.BottomBodyOfWaterPath, out bodyOfWaterWorlditem)) { BodyOfWater bodyOfWater = bodyOfWaterWorlditem.Get <BodyOfWater> (); WaterfallBottomFollow = bodyOfWater.WaterPivot.transform; waitForBottom = false; } } double waitUntil = Frontiers.WorldClock.AdjustedRealTime + 0.5f; while (Frontiers.WorldClock.AdjustedRealTime < waitUntil) { yield return(null); } //Debug.Log ("Waiting for top / bottom: " + waitForTop.ToString () + " / " + waitForBottom.ToString ()); } enabled = true; yield break; }