public override void Release() { WallCursor.Delete(vm.Context); vm.Context.Architecture.Commands.Clear(); vm.Context.Architecture.SignalTerrainRedraw(); vm.Context.Architecture.SignalRedraw(); }
public void SetGUIDLocal(uint id, VM TempVM) { oldGUID = id; GUID = id; if (TempVM != null) { if (TargetOBJ != null) { TargetOBJ.Delete(TempVM.Context); } //create our master, center camera on target object var objDefinition = FSO.Content.Content.Get().WorldObjects.Get(GUID); if (objDefinition != null) { var masterID = id; var notMaster = objDefinition.OBJ.MasterID != 0 && objDefinition.OBJ.SubIndex != -1; if (notMaster) { //find the master var master = objDefinition.Resource.List <OBJD>().FirstOrDefault(x => x.MasterID == objDefinition.OBJ.MasterID && x.SubIndex == -1); if (master != null) { masterID = master.GUID; } } TargetOBJ = TempVM.Context.CreateObjectInstance(masterID, LotTilePos.OUT_OF_WORLD, Direction.SOUTH, true); TargetOBJ.SetVisualPosition(new Vector3(0.5f, 0.5f, 0f), Direction.SOUTH, TempVM.Context); TempVM.Entities = TargetOBJ.Objects; if (TargetOBJ == null) { return; } TargetTile = TargetOBJ.Objects.FirstOrDefault(x => x.Object.OBJ.GUID == id); if (TargetTile == null) { TargetTile = TargetOBJ.BaseObject; } if (TargetTile == null) { TargetOBJ = null; return; } var tile = TargetTile.VisualPosition; TempVM.Context.World.State.CenterTile = new Vector2(tile.X, tile.Y) - new Vector2(2.5f, 2.5f); foreach (var obj in TargetOBJ.Objects) { if (obj is VMGameObject) { ((ObjectComponent)obj.WorldUI).RenderInfo.Layer = WorldObjectRenderLayer.DYNAMIC; } if (notMaster && obj.Object.OBJ.GUID != id) { obj.SetRoom(2); } } } } }
/// <summary> /// Sent to the client after the object data is retrieved by the client. If data is 0 length, intantiate a new object of the type. /// Can rarely cause the object to be sent BACK to inventory if it cannot be placed in the intended location. /// </summary> /// <param name="vm"></param> /// <param name="caller"></param> /// <returns></returns> public override bool Execute(VM vm, VMAvatar caller) { if (caller == null) { return(false); } //careful here! if the object can't be placed, we have to put their object back if (!vm.Context.ObjectQueries.MultitileByPersist.ContainsKey(GUID) && TryPlace(vm, caller)) { if (CreatedGroup.BaseObject is VMGameObject) { foreach (var o in CreatedGroup.Objects) { ((VMGameObject)o).Disabled &= ~VMGameObjectDisableFlags.ForSale; } } CreatedGroup.SalePrice = -1; return(true); } else { //oops, we can't place this object or some other issue occured. move it back to inventory. if (CreatedGroup != null) { foreach (var o in CreatedGroup.Objects) { o.PersistID = 0; //no longer representative of the object in db. } CreatedGroup.Delete(vm.Context); } if (vm.GlobalLink != null) { //do a force move to inventory here. do not need to resave state, since it has not changed since the place. //if the server crashes between setting the object on this lot and now, the //server should detect that an object says it is "on" this lot, but it really isn't physically //and move it back to inventory without a state save. // //owned objects that are "out of world" should be moved to inventory on load. (FULL move, for safety) vm.GlobalLink.ForceInInventory(vm, ObjectPID, (bool success, uint pid) => {}); } } return(false); }
public void SetGUIDLocal(uint id) { oldGUID = id; GUID = id; if (TempVM != null) { if (TargetOBJ != null) { TargetOBJ.Delete(TempVM.Context); } TargetOBJ = TempVM.Context.CreateObjectInstance(GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true); if (TargetOBJ != null && TargetOBJ.BaseObject is VMGameObject) { UpdateThumb(); } else { Thumb = null; } } }
public void Release() { WallCursor.Delete(vm.Context); }