Exemple #1
0
        public bool AddObject(Object obj, ushort zoneId, bool mustUpdateRange = false)
        {
            var info = GetZone_Info(zoneId);

            if (info == null)
            {
                Log.Error("RegionMgr",
                          "AddObject: Unable to add object " + obj.Name + " to invalid Zone with ID : " + zoneId);
                return(false);
            }

            var add = new ObjectAdd
            {
                Obj             = obj,
                ZoneId          = zoneId,
                MustUpdateRange = mustUpdateRange
            };

            //obj.MovementZone = GetZoneMgr(zoneId);

            lock (_objectsToAdd)
            {
                _objectsToAdd.Add(add);
            }

            return(true);
        }
Exemple #2
0
 public DeckScene()
 {
     ObjectAdd    = delegate(DeckObject deckObject) { };
     ObjectUpdate = delegate(DeckObject deckObject) { };
     ObjectRemove = delegate(DeckObject deckObject) { };
     BubbleAdd    = delegate(DeckBubble deckObject) { };
     BubbleRemove = delegate(DeckBubble deckObject) { };
 }
Exemple #3
0
        public UInt32 ObjectAdd(ObjectAdd p)
        {
            var rezparams = new RezObjectParams();
            var group     = new Object.ObjectGroup();
            var part      = new ObjectPart();

            group.Add(1, part.ID, part);
            group.Name = "Primitive";
            IAgent agent      = Agents[p.AgentID];
            UGUI   agentOwner = agent.Owner;

            group.LastOwner        = agentOwner;
            part.Creator           = agentOwner;
            rezparams.RezzingAgent = agentOwner;
            ObjectPart.PrimitiveShape pshape = part.Shape;
            pshape.PCode            = p.PCode;
            part.Material           = p.Material;
            pshape.PathCurve        = p.PathCurve;
            pshape.ProfileCurve     = p.ProfileCurve;
            pshape.PathBegin        = p.PathBegin;
            pshape.PathEnd          = p.PathEnd;
            pshape.PathScaleX       = p.PathScaleX;
            pshape.PathScaleY       = p.PathScaleY;
            pshape.PathShearX       = p.PathShearX;
            pshape.PathShearY       = p.PathShearY;
            pshape.PathTwist        = p.PathTwist;
            pshape.PathTwistBegin   = p.PathTwistBegin;
            pshape.PathRadiusOffset = p.PathRadiusOffset;
            pshape.PathTaperX       = p.PathTaperX;
            pshape.PathTaperY       = p.PathTaperY;
            pshape.PathRevolutions  = p.PathRevolutions;
            pshape.PathSkew         = p.PathSkew;
            pshape.ProfileBegin     = p.ProfileBegin;
            pshape.ProfileEnd       = p.ProfileEnd;
            pshape.ProfileHollow    = p.ProfileHollow;

            rezparams.RayStart             = p.RayStart;
            rezparams.RayEnd               = p.RayEnd;
            rezparams.RayTargetID          = p.RayTargetID;
            rezparams.RayEndIsIntersection = p.RayEndIsIntersection;
            rezparams.Scale    = p.Scale;
            rezparams.Rotation = p.Rotation;
            pshape.State       = p.State;
            group.AttachPoint  = p.LastAttachPoint;

            part.Size          = Vector3.One / 2.0;
            part.BaseMask      = p.BasePermissions;
            part.EveryoneMask  = p.EveryOnePermissions;
            part.OwnerMask     = p.CurrentPermissions;
            part.NextOwnerMask = p.NextOwnerPermissions;
            part.GroupMask     = p.GroupPermissions;
            part.Shape         = pshape;
            group.Group.ID     = p.GroupID;
            part.ObjectGroup   = group;
            part.Size          = Vector3.One / 2f;

            /* initial setup of object */
            part.UpdateData(ObjectPartLocalizedInfo.UpdateDataFlags.All);

            var selectedList = agent.SelectedObjects(ID);

            foreach (UUID old in selectedList.GetAndClear())
            {
                ObjectPart oldSelectedPart;
                if (Primitives.TryGetValue(old, out oldSelectedPart))
                {
                    agent.ScheduleUpdate(oldSelectedPart.UpdateInfo, ID);
                }
            }
            selectedList.Add(part.ID);

            return(RezObject(group, rezparams));
        }
        public void LinkToGameSession(string sessionKey, PlayerConnection myConnection)
        {
            try
            {
                var session = sessions.GetOrCreate(sessionKey);

                session.AddPlayer(myConnection);

                if (!session.IsOpenWorldSession && session.Bot == null)
                {
                    var bot = botManager.GetMostAvailable();
                    if (bot != null)
                    {
                        session.AssignBot(bot);
                    }
                }

                var allPlayers  = session.Players.GetAll();
                var connections = connectionProvider.GetConnectedActivePlayerConnections(session);

                var objects = session.Objects.GetAll();
                var npcs    = session.Npcs.GetAll();

                var myInventory = playerInventoryProvider.GetInventory(myConnection.Player.Id);

                foreach (var connection in connections)
                {
                    var isMe = connection.InstanceID == myConnection.InstanceID;
                    if (isMe)
                    {
                        connection.Send(MyPlayerAdd.Create(gameData, myConnection.Player, myInventory.Items), SendOption.Reliable);
                        //connection.Send(PlayerInventory.Create(myConnection.Player, inventory.Items), SendOption.Reliable);
                    }
                    else
                    {
                        connection.Send(PlayerAdd.Create(gameData, myConnection.Player), SendOption.Reliable);
                    }
                }

                foreach (var player in allPlayers)
                {
                    if (player.Id == myConnection.Player.Id)
                    {
                        continue;
                    }
                    myConnection.Send(PlayerAdd.Create(gameData, player), SendOption.Reliable);
                }

                foreach (var obj in objects)
                {
                    var gobj      = gameData.GetGameObject(obj.ObjectId);
                    var transform = gameData.GetTransform(gobj.TransformId);
                    if (gobj.Static)
                    {
                        if (obj.Type != gobj.Type)
                        {
                            myConnection.Send(ObjectUpdate.Create(obj, transform, gobj.Static), SendOption.Reliable);
                        }
                    }
                    else
                    {
                        myConnection.Send(ObjectAdd.Create(obj, transform), SendOption.Reliable);
                    }
                }

                foreach (var npc in npcs)
                {
                    var transform = gameData.GetTransform(npc.TransformId);
                    myConnection.Send(NpcAdd.Create(gameData, npc, transform), SendOption.Reliable);
                }
            }
            catch (Exception exc)
            {
                logger.LogInformation(exc.ToString());
            }
        }