Example #1
0
		public void OnPlaced()
		{
			if (this._targets.Count > 0 || this._destroyTargets.Count > 0)
			{
				LocalPlayer.Sfx.PlayStructureBreak(base.gameObject, 0.1f);
			}
			if (BoltNetwork.isClient)
			{
				for (int i = 0; i < this._targets.Count; i++)
				{
					try
					{
						CutStructureHole cutStructureHole = CutStructureHole.Create(GlobalTargets.OnlyServer);
						cutStructureHole.TargetStructure = (this._targets[i] as MonoBehaviour).GetComponent<BoltEntity>();
						cutStructureHole.Position = this._holes[i]._position;
						cutStructureHole.YRotation = this._holes[i]._yRotation;
						cutStructureHole.Size = this._holes[i]._size;
						cutStructureHole.Send();
					}
					catch (Exception exception)
					{
						UnityEngine.Debug.LogException(exception);
					}
				}
				foreach (KeyValuePair<GameObject, FloorHoleArchitect.DestroyTarget> keyValuePair in this._destroyTargets)
				{
					try
					{
						if (keyValuePair.Value._bh)
						{
							keyValuePair.Value._bh.LocalizedHit(new LocalizedHitData
							{
								_damage = 13371337f,
								_distortRatio = 1f,
								_position = base.transform.position
							});
						}
						else
						{
							RemoveBuilding removeBuilding = RemoveBuilding.Create(GlobalTargets.OnlyServer);
							removeBuilding.TargetBuilding = keyValuePair.Value._go.GetComponent<BoltEntity>();
							removeBuilding.Send();
						}
					}
					catch (Exception exception2)
					{
						UnityEngine.Debug.LogException(exception2);
					}
					try
					{
						if (keyValuePair.Value._ghost)
						{
							keyValuePair.Value._ghost.transform.parent = null;
							UnityEngine.Object.Destroy(keyValuePair.Value._ghost);
						}
					}
					catch (Exception exception3)
					{
						UnityEngine.Debug.LogException(exception3);
					}
					keyValuePair.Value.Clear();
				}
				this._destroyTargets.Clear();
				UnityEngine.Object.Destroy(base.gameObject, 0.05f);
			}
			else
			{
				for (int j = 0; j < this._targets.Count; j++)
				{
					this._targets[j].CreateStructure(false);
					(this._targets[j] as MonoBehaviour).SendMessage("OnHolePlaced", SendMessageOptions.DontRequireReceiver);
					UnityEngine.Object.Destroy((this._previews[j] as MonoBehaviour).gameObject);
					this._previews[j] = null;
				}
				if (this._targets.Count > 0)
				{
					Vector3 vector = base.transform.position + new Vector3(this._holeSize.x, 0f, this._holeSize.y).RotateY(this._holes[0]._yRotation);
					Prefabs.Instance.SpawnHitPS(HitParticles.Wood, vector, Quaternion.LookRotation(base.transform.position - vector));
					vector = base.transform.position + new Vector3(this._holeSize.x, 0f, -this._holeSize.y).RotateY(this._holes[0]._yRotation);
					Prefabs.Instance.SpawnHitPS(HitParticles.Wood, vector, Quaternion.LookRotation(base.transform.position - vector));
					vector = base.transform.position + new Vector3(-this._holeSize.x, 0f, -this._holeSize.y).RotateY(this._holes[0]._yRotation);
					Prefabs.Instance.SpawnHitPS(HitParticles.Wood, vector, Quaternion.LookRotation(base.transform.position - vector));
					vector = base.transform.position + new Vector3(-this._holeSize.x, 0f, this._holeSize.y).RotateY(this._holes[0]._yRotation);
					Prefabs.Instance.SpawnHitPS(HitParticles.Wood, vector, Quaternion.LookRotation(base.transform.position - vector));
					this._holes.Clear();
					this._targets.Clear();
					this._previews.Clear();
				}
				foreach (KeyValuePair<GameObject, FloorHoleArchitect.DestroyTarget> keyValuePair2 in this._destroyTargets)
				{
					try
					{
						if (keyValuePair2.Value._bh)
						{
							if (!PlayerPreferences.NoDestruction)
							{
								keyValuePair2.Value._bh.LocalizedHit(new LocalizedHitData
								{
									_damage = keyValuePair2.Value._bh._maxHP * 2f,
									_distortRatio = 1f,
									_position = base.transform.position
								});
							}
							else
							{
								keyValuePair2.Value._bh.Collapse(base.transform.position);
							}
						}
						else if (keyValuePair2.Key)
						{
							keyValuePair2.Key.AddComponent<CollapseStructure>();
						}
					}
					catch (Exception exception4)
					{
						UnityEngine.Debug.LogException(exception4);
					}
					try
					{
						if (keyValuePair2.Value._ghost)
						{
							keyValuePair2.Value._ghost.transform.parent = null;
							UnityEngine.Object.Destroy(keyValuePair2.Value._ghost);
						}
					}
					catch (Exception exception5)
					{
						UnityEngine.Debug.LogException(exception5);
					}
					keyValuePair2.Value.Clear();
				}
				this._destroyTargets.Clear();
				UnityEngine.Object.Destroy(base.gameObject);
			}
		}
        public RedirectToRouteResult RemoveBuilding(RemoveBuilding model)
        {
            var campusId = FacilitiesSingleton.Facilities.GetParent(model.BuildingId);

            return(this.RedirectToAction <CampusController>(c => c.Details(campusId)));
        }