public static void EncodeGenesToItem(GrowableEntity sourceGrowable, Item targetItem) { if (!(sourceGrowable == null) && sourceGrowable.Genes != null) { EncodeGenesToItem(EncodeGenesToInt(sourceGrowable.Genes), targetItem); } }
void OnGrowableGathered(GrowableEntity plant, Item item, BasePlayer player) { if (config.EnableGatherRate) { item.amount = ChangeGather(item.amount, config.GatherRateFarm); } }
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); } } }
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); }
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); } } }
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)); }
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(); } }
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); }
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); }
public GrowableIncarnation(GrowableEntity entity) { Entity = entity; Reset(); }
private void OnGrowableGathered(GrowableEntity growable, Item item, BasePlayer player) { item.amount = item.amount * config.CurrentMultiplier; }
private object OnGrowableGather(GrowableEntity growable, BasePlayer player) { return(CropsProtected(player, growable)); }
private object CanTakeCutting(BasePlayer player, GrowableEntity growable) { return(CropsProtected(player, growable)); }
// 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); }