Ejemplo n.º 1
0
        public bool AddBotToRoom(Bot Bot)
        {
            uint ActorId = GenerateActorId();

            RoomActor BotActor = RoomActor.TryCreateActor(ActorId, RoomActorType.AiBot, Bot.Id, Bot,
                                                          new Vector3(Bot.InitialPosition.X, Bot.InitialPosition.Y, Bot.InitialPosition.Z), 2, this);

            Bot.Brain.Initialize(Bot);

            if (BotActor != null)
            {
                AddActorToRoom(BotActor);

                if (Bot.IsPet)
                {
                    mPetCount++;
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public bool AddUserToRoom(Session Session)
        {
            if (Session.AbsoluteRoomId != RoomId || !Session.Authenticated)
            {
                return(false);
            }

            uint ActorId = GenerateActorId();

            if (ActorId == 0)
            {
                return(false);
            }

            Vector3 StartPosition = new Vector3(Model.DoorPosition.X, Model.DoorPosition.Y, Model.DoorPosition.Z);
            int     StartRotation = Model.DoorRotation;

            RoomActor NewActor = RoomActor.TryCreateActor(ActorId, RoomActorType.UserCharacter, Session.CharacterId,
                                                          Session.CharacterInfo, StartPosition, StartRotation, this);

            Item TargetTeleporter = null;

            if (Session.IsTeleporting)
            {
                TargetTeleporter = GetItem(Session.TargetTeleporterId);

                if (TargetTeleporter != null && !TargetTeleporter.TemporaryInteractionReferenceIds.ContainsKey(2))
                {
                    NewActor.Position = new Vector3(TargetTeleporter.RoomPosition.X, TargetTeleporter.RoomPosition.Y,
                                                    TargetTeleporter.RoomPosition.Z);
                    NewActor.HeadRotation = TargetTeleporter.RoomRotation;
                    NewActor.BodyRotation = TargetTeleporter.RoomRotation;
                    NewActor.UpdateNeeded = true;

                    TargetTeleporter.TemporaryInteractionReferenceIds.Add(2, NewActor.Id);
                    TargetTeleporter.DisplayFlags = "2";
                    TargetTeleporter.RequestUpdate(3);
                }

                Session.TargetTeleporterId = 0;
                Session.IsTeleporting      = false;
            }

            if (NewActor == null)
            {
                return(false);
            }

            AddActorToRoom(NewActor);

            if (TargetTeleporter != null)
            {
                TargetTeleporter.BroadcastStateUpdate(this);
            }

            if (CheckUserRights(Session, true))
            {
                NewActor.SetStatus("flatctrl", "useradmin");
                Session.SendData(RoomOwnerRightsComposer.Compose());
                Session.SendData(RoomRightsComposer.Compose());
            }
            else if (CheckUserRights(Session))
            {
                NewActor.SetStatus("flatctrl");
                Session.SendData(RoomRightsComposer.Compose());
            }

            if (Session.CurrentEffect > 0)
            {
                NewActor.ApplyEffect(Session.CurrentEffect);
            }

            WiredManager.HandleEnterRoom(NewActor);

            NewActor.UpdateNeeded = true;
            return(true);
        }