public static void EncodeGenesToItem(GrowableEntity sourceGrowable, Item targetItem)
 {
     if (!(sourceGrowable == null) && sourceGrowable.Genes != null)
     {
         EncodeGenesToItem(EncodeGenesToInt(sourceGrowable.Genes), targetItem);
     }
 }
Esempio n. 2
0
 void OnGrowableGathered(GrowableEntity plant, Item item, BasePlayer player)
 {
     if (config.EnableGatherRate)
     {
         item.amount = ChangeGather(item.amount, config.GatherRateFarm);
     }
 }
Esempio n. 3
0
        void OnGrowableGathered(GrowableEntity plant, Item item, BasePlayer player)
        {
            if (player == null)
            {
                return;
            }
            if (AdminMode)
            {
                if (player.IsAdmin)
                {
                    SendReply(player, (string.Format(lang.GetMessage("AdminMode", this), "CROP GATHER", item.info.displayName.english, item.info.shortname)));
                }
            }
            int gr = CheckPlayerPerms(player);

            if (gr >= 0)
            {
                if (permData.PermissionsGroups[gr].CustomRateMultCropGather.ContainsKey(item.info.shortname))
                {
                    CustomList(item, permData.PermissionsGroups[gr].CustomRateMultCropGather[item.info.shortname]);
                }
                else
                {
                    GatherMultiplier(item, permData.PermissionsGroups[gr].DayRateMultCropGather, permData.PermissionsGroups[gr].NightRateMultCropGather);
                }
            }
        }
Esempio n. 4
0
    public virtual void EatNearbyFood()
    {
        if (UnityEngine.Time.time < nextEatTime)
        {
            return;
        }
        float num = StaminaCoreFraction();

        nextEatTime = UnityEngine.Time.time + UnityEngine.Random.Range(2f, 3f) + Mathf.InverseLerp(0.5f, 1f, num) * 4f;
        if (num >= 1f)
        {
            return;
        }
        List <BaseEntity> obj = Facepunch.Pool.GetList <BaseEntity>();

        Vis.Entities(base.transform.position + base.transform.forward * 1.5f, 2f, obj, 67109377);
        obj.Sort((BaseEntity a, BaseEntity b) => (b is DroppedItem).CompareTo(a is DroppedItem));
        foreach (BaseEntity item in obj)
        {
            if (item.isClient)
            {
                continue;
            }
            DroppedItem droppedItem = item as DroppedItem;
            if ((bool)droppedItem && droppedItem.item != null && droppedItem.item.info.category == ItemCategory.Food)
            {
                ItemModConsumable component = droppedItem.item.info.GetComponent <ItemModConsumable>();
                if ((bool)component)
                {
                    ReplenishFromFood(component);
                    droppedItem.item.UseItem();
                    if (droppedItem.item.amount <= 0)
                    {
                        droppedItem.Kill();
                    }
                    break;
                }
            }
            CollectibleEntity collectibleEntity = item as CollectibleEntity;
            if ((bool)collectibleEntity && collectibleEntity.IsFood())
            {
                collectibleEntity.DoPickup(null);
                break;
            }
            GrowableEntity growableEntity = item as GrowableEntity;
            if ((bool)growableEntity && growableEntity.CanPick())
            {
                growableEntity.PickFruit(null);
                break;
            }
        }
        Facepunch.Pool.FreeList(ref obj);
    }
Esempio n. 5
0
 public void GenerateRandom(GrowableEntity growable)
 {
     if (!(growable == null) && !(growable.Properties.Genes == null))
     {
         CalculateBaseWeights(growable.Properties.Genes);
         for (int i = 0; i < 6; i++)
         {
             CalculateSlotWeights(growable.Properties.Genes, i);
             Genes[i].Set(PickWeightedGeneType(), true);
         }
     }
 }
Esempio n. 6
0
        private void OnGrowableGathered(GrowableEntity growable, Item item, BasePlayer player)
        {
            float modifier;

            if (GatherDispenserModifiers.TryGetValue(item.info.displayName.english, out modifier))
            {
                item.amount = (int)(item.amount * modifier);
            }
            else if (GatherDispenserModifiers.TryGetValue("*", out modifier))
            {
                item.amount = (int)(item.amount * modifier);
            }
        }
        private void PlantTree(BasePlayer player, GrowableEntity plant, string prefabName, bool prot = false)
        {
            var entity = GameManager.server.CreateEntity(prefabName, plant.transform.position, Quaternion.identity);

            if (entity == null)
            {
                return;
            }

            entity.OwnerID = prot ? player.userID : 0;
            entity.Spawn();

            plant?.Kill();

            player.ChatMessage(Lang("Planted", player.UserIDString));
        }
Esempio n. 8
0
    public static void CrossBreed(GrowableEntity growable)
    {
        List <GrowableEntity> list = Pool.GetList <GrowableEntity>();

        Vis.Entities(growable.transform.position, 1.5f, list, 512);
        bool flag = false;

        for (int i = 0; i < 6; i++)
        {
            GrowableGene  growableGene          = growable.Genes.Genes[i];
            GeneWeighting dominantGeneWeighting = GetDominantGeneWeighting(growable, list, i);
            if (dominantGeneWeighting.Weighting > growable.Properties.Genes.Weights[(int)growableGene.Type].CrossBreedingWeight)
            {
                flag = true;
                growableGene.Set(dominantGeneWeighting.GeneType);
            }
        }
        if (flag)
        {
            growable.SendNetworkUpdate();
        }
    }
Esempio n. 9
0
    private static GeneWeighting GetDominantGeneWeighting(GrowableEntity crossBreedingGrowable, List <GrowableEntity> neighbours, int slot)
    {
        PlanterBox planter = crossBreedingGrowable.GetPlanter();

        if (planter == null)
        {
            dominant.Weighting = -1f;
            return(dominant);
        }
        for (int i = 0; i < neighbourWeights.Length; i++)
        {
            neighbourWeights[i].Weighting = 0f;
            neighbourWeights[i].GeneType  = (GeneType)i;
        }
        dominant.Weighting = 0f;
        foreach (GrowableEntity neighbour in neighbours)
        {
            if (!neighbour.isServer)
            {
                continue;
            }
            PlanterBox planter2 = neighbour.GetPlanter();
            if (!(planter2 == null) && !(planter2 != planter) && !(neighbour == crossBreedingGrowable) && neighbour.prefabID == crossBreedingGrowable.prefabID && !neighbour.IsDead())
            {
                GeneType type = neighbour.Genes.Genes[slot].Type;
                float    crossBreedingWeight = neighbour.Properties.Genes.Weights[(int)type].CrossBreedingWeight;
                float    num = (neighbourWeights[(int)type].Weighting += crossBreedingWeight);
                if (num > dominant.Weighting)
                {
                    dominant.Weighting = num;
                    dominant.GeneType  = type;
                }
            }
        }
        return(dominant);
    }
Esempio n. 10
0
        public object CropsProtected(BasePlayer player, GrowableEntity growable)
        {
            if (player.IPlayer.HasPermission(protectionbypass) == true)
            {
                return(null);
            }

            if ((bool)Config["ToolCupboardArea"] == true)
            {
                BuildingPrivlidge TC = player.GetBuildingPrivilege();
                if (TC?.IsAuthed(player) == false)
                {
                    WarnPlayer(player);
                    return(true);
                }
            }
            else if (growable.OwnerID != player.userID)
            {
                WarnPlayer(player);
                return(true);
            }

            return(null);
        }
Esempio n. 11
0
 public GrowableIncarnation(GrowableEntity entity)
 {
     Entity = entity;
     Reset();
 }
Esempio n. 12
0
 private void OnGrowableGathered(GrowableEntity growable, Item item, BasePlayer player)
 {
     item.amount = item.amount * config.CurrentMultiplier;
 }
Esempio n. 13
0
 private object OnGrowableGather(GrowableEntity growable, BasePlayer player)
 {
     return(CropsProtected(player, growable));
 }
Esempio n. 14
0
 private object CanTakeCutting(BasePlayer player, GrowableEntity growable)
 {
     return(CropsProtected(player, growable));
 }
Esempio n. 15
0
 // On Growable Gathered
 // Called before the player receives an item from gathering a growable entity
 void OnGrowableGathered(GrowableEntity plant, Item item, BasePlayer player)
 {
     CreateLogEntry("on_player_gather.log", new ResidentGatheredItem(player, plant?.name, item));
 }
 private void OnGrowableGather(GrowableEntity plant, Item item)
 {
     item.amount = (int)(item.amount * GatherRate);
 }