public PrefabInstance FindPrefabsNear() { var pos = this.theEntity.position; EntityPlayer player = null; if (this.theEntity.Buffs.HasCustomVar("Leader")) { player = theEntity.world.GetEntity((int)this.theEntity.Buffs.GetCustomVar("Leader")) as EntityPlayerLocal; } else { return(null); } if (theEntity) { DynamicPrefabDecorator dynamicPrefabDecorator = GameManager.Instance.World.ChunkCache.ChunkProvider.GetDynamicPrefabDecorator(); if (dynamicPrefabDecorator == null) { return(null); } Vector3 position = player.position; int num = (player.ChunkObserver == null) ? GamePrefs.GetInt(EnumGamePrefs.OptionsViewDistance) : player.ChunkObserver.viewDim; num = (num - 1) * 16; if (!player.isEntityRemote) { dynamicPrefabDecorator.GetPrefabsAround(position, (float)num, (float)1000f, this.prefabsAroundFar, this.prefabsAroundNear, true); GameManager.Instance.prefabLODManager.UpdatePrefabsAround(this.prefabsAroundFar, this.prefabsAroundNear); } return(this.prefabsAroundNear.Values.FirstOrDefault(d => pos.x >= d.boundingBoxPosition.x && pos.x < d.boundingBoxPosition.x + d.boundingBoxSize.x && pos.z >= d.boundingBoxPosition.z && pos.z < d.boundingBoxPosition.z + d.boundingBoxSize.z)); } return(null); }
public PrefabInstance FindPrefabsNear() { var pos = this.theEntity.position; EntityPlayer player = null; if (this.theEntity.Buffs.HasCustomVar("Owner")) { player = theEntity.world.GetEntity((int)this.theEntity.Buffs.GetCustomVar("Owner")) as EntityPlayerLocal; } else { DisplayLog("I do not have a leader."); return(null); } if (player) { DynamicPrefabDecorator dynamicPrefabDecorator = GameManager.Instance.World.ChunkCache.ChunkProvider.GetDynamicPrefabDecorator(); if (dynamicPrefabDecorator == null) { DisplayLog("FindPrefabsNear(): No Prefab Decorator found"); return(null); } Vector3 position = player.position; int num = (player.ChunkObserver == null) ? GamePrefs.GetInt(EnumGamePrefs.OptionsGfxViewDistance) : player.ChunkObserver.viewDim; num = (num - 1) * 16; if (!player.isEntityRemote) { this.prefabsAroundFar.Clear(); this.prefabsAroundNear.Clear(); DisplayLog(" Entity is not remote. Grabbing prefab lists."); dynamicPrefabDecorator.GetPrefabsAround(position, (float)num, (float)1000f, this.prefabsAroundFar, this.prefabsAroundNear, true); GameManager.Instance.prefabLODManager.UpdatePrefabsAround(this.prefabsAroundFar, this.prefabsAroundNear); } DisplayLog(" Checking Boundary Box"); return(this.prefabsAroundNear.Values.FirstOrDefault(d => pos.x >= d.boundingBoxPosition.x && pos.x < d.boundingBoxPosition.x + d.boundingBoxSize.x && pos.z >= d.boundingBoxPosition.z && pos.z < d.boundingBoxPosition.z + d.boundingBoxSize.z)); } DisplayLog(" No Prefabs"); return(null); }