private void SpawnPart(EffigyArchitect.Part part) { if (BoltNetwork.isRunning) { AddEffigyPart addEffigyPart = AddEffigyPart.Create(GlobalTargets.OnlyServer); addEffigyPart.Effigy = base.GetComponentInParent <BoltEntity>(); addEffigyPart.ItemId = part._itemId; addEffigyPart.Position = part._position; addEffigyPart.Rotation = part._rotation; addEffigyPart.Send(); } else { this.SpawnPartReal(part, false); } }
private void CheckPlace() { if (this._currentPreviewItemId != -1) { Scene.HudGui.PlacePartIcon.SetActive(true); if (TheForest.Utils.Input.GetButtonDown("Take")) { LocalPlayer.Sfx.PlayHammer(); if (LocalPlayer.AnimControl.carry) { if (BoltNetwork.isRunning) { LocalPlayer.AnimControl.DropBody(true); } else { UnityEngine.Object.Destroy(LocalPlayer.AnimControl.DropBody()); } } else { LocalPlayer.Inventory.ShuffleRemoveRightHandItem(); } EffigyArchitect.Part part = new EffigyArchitect.Part { _itemId = this._currentPreviewItemId, _position = this._currentPreviewTr.position, _rotation = this._currentPreviewTr.rotation.eulerAngles }; if (!BoltNetwork.isRunning) { this._parts.Add(part); } this.SpawnPart(part); this.UpdateCurrentPreviewItem(-1); Scene.HudGui.PlacePartIcon.SetActive(false); } } else { Scene.HudGui.PlacePartIcon.SetActive(false); } }
public void SpawnPartReal(EffigyArchitect.Part part, bool mp_addpart) { if (BoltNetwork.isRunning && mp_addpart) { this._parts.Add(part); } Item item = (part._itemId <= 0) ? null : ItemDatabase.ItemById(part._itemId); Transform transform = null; if (item != null && item._bareItemPrefab) { transform = item._bareItemPrefab; if (transform && item._id != this._baseItemId) { if (this._effigyRange.radius < 10f) { this._effigyRange.radius = 10f; } if (this._effigyRange.radius < 80f) { this._enableEffigy.lightBool = false; this._effigyRange.radius += 1.5f; this._enableEffigy.duration = Mathf.Clamp(this._enableEffigy.duration + 15f, 600f, 1200f); } if (this._enableEffigy.duration < 1200f) { this._enableEffigy.duration += 50f; } } } else if (part._itemId == -2) { transform = Prefabs.Instance.TorsoPrefab; if (transform) { if (this._effigyRange.radius < 10f) { this._effigyRange.radius = 10f; } if (this._effigyRange.radius < 80f) { this._enableEffigy.lightBool = false; this._effigyRange.radius += 3f; } if (this._enableEffigy.duration < 1200f) { this._enableEffigy.duration += 50f; } } } if (transform) { Transform transform2 = UnityEngine.Object.Instantiate <Transform>(transform); transform2.position = part._position; transform2.rotation = Quaternion.Euler(part._rotation.x, part._rotation.y, part._rotation.z); transform2.parent = base.transform; if (BoltNetwork.isServer) { BoltNetwork.Attach(transform2.gameObject).GetComponent <BoltEntity>().GetState <IPartState>().Effigy = base.GetComponentInParent <BoltEntity>(); } } }