private IEnumerator Start() { base.enabled = false; this._offsetWithPlacer = base.transform.localPosition; yield return(YieldPresets.WaitForEndOfFrame); GameObject trigger = this._freeGo.transform.GetChild(0).Find("Trigger").gameObject; GameObject trigger2 = this._snappedGo.transform.GetChild(0).Find("Trigger").gameObject; trigger.SetActive(false); trigger2.SetActive(false); Craft_Structure tmpCraftStructure = trigger.GetComponent <Craft_Structure>(); Craft_Structure tmpCraftStructure2 = trigger2.GetComponent <Craft_Structure>(); LocalPlayer.Create.CraftStructures.Add(tmpCraftStructure); LocalPlayer.Create.CraftStructures.Add(tmpCraftStructure2); yield return(null); this._snappedGo.SetActive(false); this._freeGo.SetActive(false); this._snappedRenderer = this._snappedGo.transform.GetChild(0).GetComponent <Renderer>(); this._freeRenderer = this._freeGo.transform.GetChild(0).GetComponent <Renderer>(); base.enabled = true; yield break; }
private IEnumerator DelayedAwake(bool isDeserializing) { this._logPool = new Stack <Transform>(); this._newPool = new Stack <Transform>(); this._logMat = new Material(this._logRenderer.sharedMaterial); this._raftRoot = new GameObject("RaftRoot").transform; this._raftRoot.position = base.transform.position; this._raftRoot.rotation = base.transform.rotation; if (this._multiPointsPositions == null) { this._multiPointsPositions = new List <Vector3>(5); } if (this._holes == null) { this._holes = new List <Hole>(); } if (this._logPrefab.GetComponent <Renderer>()) { this._logLength = this._logPrefab.GetComponent <Renderer>().bounds.size.z; this._logWidth = this._logPrefab.GetComponent <Renderer>().bounds.size.x; } else { this._logLength = this._logRenderer.bounds.size.z; this._logWidth = this._logRenderer.bounds.size.x; } this._maxChunkLength = this._logLength * this._maxLogScale; this._minChunkLength = this._logLength * this._minLogScale; yield return(null); if (this._wasBuilt && !isDeserializing) { base.StartCoroutine(this.OnDeserialized()); if (!BoltNetwork.isClient && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(base.gameObject, true); } } else if (this._craftStructure) { Craft_Structure craftStructure = this._craftStructure; craftStructure.OnBuilt = (Action <GameObject>)Delegate.Combine(craftStructure.OnBuilt, new Action <GameObject>(this.OnBuilt)); this._craftStructure._playTwinkle = false; if (LocalPlayer.Create) { LocalPlayer.Create.Grabber.ClosePlace(); } } if (isDeserializing || this._wasPlaced || this._wasBuilt) { base.enabled = false; } else { base.GetComponent <Renderer>().sharedMaterial = this._logMat; base.enabled = true; } yield break; }
private IEnumerator DelayedAwake(bool isDeserializing) { this._logPool = new Stack <Transform>(); this._newPool = new Stack <Transform>(); this._craneRoot = new GameObject("CraneRoot").transform; this._logMat = ((!this._wasPlaced && !this._wasBuilt) ? new Material(this._logRenderer.sharedMaterial) : this._logRenderer.sharedMaterial); if (this._logPrefab.GetComponent <Renderer>()) { this._logLength = this._logPrefab.GetComponent <Renderer>().bounds.size.z; } else { this._logLength = this._logRenderer.bounds.size.z; } yield return(null); if (this._wasBuilt) { if (!isDeserializing) { this.OnDeserialized(); if (!BoltNetwork.isClient && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(base.gameObject, true); } } } else { if (this._wasPlaced) { UnityEngine.Object.Destroy(this._holeCutter.gameObject); this.OnDeserialized(); } else { if (!CoopPeerStarter.DedicatedHost && LocalPlayer.Create.BuildingPlacer) { LocalPlayer.Create.Grabber.ClosePlace(); } LocalPlayer.Create.BuildingPlacer.SetRenderer(null); } if (this._craftStructure) { Craft_Structure craftStructure = this._craftStructure; craftStructure.OnBuilt = (Action <GameObject>)Delegate.Combine(craftStructure.OnBuilt, new Action <GameObject>(this.OnBuilt)); } } if (isDeserializing || this._wasBuilt || this._wasPlaced) { base.enabled = false; } else { base.enabled = true; } yield break; }
private void OnBuilt(GameObject built) { GardenArchitect component = built.GetComponent <GardenArchitect>(); component._wasBuilt = true; component._size = this._size; Craft_Structure craftStructure = this._craftStructure; craftStructure.OnBuilt = (Action <GameObject>)Delegate.Remove(craftStructure.OnBuilt, new Action <GameObject>(this.OnBuilt)); }
private IEnumerator DelayedAwake(bool isDeserializing) { this._logPool = new Stack <Transform>(); this._newPool = new Stack <Transform>(); this._coasterRoot = new GameObject("CoasterRoot").transform; if (this._multiPointsPositions == null) { this._multiPointsPositions = new List <Vector3>(5); } Renderer foundRenderer = this._logPrefabs[0].GetComponentInChildren <Renderer>(); if (foundRenderer) { this._logLength = foundRenderer.bounds.size.z; this._logWidth = foundRenderer.bounds.size.x; this._logHeight = foundRenderer.bounds.size.y; } else { this._logLength = this._logRenderer.bounds.size.z; this._logWidth = this._logRenderer.bounds.size.x; this._logHeight = this._logRenderer.bounds.size.y; } yield return(null); if (this._wasBuilt && !isDeserializing) { this.OnDeserialized(); if (!BoltNetwork.isClient && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(base.gameObject, true); } } else if (this._craftStructure) { this._craftStructure.CustomLockCheck = new Func <bool>(this.ArePlayersInside); Craft_Structure craftStructure = this._craftStructure; craftStructure.OnBuilt = (Action <GameObject>)Delegate.Combine(craftStructure.OnBuilt, new Action <GameObject>(this.OnBuilt)); this._craftStructure._playTwinkle = false; if (LocalPlayer.Create) { LocalPlayer.Create.Grabber.ClosePlace(); } } if (isDeserializing || this._wasPlaced || this._wasBuilt) { base.enabled = false; } else { base.enabled = true; } yield break; }
public void OnBuilt(GameObject built) { CraneArchitect component = built.GetComponent <CraneArchitect>(); component._wasBuilt = true; component._aboveGround = this._aboveGround; component._bottomY = this._bottomY; if (this._craftStructure) { Craft_Structure craftStructure = this._craftStructure; craftStructure.OnBuilt = (Action <GameObject>)Delegate.Remove(craftStructure.OnBuilt, new Action <GameObject>(this.OnBuilt)); } }
private void OnBuilt(GameObject built) { FoundationArchitect foundationArchitect = built.GetComponent <FoundationArchitect>(); if (!foundationArchitect) { foundationArchitect = built.AddComponent <FoundationArchitect>(); foundationArchitect.Clone(this); foundationArchitect._logPrefab = Prefabs.Instance.LogBuiltPrefab; } foundationArchitect._multiPointsPositions = this._multiPointsPositions; foundationArchitect._wasBuilt = true; foundationArchitect.OnSerializing(); foundationArchitect._aboveGround = this._aboveGround; Craft_Structure craftStructure = this._craftStructure; craftStructure.OnBuilt = (Action <GameObject>)Delegate.Remove(craftStructure.OnBuilt, new Action <GameObject>(this.OnBuilt)); }
private IEnumerator Start() { base.enabled = false; yield return(null); GameObject trigger = this._outWaterGo.transform.GetChild(0).Find("Trigger").gameObject; GameObject trigger2 = this._inWaterGo.transform.GetChild(0).Find("Trigger").gameObject; trigger.SetActive(false); trigger2.SetActive(false); Craft_Structure tmpCraftStructure = trigger.GetComponent <Craft_Structure>(); Craft_Structure tmpCraftStructure2 = trigger2.GetComponent <Craft_Structure>(); LocalPlayer.Create.CraftStructures.Add(tmpCraftStructure); LocalPlayer.Create.CraftStructures.Add(tmpCraftStructure2); yield return(null); this._outWaterGo.SetActive(false); this._inWaterGo.SetActive(false); this._inWaterRenderer = this._outWaterGo.transform.GetChild(0).GetComponent <Renderer>(); this._outWaterRenderer = this._inWaterGo.transform.GetChild(0).GetComponent <Renderer>(); base.enabled = true; yield break; }
private IEnumerator DelayedAwake(bool isDeserializing) { this._logPool = new Stack <Transform>(); this._newPool = new Stack <Transform>(); this._edges = new List <FoundationArchitect.Edge>(); this._foundationRoot = new GameObject("FoundationRoot"); this._edgesGo = new List <GameObject>(5); if (this._multiPointsPositions == null) { this._multiPointsPositions = new List <Vector3>(5); } if (this._logPrefab.GetComponent <Renderer>()) { this._logLength = this._logPrefab.GetComponent <Renderer>().bounds.size.z; this._logWidth = this._logPrefab.GetComponent <Renderer>().bounds.size.x; } else { this._logLength = this._logRenderer.bounds.size.z; this._logWidth = this._logRenderer.bounds.size.x; } this._maxHeightWithoutDiagonal = this._maxHeightPercentWithoutDiagonal * this._logLength; this._maxSegmentHorizontalLength = this._logLength * this._maxLogScale; this._minEdgeLength = this._logWidth; this.MaxHeight = 0f; yield return(null); if (this._wasBuilt && !isDeserializing) { this.OnDeserialized(); if (this._mode == FoundationArchitect.Modes.Manual && !BoltNetwork.isClient && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(base.gameObject, true); } } else if (this._craftStructure) { this._craftStructure.CustomLockCheck = new Func <bool>(this.ArePlayersBellow); if (this._wasPlaced && this._multiPointsPositions.Count > 0) { this._craftStructure.TriggerOffset = this.SupportCenter - this._craftStructure.transform.position; } Craft_Structure craftStructure = this._craftStructure; craftStructure.OnBuilt = (Action <GameObject>)Delegate.Combine(craftStructure.OnBuilt, new Action <GameObject>(this.OnBuilt)); if (this._mode == FoundationArchitect.Modes.Manual) { this._craftStructure._playTwinkle = false; if (LocalPlayer.Create) { LocalPlayer.Create.Grabber.ClosePlace(); } } } if (this._mode == FoundationArchitect.Modes.ManualSlave) { this.Enslaved = true; } if (isDeserializing || this._wasBuilt || this._wasPlaced) { base.enabled = false; } else { base.enabled = true; } yield break; }
public void CreateBuilding(BuildingTypes type) { this._currentBlueprint = Prefabs.Instance.Constructions._blueprints.Find((BuildingBlueprint bp) => bp._type == type); if (this._currentBlueprint == null) { Debug.LogError("Building blueprint not found on Create script for " + type); } else { this.InitPlacer(this._currentBlueprint); if (!BoltNetwork.isRunning || !this._currentBlueprint._ghostPrefabMP) { this._currentGhost = UnityEngine.Object.Instantiate <GameObject>(this._currentBlueprint._ghostPrefab); } else { this._currentGhost = UnityEngine.Object.Instantiate <GameObject>(this._currentBlueprint._ghostPrefabMP); } this._currentGhost.transform.parent = this._buildingPlacer.transform; this._currentGhost.transform.localRotation = Quaternion.identity; Transform transform = this._currentGhost.transform.Find("Trigger"); Craft_Structure component = transform.GetComponent <Craft_Structure>(); if (component) { this.CraftStructures.Add(component); } transform.gameObject.SetActive(false); Renderer component2 = this._currentGhost.GetComponent <Renderer>(); if (component2) { component2.enabled = false; base.StartCoroutine(this.EnableRendererAfterDelay(component2)); } Transform transform2 = this._currentGhost.transform.Find("LastBuiltLocation"); if (transform2) { transform2.gameObject.SetActive(false); } this._currentGhost.transform.localPosition = this.GetGhostOffsetWithPlacer(this._currentGhost); this._buildingPlacer.TreeStructure = this._currentBlueprint._allowInTree; this._buildingPlacer.IgnoreLookAtCollision = this._currentBlueprint._ignoreLookAtCollision; this._buildingPlacer.IgnoreBlock = this._currentBlueprint._ignoreBlock; this._buildingPlacer.AllowFoundation = this._currentBlueprint._allowFoundation; this._buildingPlacer.Airborne = this._currentBlueprint._airBorne; IAnchorValidation component3 = this._currentGhost.GetComponent <IAnchorValidation>(); if (component3 != null) { this._buildingPlacer.ValidateAnchor = new Func <Transform, bool>(component3.ValidateAnchor); } this._buildingPlacer.ShowAnchorArea.SetActive(this._currentBlueprint._showAnchors); this._buildingPlacer.ShowSupportAnchorArea.SetActive(this._currentBlueprint._showSupportAnchor); if (this._currentBlueprint._waterborne) { this._buildingPlacer.SetWaterborne(this._currentBlueprint._waterborneExclusive); } if (this._currentBlueprint._hydrophobic) { this._buildingPlacer.SetHydrophobic(); } this.BeginCoolDown(); this.CreateMode = true; this.LockPlace = true; this.ShouldOpenBook = false; this.Inventory.EquipPreviousUtility(true); } }
private bool TryAddTarget(PrefabIdentifier pi, Collider c) { if (pi) { IHoleStructure holeStructure = (IHoleStructure)pi.GetComponent(typeof(IHoleStructure)); if (holeStructure != null) { if (!this._targets.Contains(holeStructure) && holeStructure.HoleCount < 20) { Hole item; if (holeStructure is FloorArchitect) { if (!this._previewFloor || !(holeStructure as FloorArchitect).WasBuilt) { return false; } FloorArchitect floorArchitect = holeStructure as FloorArchitect; FloorArchitect floorArchitect2 = UnityEngine.Object.Instantiate<FloorArchitect>(this._previewFloor, floorArchitect.transform.position, floorArchitect.transform.rotation); floorArchitect.OnBuilt(floorArchitect2.gameObject); floorArchitect2._wasBuilt = false; this._previews.Add(floorArchitect2); item = floorArchitect2.AddSquareHole(base.transform.position, base.transform.rotation.y, this._holeSize); } else if (holeStructure is RoofArchitect) { if (!this._previewRoof || !(holeStructure as RoofArchitect).WasBuilt) { return false; } RoofArchitect roofArchitect = holeStructure as RoofArchitect; RoofArchitect roofArchitect2 = UnityEngine.Object.Instantiate<RoofArchitect>(this._previewRoof, roofArchitect.transform.position, roofArchitect.transform.rotation); roofArchitect.OnBuilt(roofArchitect2.gameObject); roofArchitect2._wasBuilt = false; this._previews.Add(roofArchitect2); item = roofArchitect2.AddSquareHole(base.transform.position, base.transform.rotation.y, this._holeSize); } else { if (holeStructure is CraneArchitect) { return false; } if (!(holeStructure is RaftArchitect) || !(holeStructure as RaftArchitect).WasBuilt) { UnityEngine.Debug.LogError("Trying to cut IHS '" + pi.name + "' which isn't roof, floor or raft. Please report this to guillaume."); return false; } if (!this._previewRaft || !(base.transform.root != pi.transform.root)) { return false; } RaftArchitect raftArchitect = holeStructure as RaftArchitect; RaftArchitect raftArchitect2 = UnityEngine.Object.Instantiate<RaftArchitect>(this._previewRaft, raftArchitect.transform.position, raftArchitect.transform.rotation); raftArchitect.OnBuilt(raftArchitect2.gameObject); this._previews.Add(raftArchitect2); item = raftArchitect2.AddSquareHole(base.transform.position, base.transform.rotation.y, this._holeSize); } this._targets.Add(holeStructure); this._holes.Add(item); this.CheckCanPlace(); return true; } } else { BuildingBlueprint blueprintByPrefabId = Prefabs.Instance.Constructions.GetBlueprintByPrefabId(pi.ClassId); if (blueprintByPrefabId != null && !blueprintByPrefabId._preventHoleCutting) { FloorHoleArchitect.DestroyTarget destroyTarget; if (!this._destroyTargets.TryGetValue(pi.gameObject, out destroyTarget)) { destroyTarget = new FloorHoleArchitect.DestroyTarget(); destroyTarget._go = pi.gameObject; destroyTarget._bh = pi.GetComponent<BuildingHealth>(); ICoopStructure component = pi.GetComponent<ICoopStructure>(); if (component != null) { IProceduralStructure component2 = pi.GetComponent<IProceduralStructure>(); if (component2 == null) { return false; } destroyTarget._ghost = component2.SpawnStructure().gameObject; } else { destroyTarget._ghost = UnityEngine.Object.Instantiate<GameObject>(blueprintByPrefabId._ghostPrefab, pi.transform.position, pi.transform.rotation); } destroyTarget._ghost.transform.parent = pi.transform; int layer = LayerMask.NameToLayer("TransparentFX"); Renderer component3 = destroyTarget._ghost.GetComponent<Renderer>(); if (component3) { destroyTarget._ghost.layer = layer; component3.sharedMaterial = this._overlayMaterial; } else { Craft_Structure componentInChildren = destroyTarget._ghost.GetComponentInChildren<Craft_Structure>(); if (componentInChildren && componentInChildren._requiredIngredients.Count > 0) { for (int i = 0; i < componentInChildren._requiredIngredients.Count; i++) { Craft_Structure.BuildIngredients buildIngredients = componentInChildren._requiredIngredients[i]; buildIngredients.SetGhostMaterial(this._overlayMaterial); } } else { Renderer[] componentsInChildren = destroyTarget._ghost.GetComponentsInChildren<Renderer>(); foreach (Renderer renderer in componentsInChildren) { renderer.gameObject.layer = layer; renderer.sharedMaterial = this._overlayMaterial; } } } Transform transform = destroyTarget._ghost.transform.Find("Trigger"); if (transform) { UnityEngine.Object.Destroy(transform.gameObject); } LastBuiltLocation component4 = destroyTarget._ghost.GetComponent<LastBuiltLocation>(); if (component4) { UnityEngine.Object.Destroy(component4.gameObject); } LastBuiltLocation component5 = destroyTarget._ghost.GetComponent<LastBuiltLocation>(); if (component5) { UnityEngine.Object.Destroy(component5.gameObject); } UnityEngine.Object.Destroy(destroyTarget._ghost.GetComponent<PrefabIdentifier>()); UnityEngine.Object.Destroy(destroyTarget._ghost.GetComponent<SingleAnchorStructure>()); this._destroyTargets.Add(pi.gameObject, destroyTarget); } if (c && !destroyTarget._colliders.Contains(c)) { destroyTarget._colliders.Add(c); } this.CheckCanPlace(); return true; } } } return false; }
public void SwapToNextGhost() { if (LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayWhoosh(); } if (BoltNetwork.isRunning && !base.entity.isOwner) { SwapGhost swapGhost = SwapGhost.Create(base.entity.source); swapGhost.GhostEntity = base.entity; swapGhost.Send(); } else { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this._swapTo, this._ghost.transform.position, this._ghost.transform.rotation); if (this._ghost.transform.parent) { gameObject.transform.parent = this._ghost.transform.parent; } Craft_Structure componentInChildren = gameObject.GetComponentInChildren <Craft_Structure>(); if (componentInChildren) { componentInChildren._presentIngredients = new ReceipeIngredient[componentInChildren._requiredIngredients.Count]; for (int i = 0; i < this._presentIngredients.Length; i++) { bool flag = false; for (int j = 0; j < componentInChildren._presentIngredients.Length; j++) { if (componentInChildren._presentIngredients[j] == null) { componentInChildren._presentIngredients[j] = new ReceipeIngredient { _itemID = this._presentIngredients[i]._itemID, _amount = 0 }; } if (this._presentIngredients[i]._itemID == componentInChildren._presentIngredients[j]._itemID) { int num = this._requiredIngredients[i]._amount - this._presentIngredients[i]._amount; BuildMission.AddNeededToBuildMission(this._presentIngredients[i]._itemID, -num, true); componentInChildren._presentIngredients[j]._amount = this._presentIngredients[i]._amount; flag = true; break; } } if (!flag) { this.SpawnBackIngredients(i); } } componentInChildren.manualLoading = false; TreeStructure component = this._ghost.GetComponent <TreeStructure>(); if (component) { TreeStructure treeStructure = gameObject.GetComponent <TreeStructure>(); if (!treeStructure) { treeStructure = gameObject.AddComponent <TreeStructure>(); } treeStructure.TreeId = component.TreeId; } if (BoltNetwork.isRunning && !gameObject.GetComponent <BoltEntity>().isAttached) { BoltNetwork.Attach(gameObject); } this.AllOff(false); if (BoltNetwork.isRunning) { BoltNetwork.Destroy(this._ghost); } else { UnityEngine.Object.Destroy(this._ghost); } } else { Debug.Log("Swap target isn't a ghost, aborting"); UnityEngine.Object.Destroy(gameObject); } } }