/// <summary> /// Handles operation SpawnItem: Creates a new Item and optionally subscribes an InterestArea to it. /// </summary> public OperationResponse OperationSpawnItem(PeerBase peer, OperationRequest request) { log.InfoFormat("Spawn item operation started for peer: {0}", this.Peer.ToString()); var operation = new SpawnItem(peer.Protocol, request); if (!operation.IsValid) { log.InfoFormat("Spawn item operation invalid"); return(new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }); } operation.OnStart(); var item = new Item(operation.Position, operation.Rotation, operation.Properties, this, operation.ItemId, operation.ItemType, this.World); if (this.World.ItemCache.AddItem(item)) { log.InfoFormat("adding item"); this.AddItem(item); return(this.ItemOperationSpawn(item, operation)); } log.InfoFormat("Spawn item operation for peer: {0}", this.Peer.ToString()); item.Dispose(); return(operation.GetOperationResponse((int)ReturnCode.ItemAlreadyExists, "ItemAlreadyExists")); }
/// <summary> /// Handles operation SpawnItem: Creates a new Item and optionally subscribes an InterestArea to it. /// </summary> public OperationResponse OperationSpawnItem(PeerBase peer, OperationRequest request) { var operation = new SpawnItem(peer.Protocol, request); if (!operation.IsValid) { return(new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }); } operation.OnStart(); var item = new Item(operation.Position, operation.Rotation, operation.Properties, this, operation.ItemId, operation.ItemType, this.World); if (this.World.ItemCache.AddItem(item)) { this.AddItem(item); return(this.ItemOperationSpawn(item, operation)); } item.Dispose(); return(operation.GetOperationResponse((int)ReturnCode.ItemAlreadyExists, "ItemAlreadyExists")); }