public bool IsStoryCollectionReadyToCharge(StoryCollectionData collection) { bool hasCollectables = true; RavenhillResourceService resourceService = engine.GetService <IResourceService>().Cast <RavenhillResourceService>(); PlayerService playerService = engine.GetService <IPlayerService>().Cast <PlayerService>(); foreach (string collectableId in collection.collectables) { StoryCollectableData collectableData = resourceService.GetStoryCollectable(collectableId); int playerCount = playerService.GetItemCount(collectableData); if (playerCount <= 0) { hasCollectables = false; break; } } bool hasCharger = true; StoryChargerData chargerData = resourceService.GetStoryCharger(collection.chargerId); int playerChargerCount = playerService.GetItemCount(chargerData); if (playerChargerCount <= 0) { hasCharger = false; } return(hasCollectables && hasCharger); }
public void ChargeStoryCollection(StoryCollectionData collectionData) { PlayerService playerService = engine.GetService <IPlayerService>().Cast <PlayerService>(); RavenhillResourceService resourceService = engine.GetService <IResourceService>().Cast <RavenhillResourceService>(); StoryChargerData chargerData = resourceService.GetStoryCharger(collectionData.chargerId); if (playerService.GetItemCount(chargerData) > 0) { playerService.RemoveItem(InventoryItemType.StoryCharger, chargerData.id, 1); playerService.AddItem(new InventoryItem(collectionData, 1)); RavenhillEvents.OnStoryCollectionCharged(collectionData); } }