Beispiel #1
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);
                }
            }
        }
Beispiel #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);
        }
Beispiel #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);
                }
            }
        }