コード例 #1
0
ファイル: WaterWarsView.cs プロジェクト: cmickeyb/waterwars
        public SceneObjectGroup ReplaceSceneObjectFromInventoryItem(
            string itemName, AbstractGameModel gm, UUID ownerUuid)
        {
            RootPart.ParentGroup.Scene.DeleteSceneObject(RootPart.ParentGroup, false);
            SceneObjectGroup so = RezSceneObjectFromInventoryItem(itemName, gm, ownerUuid, RootPart.AbsolutePosition);

            // This should be pushed down into RezSceneObjectFromInventoryItem(), but other callers rely on the
            // scene object maintaining its original name for identification purposes (e.g. crops).
            so.Name = gm.Name;

            m_rootPart = so.RootPart;
            so.ScheduleGroupForFullUpdate();

            return so;
        }
コード例 #2
0
 public void TriggerGameModelSelected(Player p, AbstractGameModel gm)
 {
     if (OnGameModelSelected != null)
         OnGameModelSelected(p, gm);
 }
コード例 #3
0
ファイル: PlayerServices.cs プロジェクト: cmickeyb/waterwars
        /// <summary>
        /// Set the game object last selected by the player in-world
        /// </summary>
        /// <param name="playerId"></param>
        /// <param name="model"></param>
        public void SetLastSelected(UUID playerId, AbstractGameModel m)
        {
            //            m_log.InfoFormat("[WATER WARS]: Setting last selected for {0} to {1} type {2}", playerId, m.Name, m.Type);

            Player p = null;
            lock (m_controller.Game.Players)
                m_controller.Game.Players.TryGetValue(playerId, out p);

            //            m_log.InfoFormat(
            //                "[WATER WARS]: In SetLastSelected found {0} for uuid {1} when trying to set {2} type {3}",
            //                p != null ? p.Name : null, playerId, m.Name, m.Type);

            // XXX: At the moment, we don't serve selections to non-players
            if (null == p)
                return;

            lock (m_lastSelected)
            {
                // Remove our previous change listener
                if (m_lastSelectedChangeDelegates.ContainsKey(playerId))
                    m_lastSelected[playerId].OnChange -= m_lastSelectedChangeDelegates[playerId];

                // Set up a change listener so that any alterations to the model get propogated to the media browser
                // (the view)
                m_lastSelected[playerId] = m;
                m_lastSelectedChangeDelegates[playerId]
                    = delegate(AbstractModel model)
                    {
                        // XXX: Probably not required now that we have stopped listening to state changes and are
                        // firing general change events manually to avoid race conditions and multiple updates.
            //                        // If the game is in the revenue state while transitioning from the water state back
            //                        // to the build state then ignore any game asset updates.
            //                        // The reason for this is that the revenue changes will fire game asset updates, but
            //                        // these object updates will not include build owner actions.  While the client is updating and before
            //                        // it makes the next long poll, the subsequent start build stage event can fire.  However, this event
            //                        // will not be seen by the client and the user will end up with no build actions until they reselect
            //                        // the game asset.
            //                        if (m_controller.Game.State == GameStateType.Revenue)
            //                        {
            ////                            m_log.InfoFormat(
            ////                                "[WATER WARS]: Ignoring change of {0} for {1} since state is {2}",
            ////                                model.Name, playerId, m_controller.Game.State);
            //                                return;
            //                        }

            //                        m_log.InfoFormat(
            //                            "[WATER WARS]: Pulsing change of {0} for {1} since state is {2}",
            //                            model.Name, playerId, m_controller.Game.State);

                        Object obj = m_lastSelectedSyncObjects[playerId];

                        lock (obj)
                            Monitor.PulseAll(obj);
                    };

                m_controller.EventManager.TriggerGameModelSelected(p, m);
                m.OnChange += m_lastSelectedChangeDelegates[playerId];
            }

            // Pulse anybody waiting since the entire selected object has changed.
            // No need to lock since m_lastSelectedSyncObjects is only set on initialization
            Object o = m_lastSelectedSyncObjects[playerId];

            lock (o)
                Monitor.PulseAll(o);
            //m_lastSelectedResetEvents[playerId].Set();
        }
コード例 #4
0
ファイル: WaterWarsView.cs プロジェクト: cmickeyb/waterwars
        /// <summary>
        /// Rez a scene object from a given inventory item.
        /// </summary>
        /// <remarks>
        /// FIXME: In a better world we could just get the owner from AbstractGameModel.  However, various complications
        /// (e.g. the fact that buy points have development rights owners and water rights owners) prevents this  
        /// currently.
        /// </remarks>
        /// <param name="itemName"></param>
        /// <param name="gm"></param>
        /// <param name="ownerUuid"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        protected SceneObjectGroup RezSceneObjectFromInventoryItem(
            string itemName, AbstractGameModel gm, UUID ownerUuid, Vector3 pos)
        {
            //            m_log.InfoFormat(
            //                "[WATER WARS]: Rezzing item {0} corresponding to game model {1} at {2}", itemName, gm.Name, pos);

            TaskInventoryItem item = GetItem(m_itemStoreView, itemName);

            // we're only doing this beforehand so that we can get the rotation (since the existing RezObject() doesn't
            // retain it.  FIXME FIXME FIXME
            //            AssetBase objectAsset = m_scene.AssetService.Get(item.AssetID.ToString());
            //            string xml = Utils.BytesToString(objectAsset.Data);
            //            SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(xml);

            SceneObjectGroup so = m_itemStoreView.RootPart.Inventory.GetRezReadySceneObject(item);
            so.UUID = gm.Uuid;
            so.OwnerID = ownerUuid;
            m_scene.AddNewSceneObject(so, true, pos, so.GroupRotation, Vector3.Zero);

            return so;
        }
コード例 #5
0
ファイル: Recorder.cs プロジェクト: cmickeyb/waterwars
        protected void ProcessGameModelSelected(Player p, AbstractGameModel gm)
        {
            if (null == m_xtw)
                return;

            if (!(gm is AbstractGameAsset || gm is BuyPoint))
                return;

            lock (this)
            {
                RecordEventStart(SelectedElement);
                RecordPlayerReference(p);
                if (gm is AbstractGameAsset)
                    RecordGameAssetReference(gm as AbstractGameAsset);
                else
                    RecordBuyPointReference(gm as BuyPoint);
                RecordEventEnd();
            }
        }