private void SpawnFoodPrefab(Cook foodPrefab, bool center, DecayingInventoryItemView.DecayStates decayStateValue) { if (this.CookingDisabled) { return; } Vector3 position = base.transform.position + new Vector3((!center) ? UnityEngine.Random.Range(-0.2f, 0.2f) : 0f, 1.25f, (!center) ? UnityEngine.Random.Range(-0.2f, 0.2f) : 0f); if (!BoltNetwork.isRunning) { Cook cook = UnityEngine.Object.Instantiate <Cook>(foodPrefab, position, Quaternion.identity); cook.transform.parent = base.transform.parent; cook.transform.Rotate(0f, (float)UnityEngine.Random.Range(0, 359), 0f); if (decayStateValue > DecayingInventoryItemView.DecayStates.None && decayStateValue <= DecayingInventoryItemView.DecayStates.DriedSpoilt) { cook.SetDecayState(decayStateValue); } else { cook.SendMessage("SetActiveBonus", (WeaponStatUpgrade.Types)decayStateValue, SendMessageOptions.DontRequireReceiver); } } else { PlaceDryingFood placeDryingFood = PlaceDryingFood.Create(GlobalTargets.OnlyServer); placeDryingFood.PrefabId = foodPrefab.GetComponent <BoltEntity>().prefabId; placeDryingFood.Position = position; placeDryingFood.Rotation = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 359), 0f); placeDryingFood.Parent = base.transform.parent.GetComponent <BoltEntity>(); placeDryingFood.DecayState = (int)decayStateValue; placeDryingFood.Send(); } }
private void SpawnFoodPrefab(Cook foodPrefab) { this._nextAddFood = Time.time + 0.25f; Vector3 position = this.dryingGrid.transform.InverseTransformPoint(LocalPlayer.Create.Grabber.transform.position); position.x -= position.x % this.gridChunkSize.x; position.z -= position.z % this.gridChunkSize.y; position.x = Mathf.Clamp(position.x, -this.dryingGrid.size.x * 0.5f + this.gridChunkSize.x, this.dryingGrid.size.x * 0.5f - this.gridChunkSize.x); position.z = Mathf.Clamp(position.z, -this.dryingGrid.size.z * 0.5f + this.gridChunkSize.y, this.dryingGrid.size.z * 0.5f - this.gridChunkSize.y); position.y = this.dryingGrid.center.y + this.gridOffset.y; if (BoltNetwork.isRunning) { PlaceDryingFood placeDryingFood = PlaceDryingFood.Create(GlobalTargets.OnlyServer); placeDryingFood.PrefabId = foodPrefab.GetComponent <BoltEntity>().prefabId; placeDryingFood.Position = this.dryingGrid.transform.TransformPoint(position); placeDryingFood.Rotation = Quaternion.identity; placeDryingFood.Parent = base.transform.parent.GetComponent <BoltEntity>(); if (DecayingInventoryItemView.LastUsed) { placeDryingFood.DecayState = (int)DecayingInventoryItemView.LastUsed._prevState; } placeDryingFood.Send(); } else { Cook cook = UnityEngine.Object.Instantiate <Cook>(foodPrefab, this.dryingGrid.transform.TransformPoint(position), Quaternion.identity); cook.transform.parent = base.transform.parent; } }
private void SpawnFoodPrefab(GameObject prefab) { Vector3 position = base.transform.position + new Vector3(UnityEngine.Random.Range(-0.2f, 0.2f), UnityEngine.Random.Range(-0.15f, 0f), UnityEngine.Random.Range(-0.2f, 0.2f)); if (!BoltNetwork.isRunning) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(prefab, position, Quaternion.identity); gameObject.transform.parent = base.transform.parent; this.UpdateCookController(); } else { PlaceDryingFood placeDryingFood = PlaceDryingFood.Create(GlobalTargets.OnlyServer); placeDryingFood.PrefabId = prefab.GetComponent <BoltEntity>().prefabId; placeDryingFood.Position = position; placeDryingFood.Rotation = Quaternion.Euler((float)UnityEngine.Random.Range(-15, 15), (float)UnityEngine.Random.Range(0, 359), (float)UnityEngine.Random.Range(-15, 15)); placeDryingFood.Parent = base.transform.parent.GetComponent <BoltEntity>(); if (DecayingInventoryItemView.LastUsed) { placeDryingFood.DecayState = (int)DecayingInventoryItemView.LastUsed._prevState; } placeDryingFood.Send(); } }