Пример #1
0
 private void SpawnFoodPrefab(Cook foodPrefab)
 {
     Vector3 center = this.dryingGrid.center;
     Vector3 vector = this.dryingGrid.size * 0.5f;
     Vector3 vector2 = center;
     Vector3 vector3 = center;
     vector2.x += vector.x;
     vector2.z += vector.z;
     vector3.x -= vector.x;
     vector3.z -= vector.z;
     Vector3 position = new Vector3(UnityEngine.Random.Range(vector3.x, vector2.x), center.y, UnityEngine.Random.Range(vector3.z, vector2.z));
     position.x -= position.x % this.gridChunkSize.x;
     position.z -= position.z % this.gridChunkSize.y;
     if (BoltNetwork.isRunning)
     {
         PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer);
         placeConstruction.PrefabId = foodPrefab.GetComponent<BoltEntity>().prefabId;
         placeConstruction.Position = this.dryingGrid.transform.TransformPoint(position);
         placeConstruction.Rotation = Quaternion.identity;
         placeConstruction.Parent = base.transform.parent.GetComponent<BoltEntity>();
         placeConstruction.Send();
     }
     else
     {
         Cook cook = (Cook)UnityEngine.Object.Instantiate(foodPrefab, this.dryingGrid.transform.TransformPoint(position), Quaternion.identity);
         cook.transform.parent = base.transform.parent;
     }
 }
Пример #2
0
    private void SpawnFoodPrefab(Cook foodPrefab)
    {
        Vector3 center  = this.dryingGrid.center;
        Vector3 vector  = this.dryingGrid.size * 0.5f;
        Vector3 vector2 = center;
        Vector3 vector3 = center;

        vector2.x += vector.x;
        vector2.z += vector.z;
        vector3.x -= vector.x;
        vector3.z -= vector.z;
        Vector3 position = new Vector3(UnityEngine.Random.Range(vector3.x, vector2.x), center.y, UnityEngine.Random.Range(vector3.z, vector2.z));

        position.x -= position.x % this.gridChunkSize.x;
        position.z -= position.z % this.gridChunkSize.y;
        if (BoltNetwork.isRunning)
        {
            PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer);
            placeConstruction.PrefabId = foodPrefab.GetComponent <BoltEntity>().prefabId;
            placeConstruction.Position = this.dryingGrid.transform.TransformPoint(position);
            placeConstruction.Rotation = Quaternion.identity;
            placeConstruction.Parent   = base.transform.parent.GetComponent <BoltEntity>();
            placeConstruction.Send();
        }
        else
        {
            Cook cook = (Cook)UnityEngine.Object.Instantiate(foodPrefab, this.dryingGrid.transform.TransformPoint(position), Quaternion.identity);
            cook.transform.parent = base.transform.parent;
        }
    }
Пример #3
0
    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;
        }
    }
Пример #4
0
    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();
        }
    }