Example #1
0
        /// <summary>
        /// Ensure all members of the family are present on the lot.
        /// Spawns missing family members at the mailbox.
        /// </summary>
        public void VerifyFamily(VM vm)
        {
            if (CurrentFamily == null)
            {
                vm.SetGlobalValue(32, 1);
                return;
            }
            vm.SetGlobalValue(32, 0);
            vm.SetGlobalValue(9, (short)CurrentFamily.ChunkID);
            var missingMembers = new HashSet <uint>(CurrentFamily.RuntimeSubset);

            foreach (var avatar in vm.Context.ObjectQueries.Avatars)
            {
                missingMembers.Remove(avatar.Object.OBJ.GUID);
            }

            foreach (var member in missingMembers)
            {
                var sim = vm.Context.CreateObjectInstance(member, LotView.Model.LotTilePos.OUT_OF_WORLD, LotView.Model.Direction.NORTH).Objects[0];
                ((VMAvatar)sim).SetPersonData(VMPersonDataVariable.TS1FamilyNumber, (short)CurrentFamily.ChunkID);
                var mailbox = vm.Entities.FirstOrDefault(x => (x.Object.OBJ.GUID == 0xEF121974 || x.Object.OBJ.GUID == 0x1D95C9B0));
                if (mailbox != null)
                {
                    VMFindLocationFor.FindLocationFor(sim, mailbox, vm.Context, VMPlaceRequestFlags.Default);
                }
                ((VMAvatar)sim).AvatarState.Permissions = Model.TSOPlatform.VMTSOAvatarPermissions.Owner;

                vm.Scheduler.RescheduleInterrupt(sim);
            }
        }
Example #2
0
        public override bool Execute(VM vm)
        {
            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);
            }
            sim.PersistID = SimID;

            VMAvatar avatar = (VMAvatar)sim;

            avatar.SkinTone = (Vitaboy.AppearanceType)SkinTone;
            avatar.SetPersonData(VMPersonDataVariable.Gender, (short)((Gender) ? 1 : 0));
            avatar.DefaultSuits         = new VMAvatarDefaultSuits(Gender);
            avatar.DefaultSuits.Daywear = BodyID;
            avatar.BodyOutfit           = BodyID;
            avatar.HeadOutfit           = HeadID;
            avatar.Name = Name;

            vm.SignalChatEvent(new VMChatEvent(avatar.PersistID, VMChatEventType.Join, avatar.Name));

            return(true);
        }
        public NetworkClient Client; //REPLACE WHEN MOVING OFF GONZONET!!

        public override bool Execute(VM vm)
        {
            Name = Name.Substring(0, Math.Min(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)
            {
                TSO.HIT.HITVM.Get().PlaySoundEvent("lot_enter");
            }
            if (mailbox != null)
            {
                VMFindLocationFor.FindLocationFor(sim, mailbox, vm.Context);
            }
            sim.PersistID = ActorUID;

            VMAvatar avatar = (VMAvatar)sim;

            avatar.SkinTone = (Vitaboy.AppearanceType)SkinTone;
            avatar.SetPersonData(VMPersonDataVariable.Gender, (short)((Gender) ? 1 : 0));
            avatar.BodyOutfit = BodyID;
            avatar.HeadOutfit = HeadID;
            avatar.Name       = Name;
            ((VMTSOAvatarState)avatar.TSOState).Permissions = Permissions;



            return(true);
        }
Example #4
0
File: VM.cs Project: fourks/FreeSO
        /// <summary>
        /// Ensure all members of the family are present on the lot.
        /// Spawns missing family members at the mailbox.
        /// </summary>
        public void VerifyFamily()
        {
            if (CurrentFamily == null)
            {
                return;
            }
            SetGlobalValue(9, (short)CurrentFamily.ChunkID);
            var missingMembers = new HashSet <uint>(CurrentFamily.FamilyGUIDs);

            foreach (var avatar in Context.ObjectQueries.Avatars)
            {
                missingMembers.Remove(avatar.Object.OBJ.GUID);
            }

            foreach (var member in missingMembers)
            {
                var sim = Context.CreateObjectInstance(member, LotView.Model.LotTilePos.OUT_OF_WORLD, LotView.Model.Direction.NORTH).Objects[0];
                ((VMAvatar)sim).SetPersonData(VMPersonDataVariable.TS1FamilyNumber, (short)CurrentFamily.ChunkID);
                var mailbox = Entities.FirstOrDefault(x => (x.Object.OBJ.GUID == 0xEF121974 || x.Object.OBJ.GUID == 0x1D95C9B0));
                if (mailbox != null)
                {
                    VMFindLocationFor.FindLocationFor(sim, mailbox, Context, VMPlaceRequestFlags.Default);
                }
            }
        }
Example #5
0
        public NetworkClient Client; //REPLACE WHEN MOVING OFF GONZONET!!

        public override bool Execute(VM vm)
        {
            Name = Name.Substring(0, Math.Min(Name.Length, 64));
            var sim     = vm.Context.CreateObjectInstance(VMAvatar.TEMPLATE_PERSON, LotTilePos.OUT_OF_WORLD, Direction.NORTH, false).Objects[0];
            var mailbox = vm.Entities.FirstOrDefault(x => (x.Object.OBJ.GUID == 0xEF121974 || x.Object.OBJ.GUID == 0x1D95C9B0 ||
                                                           x.Object.OBJ.GUID == 0x865A6812));

            LotTilePos pos = mailbox.Position;

            pos.x = (short)(mailbox.Position.x + 1);
            pos.y = (short)(mailbox.Position.y + 1);

            if (VM.UseWorld)
            {
                TSO.HIT.HITVM.Get().PlaySoundEvent("lot_enter");
            }
            if (mailbox != null)
            {
                VMFindLocationFor.FindLocationFor(sim, mailbox, vm.Context);
            }
            ((VMAvatar)sim).Visitor = ActorUID == 0 ? true : false;
            sim.PersistID           = ActorUID;

            VMAvatar avatar = (VMAvatar)sim;

            avatar.SkinTone = (Vitaboy.AppearanceType)SkinTone;
            avatar.SetPersonData(VMPersonDataVariable.Gender, (short)((Gender) ? 1 : 0));
            avatar.DefaultSuits         = new VMAvatarDefaultSuits(Gender);
            avatar.DefaultSuits.Daywear = BodyID;
            avatar.BodyOutfit           = BodyID;
            avatar.HeadOutfit           = HeadID;
            avatar.Name = Name;
            ((VMTSOAvatarState)avatar.TSOState).Budget.Value = 999999;
            ((VMTSOAvatarState)avatar.TSOState).Permissions  = Permissions;

            avatar.SetPosition(pos, Direction.WEST, vm.Context);


            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
            }

            if (RequesterID == vm.MyUID)
            {
                vm.MyUID = ActorUID;                          //we're this sim! try send commands as them.
            }
            vm.SignalChatEvent(new VMChatEvent(avatar.PersistID, VMChatEventType.Join, avatar.Name));


            return(true);
        }
Example #6
0
        //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 void Tick()
        {
            Velocity = new Vector3(0, 0, 0);
            base.Tick();

            if (Message != "")
            {
                if (MessageTimeout-- > 0)
                {
                    if (MessageTimeout == 0)
                    {
                        SetPersonData(VMPersonDataVariable.ChatBaloonOn, 0);
                        m_Message = "";
                    }
                }
            }

            if (Thread != null && Thread.ThreadBreak == Engine.VMThreadBreakMode.Pause)
            {
                return;
            }

            if (PersonData[(int)VMPersonDataVariable.OnlineJobStatusFlags] == 0)
            {
                PersonData[(int)VMPersonDataVariable.OnlineJobStatusFlags] = 1;
            }
            if (Thread != null)
            {
                MotiveDecay.Tick(this, Thread.Context);
                SetPersonData(VMPersonDataVariable.OnlineJobGrade, Math.Max((short)0, Thread.Context.VM.GetGlobalValue(11))); //force job grade to what we expect
                if (Position == LotTilePos.OUT_OF_WORLD)
                {
                    //uh oh!
                    var mailbox = Thread.Context.VM.Entities.FirstOrDefault(x => (x.Object.OBJ.GUID == 0xEF121974 || x.Object.OBJ.GUID == 0x1D95C9B0));
                    if (mailbox != null)
                    {
                        VMFindLocationFor.FindLocationFor(this, mailbox, Thread.Context);
                    }
                }
            }

            //animation update for avatars
            VMAvatar avatar      = this;
            float    totalWeight = 0f;

            foreach (var state in Animations)
            {
                totalWeight += state.Weight;
                if (!state.EndReached && state.Weight != 0)
                {
                    if (state.PlayingBackwards)
                    {
                        state.CurrentFrame -= state.Speed;
                    }
                    else
                    {
                        state.CurrentFrame += state.Speed;
                    }
                    var currentFrame = state.CurrentFrame;
                    var currentTime  = currentFrame * 33.33f;
                    var timeProps    = state.TimePropertyLists;
                    if (!state.PlayingBackwards)
                    {
                        for (var i = 0; i < timeProps.Count; i++)
                        {
                            var tp = timeProps[i];
                            if (tp.ID > currentTime)
                            {
                                break;
                            }

                            timeProps.RemoveAt(0);
                            i--;

                            HandleTimePropsEvent(tp);
                        }
                    }
                    else
                    {
                        for (var i = timeProps.Count - 1; i >= 0; i--)
                        {
                            var tp = timeProps[i];
                            if (tp.ID < currentTime)
                            {
                                break;
                            }

                            timeProps.RemoveAt(timeProps.Count - 1);
                            HandleTimePropsEvent(tp);
                        }
                    }

                    var status = Animator.RenderFrame(avatar.Avatar, state.Anim, (int)state.CurrentFrame, state.CurrentFrame % 1f, state.Weight / totalWeight);
                    if (status != AnimationStatus.IN_PROGRESS)
                    {
                        if (state.Loop)
                        {
                            if (state.PlayingBackwards)
                            {
                                state.CurrentFrame += state.Anim.NumFrames;
                            }
                            else
                            {
                                state.CurrentFrame -= state.Anim.NumFrames;
                            }
                        }
                        else
                        {
                            state.EndReached = true;
                        }
                    }
                }
            }

            if (avatar.CarryAnimationState != null)
            {
                var status = Animator.RenderFrame(avatar.Avatar, avatar.CarryAnimationState.Anim, (int)avatar.CarryAnimationState.CurrentFrame, 0.0f, 1f); //currently don't advance frames... I don't think any of them are animated anyways.
            }

            for (int i = 0; i < 16; i++)
            {
                MotiveChanges[i].Tick(this); //tick over motive changes
            }

            avatar.Avatar.ReloadSkeleton();

            PersonData[(int)VMPersonDataVariable.TickCounter]++;
            if (KillTimeout > -1)
            {
                if (++KillTimeout > FORCE_DELETE_TIMEOUT)
                {
                    Delete(true, Thread.Context);
                }
                else
                {
                    SetPersonData(VMPersonDataVariable.RenderDisplayFlags, 1);
                    SetValue(VMStackObjectVariable.Hidden, (short)((KillTimeout % 30) / 15));
                    if (Thread.BlockingState != null)
                    {
                        Thread.BlockingState.WaitTime = Math.Max(Thread.BlockingState.WaitTime, 1000000); //make most things time out
                    }
                    UserLeaveLot();                                                                       //keep forcing
                }
            }
        }