public void Deserialize(BinaryReader reader) { Version = reader.ReadInt32(); Name = reader.ReadString(); PersistID = reader.ReadUInt32(); DefaultSuits = new VMAvatarDefaultSuits(reader); Permissions = (VMTSOAvatarPermissions)reader.ReadByte(); if (Version > 1) { AvatarFlags = (VMTSOAvatarFlags)reader.ReadUInt32(); } Budget = reader.ReadUInt32(); BodyOutfit = reader.ReadUInt64(); HeadOutfit = reader.ReadUInt64(); SkinTone = reader.ReadByte(); if (Version > 2) { IsWorker = reader.ReadBoolean(); } for (int i = 0; i < MotiveData.Length; i++) { MotiveData[i] = reader.ReadInt16(); } for (int i = 0; i < PersonData.Length; i++) { PersonData[i] = reader.ReadInt16(); } var count = reader.ReadInt32(); Relationships = new VMEntityPersistRelationshipMarshal[count]; for (int i = 0; i < Relationships.Length; i++) { Relationships[i] = new VMEntityPersistRelationshipMarshal(); Relationships[i].Deserialize(reader); } var jobs = reader.ReadInt32(); for (int i = 0; i < jobs; i++) { var id = reader.ReadInt16(); var job = new VMTSOJobInfo(); job.Deserialize(reader); OnlineJobInfo[id] = job; } if (Version > 3) { var ignored = reader.ReadInt32(); for (int i = 0; i < ignored; i++) { IgnoredAvatars.Add(reader.ReadUInt32()); } } }
public virtual bool SetPersonData(VMPersonDataVariable variable, short value) { if ((ushort)variable > 100) { throw new Exception("Person Data out of bounds!"); } VMTSOJobInfo jobInfo = null; switch (variable) { case VMPersonDataVariable.OnlineJobID: if (value > 4) { return(false); } if (!((VMTSOAvatarState)TSOState).JobInfo.ContainsKey(value)) { ((VMTSOAvatarState)TSOState).JobInfo[value] = new VMTSOJobInfo(); ((VMTSOAvatarState)TSOState).JobInfo[value].StatusFlags = 1; } break; case VMPersonDataVariable.OnlineJobGrade: if (((VMTSOAvatarState)TSOState).JobInfo.TryGetValue(GetPersonData(VMPersonDataVariable.OnlineJobID), out jobInfo)) { jobInfo.Level = value; } return(true); case VMPersonDataVariable.OnlineJobSickDays: if (((VMTSOAvatarState)TSOState).JobInfo.TryGetValue(GetPersonData(VMPersonDataVariable.OnlineJobID), out jobInfo)) { jobInfo.SickDays = value; } return(true); case VMPersonDataVariable.OnlineJobStatusFlags: if (((VMTSOAvatarState)TSOState).JobInfo.TryGetValue(GetPersonData(VMPersonDataVariable.OnlineJobID), out jobInfo)) { jobInfo.StatusFlags = value; } return(true); case VMPersonDataVariable.OnlineJobXP: if (((VMTSOAvatarState)TSOState).JobInfo.TryGetValue(GetPersonData(VMPersonDataVariable.OnlineJobID), out jobInfo)) { var diff = value - jobInfo.Experience; jobInfo.Experience = value; } return(true); case VMPersonDataVariable.Priority: if (Thread.Queue.Count != 0 && Thread.Stack.LastOrDefault().ActionTree) { Thread.Queue[0].Priority = value; Thread.QueueDirty = true; } return(true); case VMPersonDataVariable.MoneyAmmountOverHead: if (value != -32768) { ShowMoneyHeadline(value); } break; case VMPersonDataVariable.RenderDisplayFlags: if (WorldUI != null) { ((AvatarComponent)WorldUI).DisplayFlags = (AvatarDisplayFlags)value; } return(true); case VMPersonDataVariable.SkillLock: return(true); case VMPersonDataVariable.IsGhost: SetPersonData(VMPersonDataVariable.RenderDisplayFlags, (short)(GetPersonData(VMPersonDataVariable.RenderDisplayFlags) & ~(-1))); if (value > 0) { SetPersonData(VMPersonDataVariable.RenderDisplayFlags, (short)(GetPersonData(VMPersonDataVariable.RenderDisplayFlags) | -1)); } break; } PersonData[(ushort)variable] = value; return(true); }
public void SaveAvatar(VMAvatar avatar) { var statevm = new VMNetAvatarPersistState(); statevm.Save(avatar); foreach (var relsID in avatar.ChangedRels) { int i = 0; if (!avatar.MeToPersist.ContainsKey(relsID)) { continue; } var rels = avatar.MeToPersist[relsID]; foreach (var value in rels) { RelationshipsToSave.Add(new DbRelationship { from_id = avatar.PersistID, to_id = relsID, index = (uint)(i++), value = (int)value }); } } avatar.ChangedRels.Clear(); var dbState = StateToDb(statevm); dbState.avatar_id = avatar.PersistID; var pid = avatar.PersistID; DbJobLevel jobLevel = null; if (dbState.current_job > 0) { VMTSOJobInfo info = null; ((VMTSOAvatarState)avatar.TSOState).JobInfo.TryGetValue((short)dbState.current_job, out info); if (info != null) { jobLevel = new DbJobLevel() { avatar_id = pid, job_type = dbState.current_job, job_experience = (ushort)info.Experience, job_level = (ushort)info.Level, job_sickdays = (ushort)info.SickDays, job_statusflags = (ushort)info.StatusFlags }; } } Host.InBackground(() => { using (var db = DAFactory.Get()) { db.Avatars.UpdateAvatarLotSave(pid, dbState); if (jobLevel != null) { db.Avatars.UpdateAvatarJobLevel(jobLevel); } } }); }
public virtual short GetPersonData(VMPersonDataVariable variable) { if ((ushort)variable > 100) { throw new Exception("Person Data out of bounds!"); } VMTSOJobInfo jobInfo = null; switch (variable) { case VMPersonDataVariable.OnlineJobGrade: if (((VMTSOAvatarState)TSOState).JobInfo.TryGetValue(GetPersonData(VMPersonDataVariable.OnlineJobID), out jobInfo)) { return(jobInfo.Level); } return(0); case VMPersonDataVariable.OnlineJobSickDays: if (((VMTSOAvatarState)TSOState).JobInfo.TryGetValue(GetPersonData(VMPersonDataVariable.OnlineJobID), out jobInfo)) { return(jobInfo.SickDays); } return(0); case VMPersonDataVariable.OnlineJobStatusFlags: if (((VMTSOAvatarState)TSOState).JobInfo.TryGetValue(GetPersonData(VMPersonDataVariable.OnlineJobID), out jobInfo)) { return(jobInfo.StatusFlags); } return(0); case VMPersonDataVariable.OnlineJobXP: if (((VMTSOAvatarState)TSOState).JobInfo.TryGetValue(GetPersonData(VMPersonDataVariable.OnlineJobID), out jobInfo)) { return(jobInfo.Experience); } return(0); case VMPersonDataVariable.Priority: return((Thread.Queue.Count == 0) ? (short)0 : Thread.Queue[0].Priority); case VMPersonDataVariable.IsHousemate: var level = ((VMTSOAvatarState)TSOState).Permissions; return((short)((level >= VMTSOAvatarPermissions.BuildBuyRoommate) ? 2 : ((level >= VMTSOAvatarPermissions.Roommate) ? 1 : 0))); case VMPersonDataVariable.NumOutgoingFriends: case VMPersonDataVariable.IncomingFriends: if (Thread?.Context?.VM?.TS1 == true) { break; } return((short)(MeToPersist.Count(x => x.Key < 16777216 && x.Value.Count > 1 && x.Value[1] >= 60))); case VMPersonDataVariable.SkillLock: // this variable returns the skills that are completely locked. since the skill degrade object checks the skill lock // value anyways, this seems irrelevant. perhaps was used in special event/lot type situations. return(0); /* fully locks any skills that are locked by even one point * return (short)(((GetPersonData(VMPersonDataVariable.SkillLockBody) > 0) ? 1 : 0) | * ((GetPersonData(VMPersonDataVariable.SkillLockCharisma) > 0) ? 2 : 0) | * ((GetPersonData(VMPersonDataVariable.SkillLockCooking) > 0) ? 4 : 0) | * ((GetPersonData(VMPersonDataVariable.SkillLockCreativity) > 0) ? 8 : 0) | * ((GetPersonData(VMPersonDataVariable.SkillLockLogic) > 0) ? 16 : 0) | * ((GetPersonData(VMPersonDataVariable.SkillLockMechanical) > 0) ? 32 : 0)); */ } return(PersonData[(ushort)variable]); }