public bool SurvivalHostileDeaggro(double timeStamp) { if (!Player.Local.Surroundings.HasHostiles) { Hostile hostile = null; if (worlditem.Is <Hostile> (out hostile)) { hostile.Finish(); } } return(true); }
protected IEnumerator OnPlayerLeaveCamp() { for (int i = 0; i < SpawnedBandits.Count; i++) { Hostile hostile = null; if (SpawnedBandits [i].worlditem.Is <Hostile> (out hostile)) { hostile.Finish(); } yield return(null); } yield break; }
protected IEnumerator UpdateBehavior() { while (!motile.HasBody || !motile.Body.HasSpawned) { yield return(null); } Transform root = creature.Body.RootBodyPart.transform; Transform dropPoint = root.FindChild("OrbShellBot"); DropItems.SpawnPoints.Add(dropPoint.localPosition); dropPoint = root.FindChild("OrbShellTop"); DropItems.SpawnPoints.Add(dropPoint.localPosition); dropPoint = root.FindChild("OrbInnards"); DropItems.SpawnPoints.Add(dropPoint.localPosition); OrbFlarePlane = root.FindChild("OrbFlarePlane"); LocalFlareMaterial = OrbFlarePlane.GetComponent <Renderer> ().material; OrbSpotlightBottom = root.FindChild("OrbSpotlightBottom").GetComponent <Light>(); OrbSpotlightForward = root.FindChild("OrbSpotlightForward").GetComponent <Light>(); OrbPointLight = root.FindChild("OrbPointLight").GetComponent <Light>(); //we'll find the gem pivot and light pivot in the orb's root LuminiteGemPivot = root.FindChild("OrbLuminiteGemPivot"); LuminiteLightPivot = root.FindChild("OrbLuminiteLightPivot"); Transform luminiteBits = root.FindChild("OrbTrailRenderer"); LuminteTrail = luminiteBits.gameObject.GetComponent <TrailRenderer> (); luminiteBits = root.Find("OrbTrailParticles"); LuminiteParticles = luminiteBits.gameObject.GetComponent <ParticleSystem> (); PowerSource = worlditem.GetOrAdd <LuminitePowered> (); PowerSource.OnLosePower += OnLosePower; PowerSource.OnRestorePower += OnRestorePower; PowerSource.OnPowerSourceRemoved += OnPowerSourceRemoved; PowerSource.PowerSourceDopplegangerProps.CopyFrom(OrbGemGenericWorldItem); PowerSource.FXOnRestorePower = "ShieldEffectSubtleGold"; PowerSource.FXOnLosePower = "RipEffect"; PowerSource.FXOnPowerSourceRemoved = "ShieldEffectSubtleGold"; PowerSource.PowerSourceDopplegangerParent = LuminiteGemPivot; PowerSource.PowerAudio = root.FindChild("OrbPowerAudio").GetComponent <AudioSource>(); PowerSource.Refresh(); if (PowerSource.HasPower) { OnRestorePower(); StartCoroutine(Burrow(true)); } else { OnLosePower(); } yield return(null); while (worlditem.Is(WILoadState.Initialized)) { if (!PowerSource.HasPower) { BehaviorState = OrbBehaviorState.Unpowered; } else if (WorldClock.IsDay) { MeteorToGather = null; LuminiteToGather = null; ThingToInvestigate = null; BehaviorState = OrbBehaviorState.Burrowing; } IEnumerator nextTask = null; switch (BehaviorState) { case OrbBehaviorState.Awakening: nextTask = Burrow(true); break; case OrbBehaviorState.ConsideringOptions: nextTask = ConsiderOptions(); break; case OrbBehaviorState.SeekingMeteor: nextTask = SeekResources(true); break; case OrbBehaviorState.EatingMeteor: nextTask = MineResources(MeteorToGather); break; case OrbBehaviorState.SeekingLuminite: nextTask = SeekResources(false); break; case OrbBehaviorState.EatingLuminite: nextTask = MineResources(LuminiteToGather); break; case OrbBehaviorState.SeekingItemOfInterest: nextTask = SeekItemOfInterest(); break; case OrbBehaviorState.Unpowered: MeteorToGather = null; LuminiteToGather = null; ThingToInvestigate = null; if (worlditem.Is <Hostile> (out hostile)) { hostile.Finish(); } nextTask = WaitForPower(); break; case OrbBehaviorState.Burrowing: MeteorToGather = null; LuminiteToGather = null; ThingToInvestigate = null; if (worlditem.Is <Hostile> (out hostile)) { hostile.Finish(); } nextTask = Burrow(false); break; case OrbBehaviorState.Despawning: Debug.Log("Despawning"); //never save orb states if (thingsInvestigatedTonight != null) { thingsInvestigatedTonight.Clear(); thingsInvestigatedTonight = null; } break; } if (nextTask != null) { while (nextTask.MoveNext()) { yield return(nextTask.Current); } } double waitUntil = WorldClock.AdjustedRealTime + 0.5f; while (WorldClock.AdjustedRealTime < waitUntil) { yield return(null); } } mUpdatingBehavior = false; }