Ejemplo n.º 1
0
        public bool TakeUserRights(uint UserId)
        {
            lock (mActorSyncRoot)
            {
                if (!mUsersWithRights.Contains(UserId))
                {
                    return(false);
                }

                mUsersWithRights.Remove(UserId);

                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    MySqlClient.SetParameter("roomid", RoomId);
                    MySqlClient.SetParameter("userid", UserId);
                    MySqlClient.ExecuteNonQuery("DELETE FROM room_rights WHERE room_id = @roomid AND user_id = @userid LIMIT 1");
                }

                RoomActor Actor = GetActorByReferenceId(UserId);

                if (Actor != null)
                {
                    Actor.RemoveStatus("flatctrl");
                    Actor.UpdateNeeded = true;

                    Session ActorSession = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);

                    if (ActorSession != null)
                    {
                        ActorSession.SendData(RoomRightsRemovedComposer.Compose());
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes an actor from the room instance. DO NOT CALL DIRECTLY FOR HUMAN CHARACTERS.
        /// </summary>
        /// <param name="ActorId">Id of the actor to remove.</param>
        /// <returns>Boolean based on success of removal.</returns>
        public bool RemoveActorFromRoom(uint ActorId)
        {
            bool Success = false;

            lock (mActorSyncRoot)
            {
                RoomActor Actor = GetActor(ActorId);

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

                if (Actor.Type == RoomActorType.UserCharacter)
                {
                    if (Actor.ReferenceId == Info.OwnerId && HasOngoingEvent)
                    {
                        StopEvent();
                    }

                    Trade Trade = TradeManager.GetTradeForUser(Actor.ReferenceId);

                    if (Trade != null)
                    {
                        TradeManager.StopTradeForUser(Trade.UserOne);
                        TradeManager.StopTradeForUser(Trade.UserTwo);

                        Session TargetSession = SessionManager.GetSessionByCharacterId(Actor.ReferenceId ==
                                                                                       Trade.UserOne ? Trade.UserTwo : Trade.UserOne);

                        if (TargetSession != null)
                        {
                            TargetSession.SendData(TradeAbortedComposer.Compose(Actor.ReferenceId));

                            RoomActor TargetActor = GetActorByReferenceId(TargetSession.CharacterId);

                            if (TargetActor != null)
                            {
                                TargetActor.RemoveStatus("trd");
                                TargetActor.UpdateNeeded = true;
                            }
                        }
                    }
                }

                foreach (RoomActor _Actor in mActors.Values)
                {
                    if (_Actor.Type == RoomActorType.AiBot)
                    {
                        if (_Actor.Id == Actor.Id)
                        {
                            Bot SelfBot = ((Bot)_Actor.ReferenceObject);
                            SelfBot.Brain.OnSelfLeaveRoom(this);

                            if (SelfBot.IsPet)
                            {
                                mPetCount--;
                            }
                        }
                        else
                        {
                            ((Bot)_Actor.ReferenceObject).Brain.OnUserLeave(this, Actor);
                        }
                    }
                }

                Success = mActors.Remove(ActorId);

                if (Success)
                {
                    BroadcastMessage(RoomUserRemovedComposer.Compose(ActorId));
                    MarkActorCountSyncNeeded();
                }
            }

            return(Success);
        }
Ejemplo n.º 3
0
        public void UpdateActorStatus(RoomActor Actor)
        {
            Vector2 Redirection = mRedirectGrid[Actor.Position.X, Actor.Position.Y];

            if (Redirection != null)
            {
                Actor.Position = new Vector3(Redirection.X, Redirection.Y, GetUserStepHeight(Redirection));
            }

            RoomTileEffect Effect = mTileEffects[Actor.Position.X, Actor.Position.Y];

            if (Effect == null)
            {
                return;
            }

            Dictionary <string, string> CurrentStatusses = Actor.UserStatusses;

            if (Effect.Type == RoomTileEffectType.Sit && !CurrentStatusses.ContainsKey("mv"))
            {
                string OldStatus = (CurrentStatusses.ContainsKey("sit") ? CurrentStatusses["sit"] : string.Empty);
                string NewStatus = Math.Round(Effect.InteractionHeight, 1).ToString().Replace(',', '.');

                if (Actor.BodyRotation != Effect.Rotation)
                {
                    Actor.BodyRotation = Effect.Rotation;
                    Actor.HeadRotation = Effect.Rotation;
                    Actor.UpdateNeeded = true;
                }

                if (NewStatus != OldStatus)
                {
                    Actor.SetStatus("sit", NewStatus);
                    Actor.UpdateNeeded = true;
                }
            }
            else if (CurrentStatusses.ContainsKey("sit"))
            {
                Actor.RemoveStatus("sit");
                Actor.UpdateNeeded = true;
            }

            if (Effect.Type == RoomTileEffectType.Lay && !CurrentStatusses.ContainsKey("mv"))
            {
                string OldStatus = (CurrentStatusses.ContainsKey("lay") ? CurrentStatusses["lay"] : string.Empty);
                string NewStatus = Math.Round(Effect.InteractionHeight, 1).ToString().Replace(',', '.');

                if (Actor.BodyRotation != Effect.Rotation)
                {
                    Actor.BodyRotation = Effect.Rotation;
                    Actor.HeadRotation = Effect.Rotation;
                    Actor.UpdateNeeded = true;
                }

                if (OldStatus != NewStatus)
                {
                    Actor.SetStatus("lay", NewStatus);
                    Actor.UpdateNeeded = true;
                }
            }
            else if (CurrentStatusses.ContainsKey("lay"))
            {
                Actor.RemoveStatus("lay");
                Actor.UpdateNeeded = true;
            }

            if (Effect.Type == RoomTileEffectType.Effect)
            {
                if ((Actor.AvatarEffectId != Effect.EffectId || !Actor.AvatarEffectByItem))
                {
                    Actor.ApplyEffect(Effect.EffectId, true, true);
                }
            }
            else if (Actor.AvatarEffectByItem)
            {
                int ClearEffect = 0;

                if (Actor.Type == RoomActorType.UserCharacter)
                {
                    Session SessionObject = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);

                    if (SessionObject != null)
                    {
                        ClearEffect = SessionObject.CurrentEffect;
                    }
                }
                else
                {
                    Bot BotObject = (Bot)Actor.ReferenceObject;

                    if (BotObject != null)
                    {
                        ClearEffect = BotObject.Effect;
                    }
                }

                Actor.ApplyEffect(ClearEffect, true, true);
            }

            if (Actor.Type == RoomActorType.UserCharacter && Effect.QuestData > 0)
            {
                Session SessionObject = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);

                if (SessionObject != null)
                {
                    QuestManager.ProgressUserQuest(SessionObject, QuestType.EXPLORE_FIND_ITEM, Effect.QuestData);
                }
            }
        }
Ejemplo n.º 4
0
        public void UpdateActorStatus(RoomActor Actor)
        {
            Vector2 Redirection = mRedirectGrid[Actor.Position.X, Actor.Position.Y];

            if (Redirection != null)
            {
                Actor.Position = new Vector3(Redirection.X, Redirection.Y, GetUserStepHeight(Redirection));
            }

            RoomTileEffect Effect = mTileEffects[Actor.Position.X, Actor.Position.Y];

            if (Effect == null)
            {
                return;
            }

            Dictionary<string, string> CurrentStatusses = Actor.UserStatusses;

            if (Effect.Type == RoomTileEffectType.Sit && !CurrentStatusses.ContainsKey("mv"))
            {
                string OldStatus = (CurrentStatusses.ContainsKey("sit") ? CurrentStatusses["sit"] : string.Empty);
                string NewStatus = Math.Round(Effect.InteractionHeight, 1).ToString().Replace(',', '.');

                if (Actor.BodyRotation != Effect.Rotation)
                {
                    Actor.BodyRotation = Effect.Rotation;
                    Actor.HeadRotation = Effect.Rotation;
                    Actor.UpdateNeeded = true;
                }

                if (NewStatus != OldStatus)
                {
                    Actor.SetStatus("sit", NewStatus);
                    Actor.UpdateNeeded = true;
                }
            }
            else if (CurrentStatusses.ContainsKey("sit"))
            {
                Actor.RemoveStatus("sit");
                Actor.UpdateNeeded = true;
            }

            if (Effect.Type == RoomTileEffectType.Lay && !CurrentStatusses.ContainsKey("mv"))
            {
                string OldStatus = (CurrentStatusses.ContainsKey("lay") ? CurrentStatusses["lay"] : string.Empty);
                string NewStatus = Math.Round(Effect.InteractionHeight, 1).ToString().Replace(',', '.');

                if (Actor.BodyRotation != Effect.Rotation)
                {
                    Actor.BodyRotation = Effect.Rotation;
                    Actor.HeadRotation = Effect.Rotation;
                    Actor.UpdateNeeded = true;
                }

                if (OldStatus != NewStatus)
                {
                    Actor.SetStatus("lay", NewStatus);
                    Actor.UpdateNeeded = true;
                }
            }
            else if (CurrentStatusses.ContainsKey("lay"))
            {
                Actor.RemoveStatus("lay");
                Actor.UpdateNeeded = true;
            }

            if (Effect.Type == RoomTileEffectType.Effect)
            {
                if ((Actor.AvatarEffectId != Effect.EffectId || !Actor.AvatarEffectByItem))
                {
                    Actor.ApplyEffect(Effect.EffectId, true, true);
                }
            }
            else if (Actor.AvatarEffectByItem)
            {
                int ClearEffect = 0;

                if (Actor.Type == RoomActorType.UserCharacter)
                {
                    Session SessionObject = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);

                    if (SessionObject != null)
                    {
                        ClearEffect = SessionObject.CurrentEffect;
                    }
                }
                else
                {
                    Bot BotObject = (Bot)Actor.ReferenceObject;

                    if (BotObject != null)
                    {
                        ClearEffect = BotObject.Effect;
                    }
                }

                Actor.ApplyEffect(ClearEffect, true, true);
            }

            if (Actor.Type == RoomActorType.UserCharacter && Effect.QuestData > 0)
            {
                Session SessionObject = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);

                if (SessionObject != null)
                {
                    QuestManager.ProgressUserQuest(SessionObject, QuestType.EXPLORE_FIND_ITEM, Effect.QuestData);
                }
            }
        }