public override bool Execute(VM vm) { var obj = vm.GetAvatarByPersist(TargetUID); var roomieChange = false; if (Mode == VMChangePermissionsMode.OBJECTS_ONLY) { roomieChange = true; } else { var ownerSwitch = Mode == VMChangePermissionsMode.OWNER_SWITCH || Mode == VMChangePermissionsMode.OWNER_SWITCH_WITH_OBJECTS; if (ownerSwitch) { ChangeUserLevel(vm, ReplaceUID, VMTSOAvatarPermissions.Visitor); } roomieChange = ChangeUserLevel(vm, TargetUID, Level); if (ownerSwitch) { roomieChange = true; } } //mark objects not owned by roommates for inventory transfer if (roomieChange) { VMBuildableAreaInfo.UpdateOverbudgetObjects(vm); var roomies = vm.TSOState.Roommates; foreach (var ent in vm.Entities) { if (ent is VMGameObject && ent.PersistID > 0) { var owner = ((VMTSOObjectState)ent.TSOState).OwnerID; if (owner == ReplaceUID && ReplaceUID != 0) { ((VMTSOObjectState)ent.TSOState).OwnerID = TargetUID; owner = TargetUID; } var wasDisabled = (((VMGameObject)ent).Disabled & VMGameObjectDisableFlags.PendingRoommateDeletion) > 0; var toBeDisabled = !roomies.Contains(owner); if (wasDisabled != toBeDisabled) { if (toBeDisabled) { ((VMGameObject)ent).Disabled |= VMGameObjectDisableFlags.PendingRoommateDeletion; } else { ((VMGameObject)ent).Disabled &= ~VMGameObjectDisableFlags.PendingRoommateDeletion; } vm.Scheduler.RescheduleInterrupt(ent); ((VMGameObject)ent).RefreshLight(); } } } } return(base.Execute(vm)); }
public void UpdateTSOBuildableArea() { //if (VM.TS1) return; VMBuildableAreaInfo.UpdateOverbudgetObjects(VM); var lotSInfo = VM.TSOState.Size; var area = GetTSOBuildableArea(lotSInfo); Architecture.UpdateBuildableArea(area, ((lotSInfo >> 8) & 255) + 2); }
public void Donate(VM vm, VMEntity owner) { //remove all sellback value and set it as donated. owner.MultitileGroup.Price = 0; foreach (var obj in owner.MultitileGroup.Objects) { (obj.TSOState as VMTSOObjectState).ObjectFlags |= VMTSOObjectFlags.FSODonated; } VMBuildableAreaInfo.UpdateOverbudgetObjects(vm); }
//variables used locally for deferred avatar loading public override bool Execute(VM vm) { if (vm.TS1) { if (vm.CurrentFamily == null) { return(true); } var gameState = Content.Content.Get().Neighborhood.GameState; var control = vm.Entities.FirstOrDefault(x => x is VMAvatar && !((VMAvatar)x).IsPet && ((VMAvatar)x).GetPersonData(VMPersonDataVariable.TS1FamilyNumber) == vm.CurrentFamily?.ChunkID); if (control == null) { control = vm.Context.CreateObjectInstance((gameState.DowntownSimGUID == 0)?0x32AA2056:gameState.DowntownSimGUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH)?.BaseObject; control?.SetPosition(LotTilePos.FromBigTile(1, 1, 1), Direction.NORTH, vm.Context); } if (control != null) { var ava = (VMAvatar)control; ava.PersistID = ActorUID; ((VMTSOAvatarState)(ava.TSOState)).Permissions = VMTSOAvatarPermissions.Admin; ava.TSOState.Budget.Value = 1000000; vm.Context.ObjectQueries.RegisterAvatarPersist(ava, ava.PersistID); vm.SetGlobalValue(3, control.ObjectID); } return(true); } var name = AvatarState.Name.Substring(0, Math.Min(AvatarState.Name.Length, 64)); var sim = vm.Context.CreateObjectInstance(VMAvatar.TEMPLATE_PERSON, LotTilePos.OUT_OF_WORLD, Direction.NORTH).Objects[0]; var mailbox = vm.Entities.FirstOrDefault(x => (x.Object.OBJ.GUID == 0xEF121974 || x.Object.OBJ.GUID == 0x1D95C9B0)); if (VM.UseWorld) { FSO.HIT.HITVM.Get().PlaySoundEvent("lot_enter"); } if (mailbox != null) { VMFindLocationFor.FindLocationFor(sim, mailbox, vm.Context, VMPlaceRequestFlags.Default); } else { sim.SetPosition(LotTilePos.FromBigTile(3, 3, 1), Direction.NORTH, vm.Context); } sim.PersistID = ActorUID; VMAvatar avatar = (VMAvatar)sim; AvatarState.Apply(avatar); var oldRoomCount = vm.TSOState.Roommates.Count; //some off lot changes may have occurred. Keep things up to date if we're caught between database sync points (TODO: right now never, but should happen on every roomie change). if (AvatarState.Permissions > VMTSOAvatarPermissions.Visitor && AvatarState.Permissions < VMTSOAvatarPermissions.Admin) { if (!vm.TSOState.Roommates.Contains(AvatarState.PersistID)) { vm.TSOState.Roommates.Add(AvatarState.PersistID); if (AvatarState.Permissions > VMTSOAvatarPermissions.Roommate) { vm.TSOState.BuildRoommates.Add(AvatarState.PersistID); } else { vm.TSOState.BuildRoommates.Remove(AvatarState.PersistID); } VMBuildableAreaInfo.UpdateOverbudgetObjects(vm); } } else if (AvatarState.Permissions != VMTSOAvatarPermissions.Admin) { if (vm.TSOState.Roommates.Contains(AvatarState.PersistID)) { vm.TSOState.Roommates.Remove(AvatarState.PersistID); vm.TSOState.BuildRoommates.Remove(AvatarState.PersistID); VMBuildableAreaInfo.UpdateOverbudgetObjects(vm); } } if (oldRoomCount != vm.TSOState.Roommates.Count) { //mark objects not owned by roommates for inventory transfer foreach (var ent in vm.Entities) { if (ent is VMGameObject && ent.PersistID > 0 && ((VMTSOObjectState)ent.TSOState).OwnerID == avatar.PersistID) { var old = ((VMGameObject)ent).Disabled; if (AvatarState.Permissions < VMTSOAvatarPermissions.Roommate) { ((VMGameObject)ent).Disabled |= VMGameObjectDisableFlags.PendingRoommateDeletion; } else { ((VMGameObject)ent).Disabled &= ~VMGameObjectDisableFlags.PendingRoommateDeletion; } if (old != ((VMGameObject)ent).Disabled) { vm.Scheduler.RescheduleInterrupt(ent); } ((VMGameObject)ent).RefreshLight(); } } } vm.Context.ObjectQueries.RegisterAvatarPersist(avatar, avatar.PersistID); if (ActorUID == uint.MaxValue - 1) { avatar.SetValue(VMStackObjectVariable.Hidden, 1); avatar.SetPosition(LotTilePos.OUT_OF_WORLD, Direction.NORTH, vm.Context); avatar.SetFlag(VMEntityFlags.HasZeroExtent, true); avatar.SetPersonData(VMPersonDataVariable.IsGhost, 1); //oooooOOooooOo } vm.SignalChatEvent(new VMChatEvent(avatar.PersistID, VMChatEventType.Join, avatar.Name)); return(true); }
public override bool Execute(VM vm) { var obj = vm.GetAvatarByPersist(TargetUID); var roomieChange = false; if (Mode == VMChangePermissionsMode.OBJECTS_ONLY) { roomieChange = true; } else { var ownerSwitch = Mode == VMChangePermissionsMode.OWNER_SWITCH || Mode == VMChangePermissionsMode.OWNER_SWITCH_WITH_OBJECTS; if (ownerSwitch) { ChangeUserLevel(vm, vm.TSOState.OwnerID, VMTSOAvatarPermissions.Visitor); if (vm.TSOState.CommunityLot) { vm.TSOState.Roommates.Clear(); vm.TSOState.BuildRoommates.Clear(); } } roomieChange = ChangeUserLevel(vm, TargetUID, Level); if (ownerSwitch) { roomieChange = true; } } //mark objects not owned by roommates for inventory transfer if (roomieChange) { VMBuildableAreaInfo.UpdateOverbudgetObjects(vm); var roomies = (vm.TSOState.CommunityLot)?new HashSet <uint>() { vm.TSOState.OwnerID }:vm.TSOState.Roommates; foreach (var ent in vm.Entities) { if (ent is VMGameObject && ent.PersistID > 0) { var owner = ((VMTSOObjectState)ent.TSOState).OwnerID; if (Mode == VMChangePermissionsMode.OWNER_SWITCH_WITH_OBJECTS && owner == ReplaceUID && ReplaceUID != 0) { var item = Content.Content.Get().WorldCatalog.GetItemByGUID((ent.MasterDefinition ?? ent.Object.OBJ).GUID); if (item == null || item.Value.DisableLevel < 2) //do not trade objects that are untradable. { ((VMTSOObjectState)ent.TSOState).OwnerID = TargetUID; owner = TargetUID; } } var wasDisabled = (((VMGameObject)ent).Disabled & VMGameObjectDisableFlags.PendingRoommateDeletion) > 0; var toBeDisabled = !roomies.Contains(owner) && !((VMTSOObjectState)ent.TSOState).ObjectFlags.HasFlag(VMTSOObjectFlags.FSODonated); if (wasDisabled != toBeDisabled) { if (toBeDisabled) { ((VMGameObject)ent).Disabled |= VMGameObjectDisableFlags.PendingRoommateDeletion; } else { ((VMGameObject)ent).Disabled &= ~VMGameObjectDisableFlags.PendingRoommateDeletion; } vm.Scheduler.RescheduleInterrupt(ent); ((VMGameObject)ent).RefreshLight(); } } } } return(base.Execute(vm)); }
public override bool Execute(VM vm) { var obj = vm.GetAvatarByPersist(TargetUID); var roomieChange = false; if (obj == null) { //todo: changing owner for off-lot users, though you really shouldn't be doing that. vm.TSOState.BuildRoommates.Remove(TargetUID); if (vm.TSOState.Roommates.Contains(TargetUID)) { roomieChange = true; } vm.TSOState.Roommates.Remove(TargetUID); if (Level >= VMTSOAvatarPermissions.Roommate && Level < VMTSOAvatarPermissions.Admin) { roomieChange = !roomieChange; vm.TSOState.Roommates.Add(TargetUID); if (Level > VMTSOAvatarPermissions.Roommate) { vm.TSOState.BuildRoommates.Add(TargetUID); } } } else { var oldState = ((VMTSOAvatarState)obj.TSOState).Permissions; /*if (vm.GlobalLink != null && oldState >= VMTSOAvatarPermissions.Admin) * ((VMTSOGlobalLinkStub)vm.GlobalLink).Database.Administrators.Remove(obj.PersistID);*/ if (oldState >= VMTSOAvatarPermissions.Roommate) { vm.TSOState.Roommates.Remove(obj.PersistID); roomieChange = !roomieChange; ((VMTSOAvatarState)obj.TSOState).Flags |= VMTSOAvatarFlags.CanBeRoommate; } if (oldState >= VMTSOAvatarPermissions.BuildBuyRoommate) { vm.TSOState.BuildRoommates.Remove(obj.PersistID); } ((VMTSOAvatarState)obj.TSOState).Permissions = Level; if (Level >= VMTSOAvatarPermissions.Roommate) { ((VMTSOAvatarState)obj.TSOState).Flags &= ~VMTSOAvatarFlags.CanBeRoommate; roomieChange = !roomieChange; //flips roomie change back vm.TSOState.Roommates.Add(obj.PersistID); } if (Level >= VMTSOAvatarPermissions.BuildBuyRoommate) { vm.TSOState.BuildRoommates.Add(obj.PersistID); } /*if (vm.GlobalLink != null && Level >= VMTSOAvatarPermissions.Admin) * ((VMTSOGlobalLinkStub)vm.GlobalLink).Database.Administrators.Add(obj.PersistID);*/ } //mark objects not owned by roommates for inventory transfer if (roomieChange) { VMBuildableAreaInfo.UpdateOverbudgetObjects(vm); foreach (var ent in vm.Entities) { if (ent is VMGameObject && ent.PersistID > 0 && ((VMTSOObjectState)ent.TSOState).OwnerID == TargetUID) { var old = ((VMGameObject)ent).Disabled; if (Level < VMTSOAvatarPermissions.Roommate) { ((VMGameObject)ent).Disabled |= VMGameObjectDisableFlags.PendingRoommateDeletion; } else { ((VMGameObject)ent).Disabled &= ~VMGameObjectDisableFlags.PendingRoommateDeletion; } if (old != ((VMGameObject)ent).Disabled) { vm.Scheduler.RescheduleInterrupt(ent); } ((VMGameObject)ent).RefreshLight(); } } } return(base.Execute(vm)); }