void OnCropGather(PlantEntity 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 override bool DoCheck(Construction.Placement place) { Vector3 position = Vector3.op_Addition(place.position, Quaternion.op_Multiply(place.rotation, this.worldPosition)); List <BaseEntity> list1 = (List <BaseEntity>)Pool.GetList <BaseEntity>(); double sphereRadius = (double)this.sphereRadius; List <BaseEntity> list2 = list1; int layerMask = ((LayerMask) ref this.layerMask).get_value(); QueryTriggerInteraction queryTriggers = this.queryTriggers; Vis.Entities <BaseEntity>(position, (float)sphereRadius, list2, layerMask, queryTriggers); foreach (Component component1 in list1) { PlantEntity component2 = (PlantEntity)component1.GetComponent <PlantEntity>(); if (Object.op_Implicit((Object)component2) && this.wantsCollide) { // ISSUE: cast to a reference type Pool.FreeList <BaseEntity>((List <M0>&) ref list1); return(true); } if (Object.op_Implicit((Object)component2) && !this.wantsCollide) { // ISSUE: cast to a reference type Pool.FreeList <BaseEntity>((List <M0>&) ref list1); return(false); } } // ISSUE: cast to a reference type Pool.FreeList <BaseEntity>((List <M0>&) ref list1); return(!this.wantsCollide); }
public async Task <Plant> UpdatePlantAsync( Guid Id, Plant plantForm, CancellationToken ct) { PlantEntity entity = await _dbContext.Plants.SingleOrDefaultAsync(i => i.Id == Id, ct); if (entity == null) { return(null); } // Return if provided name is not valid if (!entity.Tag.Equals(plantForm.Tag, StringComparison.OrdinalIgnoreCase)) { return(null); } entity = Mapper.Map <PlantEntity>(plantForm); _dbContext.Plants.Update(entity); var updated = await _dbContext.SaveChangesAsync(ct); if (updated < 1) { throw new InvalidOperationException("Could not update the plant"); } return(Mapper.Map <Plant>(entity)); }
void OnPlantGather(PlantEntity plant, Item item, BasePlayer player) { if (player == null || !configData.ActiveChallengeTypes[CTypes.Plants.ToString()]) { return; } AddPoints(player, CTypes.Plants, 1); }
private void OnPlantGather(PlantEntity plant, Item item, BasePlayer player) { if (player == null || player is NPCPlayer || !configData.ChallengeSettings[Challenges.PlantsGathered].Enabled) { return; } AddPoints(player, Challenges.PlantsGathered, 1); }
private void OnCropGather(PlantEntity plant, Item item, BasePlayer player) { if (item == null || player == null) { return; } LevelHandler(player, item, SkillList.acquiring); }
/// <summary> /// Increase hemp gather rate -- doesn't seem to work /// </summary> private void OnPlantGather(PlantEntity plant, Item item, BasePlayer player) { if (player == null) return; if (this.IsInBadlands(player)) { item.amount = Convert.ToInt32(item.amount * 3); } }
void CreatePlant(BaseEntity Seed, string prefab, Vector3 Pos) { PlantEntity plant = GameManager.server.CreateEntity(prefab, Pos, Quaternion.identity) as PlantEntity; if (plant != null) { plant.Spawn(); Seed.Kill(); } }
public override void RightClick(Player player) { Point16 tilePos = Main.MouseWorld.ToPoint16(); PlantEntity entity = TileUtils.GetTileEntity <PlantEntity>(tilePos); if (entity != null) { entity.hasBeenWatered = true; } }
public async Task <Plant> GetPlantByTagAsync(string tag, CancellationToken ct) { PlantEntity entity = await _dbContext.Plants.SingleOrDefaultAsync(i => i.Tag.Equals(tag, StringComparison.OrdinalIgnoreCase), ct); if (entity == null) { return(null); } return(Mapper.Map <Plant>(entity)); }
//TODO cant figure out watering public override bool UseItem(Player player) { Point16 tilePos = (Main.MouseWorld / 16).ToPoint16(); // new Point16(16); PlantEntity entity = TileUtils.GetTileEntity <PlantEntity>(tilePos); if (entity != null) { entity.hasBeenWatered = true; } return(true); }
public override void ServerInit() { if (this.genetics == -1) { this.genetics = UnityEngine.Random.Range(0, 10000); } this.groundConditions = PlantEntity.WorkoutGroundConditions(base.transform.position); base.ServerInit(); base.InvokeRandomized(new Action(this.RunUpdate), this.thinkDeltaTime, this.thinkDeltaTime, this.thinkDeltaTime * 0.1f); base.health = 10f; this.ResetSeason(); }
public override void ServerInit() { if (this.genetics == -1) { this.genetics = Random.Range(0, 10000); } this.groundConditions = PlantEntity.WorkoutGroundConditions(((Component)this).get_transform().get_position()); base.ServerInit(); this.InvokeRandomized(new Action(this.RunUpdate), this.thinkDeltaTime, this.thinkDeltaTime, this.thinkDeltaTime * 0.1f); this.health = 10f; this.ResetSeason(); }
private void OnCropGather(PlantEntity plant, Item item, BasePlayer player) { if (TOD_Sky.Instance.IsNight) { item.amount = (int)(item.amount * config.nightrate); } else if (TOD_Sky.Instance.IsDay) { item.amount = (int)(item.amount * config.dayrate); } return; }
private void OnCropGather(PlantEntity plant, Item item) { 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); } }
//void OnBlueprintReveal(Item item, Item revealed, BasePlayer player) //{ // if (!enabled) return; // ItemMod[] mods = item.info.itemMods; // //if (CheckItem(revealed)) // //{ // // REFUND BLUEPRINT FRAGMENT/PAGE/BOOK/LIBRARY // timer.Once(0.1f, delegate() // { // if (item.info.itemid == 1351589500) // { // player.inventory.GiveItem(ItemManager.Create(item.info.itemid, 20)); // } // else // { // player.inventory.GiveItem(ItemManager.Create(item.info.itemid, 1)); // } // }); // if(sendMessages) // SendReply(player, messages["You may not research this (restricted), blueprints refunded!"]); // //} //} void OnPlantGather(PlantEntity plant, Item item, BasePlayer player) { if (!enabled) { return; } if (CheckItem(item)) { if (sendMessages) { SendReply(player, messages["You may not pick that up (restricted)"]); } } }
void OnPlantGather(PlantEntity Plant, Item item, BasePlayer player) { if (!isPayor(player.userID)) { return; } var taxrate = configData.TaxRate; List <StorageContainer> TaxContainers = GetTaxContainer(player.userID); if (TaxContainers == null) { return; } int taxcollectors = 0; foreach (var entry in ttData.TaxCollector.Where(kvp => kvp.Value.Contains(player.userID))) { taxcollectors++; } var maxtaxors = Math.Floor(100 / taxrate); if (maxtaxors < taxcollectors) { taxrate = 90 / taxcollectors; } int Tax = Convert.ToInt32(Math.Ceiling((item.amount * taxrate) / 100)); item.amount = item.amount - (Tax * taxcollectors); foreach (StorageContainer cont in TaxContainers) { if (!cont.inventory.IsFull()) { ItemDefinition ToAdd = ItemManager.FindItemDefinition(item.info.itemid); if (ToAdd != null) { cont.inventory.AddItem(ToAdd, Tax); } } else if (BasePlayer.activePlayerList.Contains(BasePlayer.FindByID(cont.OwnerID))) { if (timers.ContainsKey(cont.OwnerID.ToString())) { GetSendMSG(player, "TaxBoxFull"); SetBoxFullNotification(cont.OwnerID.ToString()); return; } } } }
//Planted plants void OnCropGather(PlantEntity plant, Item item, BasePlayer player) { //Get berry from planted hemp if (item.info.shortname.Contains("cloth")) { if (UnityEngine.Random.Range(0, 100) < BlackRaspberryChancePlanted) { player.inventory.GiveItem(ItemManager.CreateByName(BlackRaspberryItem, Oxide.Core.Random.Range(BlackRaspberryAmountMin, BlackRaspberryAmountMax + 1))); if (enableBroadcast) { SendReply(player, String.Format(msg("BlackRaspberry"))); } } if (UnityEngine.Random.Range(0, 100) < BlueberryChancePlanted) { player.inventory.GiveItem(ItemManager.CreateByName(BlueberryItem, Oxide.Core.Random.Range(BlueberryAmountMin, BlueberryAmountMax + 1))); if (enableBroadcast) { SendReply(player, String.Format(msg("Blueberry"))); } } } //Get LGF from planted corn if (item.info.shortname.Contains("corn") && !item.info.shortname.Contains("seed.corn")) { if (UnityEngine.Random.Range(0, 100) < LGFChancePlantedCorn) { player.inventory.GiveItem(ItemManager.CreateByName(LGFItemCorn, Oxide.Core.Random.Range(LGFAmountMinCorn, LGFAmountMaxCorn + 1))); if (enableBroadcast) { SendReply(player, String.Format(msg("LGFCorn"))); } } } //Get LGF from planted pumpkin if (item.info.shortname.Contains("pumpkin") && !item.info.shortname.Contains("seed.pumpkin")) { if (UnityEngine.Random.Range(0, 100) < LGFChancePlantedPumpkin) { player.inventory.GiveItem(ItemManager.CreateByName(LGFItemPumpkin, Oxide.Core.Random.Range(LGFAmountMinPumpkin, LGFAmountMaxPumpkin + 1))); if (enableBroadcast) { SendReply(player, String.Format(msg("LGFPumpkin"))); } } } }
void OnPlantGather(PlantEntity Plant, Item item, BasePlayer player) { List <StorageContainer> TaxContainers = GetTaxContainer(player.userID); if (TaxContainers == null) { return; } var taxrate = configData.TaxRate; int taxcollectors = TaxContainers.Count(); var maxtaxors = Math.Floor(100 / taxrate); if (maxtaxors < taxcollectors) { taxrate = 90 / taxcollectors; } int Tax = Convert.ToInt32(Math.Floor((item.amount * taxrate) / 100)); item.amount = item.amount - (Tax * taxcollectors); foreach (StorageContainer cont in TaxContainers) { if (!cont.inventory.IsFull()) { ItemDefinition ToAdd = ItemManager.FindItemDefinition(item.info.itemid); if (ToAdd != null) { cont.inventory.AddItem(ToAdd, Tax); } } else { item.amount += Tax; List <ushort> boxOwners = ftData.TaxBox.Where(k => k.Value == new XYZ { x = cont.transform.localPosition.x, y = cont.transform.localPosition.y, z = cont.transform.localPosition.z }).Select(k => k.Key).ToList(); if (timers.ContainsKey(boxOwners[0].ToString())) { FactionsCore.BroadcastFaction(null, "TaxBoxFull", boxOwners[0]); SetBoxFullNotification(boxOwners[0].ToString()); return; } } } }
private void OnCropGather(PlantEntity plant, Item item, BasePlayer player) { PrintDebug("OnCropGather called"); var dict = PlayerStats.TryFind(player.userID).PlantPickups; uint count; if (dict.TryGetValue(item.info.shortname, out count)) { count += (uint)item.amount; } else { count = (uint)item.amount; dict.Add(item.info.shortname, count); } dict[item.info.shortname] = count; }
public async Task <Guid> CreatePlantAsync(Plant plantForm, CancellationToken ct) { var id = Guid.NewGuid(); PlantEntity entity = Mapper.Map <PlantEntity>(plantForm); entity.Id = id; var newObj = _dbContext.Plants.Add(entity); var created = await _dbContext.SaveChangesAsync(ct); if (created < 1) { throw new InvalidOperationException("Could not create the requested object"); } return(id); }
/////////////////////////////////////////////////////////////////////////////////////////// // fonction d'entrée du clic SOURIS // les coordonnées sont cartésiennes static public void Event(int x, int y) { int rangee = Coord.YtoRow(y); int col = Coord.XtoColumn(x); List <GameObject> se = Global.Entities.FindAll(s => s.GetComponent <CClickable>() != null && x <= s.posX + s.GetComponent <CDrawable>().HitBox.Width&& x >= s.posX && y <= s.posY + s.GetComponent <CDrawable>().HitBox.Height&& y >= s.posY); se.ForEach(sunClicked => sunClicked.GetComponent <CClickable>().IsClicked = true); if (se.Count != 0) { } else if (Global.Button == Global.Creature.Zombie) { ZombieEntity ze = new ZombieEntity(rangee, Global.Creature.ZombieCone); if (rangee >= 0 && rangee < 5) { Global.Entities.Add(ze); } } else { if (rangee >= 0 && col >= 0 && rangee < 5 && col < 9) { GameObject FoundPlant = Global.Entities.FindAll(p => p.Tags.Contains("Plant")).Find(p => Coord.YtoRow((int)p.posY) == rangee && Coord.XtoColumn((int)p.posX) == col); if (Global.Button == Global.Creature.Shovel && FoundPlant != null) { FoundPlant.Inactive = true; } else if (FoundPlant == null && Global.SunCosts[Global.Button] <= Global.dollar) //&& Global.PlantsCooldown[Global.Button] + Global.Round <= Global.Round) { PlantEntity pe = new PlantEntity(col, rangee, Global.Button); Global.Entities.Add(pe); Global.dollar -= Global.SunCosts[Global.Button]; //Global.PlantsCooldown[Global.Button] = Global.Round; } } } }
//Planted plants void OnCropGather(PlantEntity plant, Item item, BasePlayer player) { //Get berry from planted hemp if (item.info.displayName.english.Contains("Cloth")) { if (Oxide.Core.Random.Range(0, 100) < berryChancePlanted) { player.inventory.GiveItem(ItemManager.CreateByName(berryItem, Oxide.Core.Random.Range(berryAmountMin, berryAmountMax + 1))); if (enableBroadcast) { SendReply(player, String.Format(msg("Berry"))); } } } //Get biofuel from planted corn if (item.info.displayName.english.Contains("Corn") && !item.info.displayName.english.Contains("Corn Seed")) { if (Oxide.Core.Random.Range(0, 100) < BiofuelChancePlantedCorn) { player.inventory.GiveItem(ItemManager.CreateByName(BiofuelItemCorn, Oxide.Core.Random.Range(BiofuelAmountMinCorn, BiofuelAmountMaxCorn + 1))); if (enableBroadcast) { SendReply(player, String.Format(msg("BiofuelCorn"))); } } } //Get biofuel from planted pumpkin if (item.info.displayName.english.Contains("Pumpkin") && !item.info.displayName.english.Contains("Pumpkin Seed")) { if (Oxide.Core.Random.Range(0, 100) < BiofuelChancePlantedPumpkin) { player.inventory.GiveItem(ItemManager.CreateByName(BiofuelItemPumpkin, Oxide.Core.Random.Range(BiofuelAmountMinPumpkin, BiofuelAmountMaxPumpkin + 1))); if (enableBroadcast) { SendReply(player, String.Format(msg("BiofuelPumpkin"))); } } } }
public PlantEntity LoadCurrentPlant() { PlantEntity entity = null; if (!File.Exists(CurrentPlant)) { entity = new PlantEntity(DateTime.Now, 1, 0); } else { var rawData = File.ReadAllText(CurrentPlant); entity = JsonConvert.DeserializeObject <PlantEntity>(rawData); } // Assign Plant var plants = LoadPlants(); entity.BaseModel = plants[entity.PlantID]; return(entity); }
public override bool DoCheck(Construction.Placement place) { bool flag; Vector3 vector3 = place.position + (place.rotation * this.worldPosition); List <BaseEntity> list = Pool.GetList <BaseEntity>(); Vis.Entities <BaseEntity>(vector3, this.sphereRadius, list, this.layerMask.@value, this.queryTriggers); List <BaseEntity> .Enumerator enumerator = list.GetEnumerator(); try { while (enumerator.MoveNext()) { PlantEntity component = enumerator.Current.GetComponent <PlantEntity>(); if (!component || !this.wantsCollide) { if (!component || this.wantsCollide) { continue; } Pool.FreeList <BaseEntity>(ref list); flag = false; return(flag); } else { Pool.FreeList <BaseEntity>(ref list); flag = true; return(flag); } } Pool.FreeList <BaseEntity>(ref list); return(!this.wantsCollide); } finally { ((IDisposable)enumerator).Dispose(); } return(flag); }
private void OnCropGather(PlantEntity plant, Item item, BasePlayer player) { HempCropQuatityChanger(item); }
private object IOnPlantGather(BaseEntity.RPCMessage msg, PlantEntity entity, Item item) { return Interface.CallHook("OnPlantGather", entity, item, msg.player); }
public void EatNearbyFood() { if (Time.time < this.nextEatTime) { return; } float single = this.StaminaCoreFraction(); this.nextEatTime = Time.time + UnityEngine.Random.Range(2f, 3f) + Mathf.InverseLerp(0.5f, 1f, single) * 4f; if (single >= 1f) { return; } List <BaseEntity> list = Pool.GetList <BaseEntity>(); Vis.Entities <BaseEntity>(base.transform.position + (base.transform.forward * 1.5f), 2f, list, 67109377, QueryTriggerInteraction.Collide); list.Sort((BaseEntity a, BaseEntity b) => b is DroppedItem.CompareTo(a is DroppedItem)); foreach (BaseEntity baseEntity in list) { if (baseEntity.isClient) { continue; } DroppedItem droppedItem = baseEntity as DroppedItem; if (droppedItem && droppedItem.item != null && droppedItem.item.info.category == ItemCategory.Food) { ItemModConsumable component = droppedItem.item.info.GetComponent <ItemModConsumable>(); if (component) { base.ClientRPC(null, "Eat"); this.lastEatTime = Time.time; float ifType = component.GetIfType(MetabolismAttribute.Type.Calories); float ifType1 = component.GetIfType(MetabolismAttribute.Type.Hydration); float single1 = component.GetIfType(MetabolismAttribute.Type.Health) + component.GetIfType(MetabolismAttribute.Type.HealthOverTime); this.ReplenishStaminaCore(ifType, ifType1); this.Heal(single1 * 2f); droppedItem.item.UseItem(1); if (droppedItem.item.amount > 0) { break; } droppedItem.Kill(BaseNetworkable.DestroyMode.None); Pool.FreeList <BaseEntity>(ref list); return; } } CollectibleEntity collectibleEntity = baseEntity as CollectibleEntity; if (!collectibleEntity || !collectibleEntity.IsFood()) { PlantEntity plantEntity = baseEntity as PlantEntity; if (!plantEntity || !plantEntity.CanPick()) { continue; } plantEntity.PickFruit(null); Pool.FreeList <BaseEntity>(ref list); return; } else { collectibleEntity.DoPickup(null); Pool.FreeList <BaseEntity>(ref list); return; } } Pool.FreeList <BaseEntity>(ref list); }
/// <summary> /// Increase hemp gather rate -- doesn't seem to work /// </summary> private void OnPlantGather(PlantEntity plant, Item item, BasePlayer player) { if (player == null) return; item.amount = Convert.ToInt32(item.amount * 2); }
private void OnCropGather(PlantEntity plant, Item item) { item.amount = (int)(item.amount * GatherRate); }
void OnPlantGather(PlantEntity Plant, Item Item, BasePlayer Player) { int Tax = Convert.ToInt32(Math.Round((Item.amount * TaxLevel) / 100)); Item.amount = Item.amount - Tax; }
private void OnPlantGather(PlantEntity plant, Item item, BasePlayer player) { HookCalled("OnPlantGather"); // TODO: Print item to be gathered }
private object OnCropGather(PlantEntity plant, Item item, BasePlayer player) => IsLimited(player) ? false : (object)null;
/// <summary> /// Increase hemp gather rate -- doesn't seem to work /// </summary> private void OnPlantGather(PlantEntity plant, Item item, BasePlayer player) { if (player == null) return; var rateMultipliers = this.GetRateMultipliers(player); // Apply rate multiplier item.amount = Convert.ToInt32(item.amount * rateMultipliers.Plant); // Increase gather rate rateMultipliers.Plant = this.IncreaseRate(rateMultipliers.Plant); this.SaveRateMultipliers(player.userID, rateMultipliers); }
private void OnCropGather(PlantEntity plant, Item item, BasePlayer player) { HookCalled("OnCropGather"); // TODO: Print item to be gathered }