public void SaveStation(string characterID, WorkhouseStation station) { lock (sync) { var document = StationDocuments.FindOne(Query <WorkshopDocument> .EQ(d => d.CharacterId, characterID)); if (document == null) { document = new WorkshopDocument { CharacterId = characterID, petSchemeAdded = false }; } document.Set(station); StationDocuments.Save(document); } }
public WorkhouseStation SourceObject(IRes resourcse) { WorkhouseStation station = new WorkhouseStation(); //if(this.Hold != null ) { // station.SetHold(this.Hold); //} if (this.StationInventoryItems == null) { this.StationInventoryItems = new List <InventoryItemDocumentElement>(); } ServerInventory serverInventory = new ServerInventory(this.StationInventoryMaxSlots); serverInventory.SetItems(DatabaseUtils.TransformForInventory(this.StationInventoryItems)); station.SetInventory(serverInventory); station.SetPetSchemeAdded(petSchemeAdded); return(station); }
//public int MaxHoldCount { get; set; } public void Set(WorkhouseStation station) { //this.Hold = ((ServerWorkhouseStationHold)station.Hold).GetInfo(); //this.MaxHoldCount = ((ServerWorkhouseStationHold)station.Hold).MaxSlots; this.StationInventoryMaxSlots = station.StationInventory.MaxSlots; if (this.StationInventoryItems == null) { this.StationInventoryItems = new List <InventoryItemDocumentElement>(); } this.StationInventoryItems.Clear(); foreach (var typedItems in station.StationInventory.Items) { foreach (var item in typedItems.Value) { this.StationInventoryItems.Add(new InventoryItemDocumentElement { Count = item.Value.Count, Object = item.Value.Object.GetInfo() }); } } petSchemeAdded = station.petSchemeAdded; }
public Hashtable EquipModule(string moduleId, WorkhouseStation station) { var character = GetComponent <CharacterObject>(); var player = GetComponent <MmoActor>(); ServerInventoryItem obj = null; if (!station.StationInventory.TryGetItem(InventoryObjectType.Module, moduleId, out obj)) { return(new Hashtable { { (int)SPC.ReturnCode, (int)RPCErrorCode.ObjectNotFound } }); } if (!(obj.Object is ShipModule)) { return(new Hashtable { { (int)SPC.ReturnCode, (int)RPCErrorCode.InvalidObjectType } }); } ShipModule module = obj.Object as ShipModule; if (module.Workshop != (Workshop)character.workshop) { return(new Hashtable { { (int)SPC.ReturnCode, (int)RPCErrorCode.InvalidObjectWorkshop }, { (int)SPC.Data, (byte)module.Workshop } }); } ShipModel model = shipModel; int willBeHoldCount = model.HoldCountWhenInstalledThatModule(module); int usedInventoryCount = player.Inventory.SlotsUsed; if (willBeHoldCount < usedInventoryCount) { return(new Hashtable { { (int)SPC.ReturnCode, (int)RPCErrorCode.LowInventorySpace }, { (int)SPC.Data, (usedInventoryCount - willBeHoldCount) } }); } station.StationInventory.Remove(InventoryObjectType.Module, moduleId, 1); ShipModule prevModule = null; this.SetModule(module, out prevModule); player.Inventory.ChangeMaxSlots(holdCapacity); if (prevModule == null) { return(new Hashtable { { (int)SPC.ReturnCode, (int)RPCErrorCode.Ok } }); } if (!station.StationInventory.Add(prevModule, 1)) { return(new Hashtable { { (int)SPC.ReturnCode, (int)RPCErrorCode.FailAddToStation } }); } if (player != null) { player.EventOnStationHoldUpdated(); player.EventOnInventoryUpdated(); player.GetComponent <MmoMessageComponent>().ReceiveUpdateCombatStats(); } return(new Hashtable { { (int)SPC.ReturnCode, (int)RPCErrorCode.Ok } }); }