private static ArrayWithWeights <IProtoItemFish> ServerSelectAvailableFishPrototypes( bool isSaltWater, IProtoItemFishingBait protoItemFishingBait, byte characterFishingKnowledgeLevel) { var result = new List <ValueWithWeight <IProtoItemFish> >(); foreach (var protoItemFish in AllFishList) { if (protoItemFish.IsSaltwaterFish != isSaltWater) { // this fish is for different water type continue; } if (protoItemFish.RequiredFishingKnowledgeLevel > characterFishingKnowledgeLevel) { // cannot catch this fish yet continue; } var weight = protoItemFish.BaitWeightList.GetWeightForBait(protoItemFishingBait); if (weight <= 0) { // this fish is not interested in this bait continue; } result.Add(new ValueWithWeight <IProtoItemFish>(protoItemFish, weight)); } return(new ArrayWithWeights <IProtoItemFish>(result)); }
public static IItem SharedFindBaitItem(ICharacter character, IProtoItemFishingBait currentProtoBait) { var lowestFreshness = uint.MaxValue; IItem lowestFreshnessItem = null; foreach (var container in character.ProtoCharacter.SharedEnumerateAllContainers( character, includeEquipmentContainer: false)) { foreach (var itemBait in container.GetItemsOfProto(currentProtoBait)) { var freshnessCurrent = itemBait.GetPrivateState <IItemWithFreshnessPrivateState>() .FreshnessCurrent; if (lowestFreshness <= freshnessCurrent) { continue; } lowestFreshness = freshnessCurrent; lowestFreshnessItem = itemBait; } } return(lowestFreshnessItem); }
public FishingBaitRefillRequest( ICharacter character, IItem itemFishingRod, IProtoItemFishingBait protoItemBait) { this.Character = character; this.ItemFishingRod = itemFishingRod; this.ProtoItemBait = protoItemBait; }
public double GetWeightForBait(IProtoItemFishingBait protoItemFishingBait) { foreach (var entry in this.Entries) { if (ReferenceEquals(entry.Value, protoItemFishingBait)) { return(entry.Weight); } } // not found return(0); }
public static bool ServerTryDeductBait(ICharacter character, IProtoItemFishingBait protoItemBait) { var itemBait = SharedFindBaitItem(character, protoItemBait); if (itemBait is null) { return(false); } // found a bait item of the required type, deduct the amount Server.Items.SetCount(itemBait, itemBait.Count - 1, byCharacter: character); NotificationSystem.ServerSendItemsNotification(character, protoItemBait, deltaCount: -1); return(true); }
public FishingBaitWeightList Add(IProtoItemFishingBait protoItemBait, double weight) { this.entries.Add(new ValueWithWeight <IProtoItemFishingBait>(protoItemBait, weight)); return(this); }
public ProtoItemFishingBaitViewModel([NotNull] IProtoItemFishingBait bait) : base(bait) { }