Beispiel #1
0
        private void RemovePlayerByUserId(uint userId)
        {
            int i = GetPlayerIndexByUserId(userId);

            if (i >= 0)
            {
                m_data.players.RemoveAt(i);
            }

            if (m_mapUserId2Address.ContainsKey(userId))
            {
                m_mapUserId2Address.Remove(userId);
            }
        }
Beispiel #2
0
 private void ItemManager_RefreshLegacyChestData_1(On.ItemManager.orig_RefreshLegacyChestData_1 orig, ItemManager self, ItemContainer chest)
 {
     try
     {
         if (chest != null)
         {
             OLogger.Log(chest.Name + ": " + chest.ItemCount);
         }
         //orig(self, chest);
         if (chest.ItemCount <= 0)
         {
             return;
         }
         Item item = null;
         item = chest.GetContainedItems()[0];
         if ((bool)item)
         {
             if (!m_legacyChestData.ContainsKey(chest.UID))
             {
                 m_legacyChestData.Add(chest.UID, new LegacyChestDataMod(chest));
             }
             m_legacyChestData[chest.UID].SetContainedData(item, chest.GetContainedItems().Count);
         }
     }
     catch (Exception ex)
     {
         OLogger.Error($"RefreshLegacyChestData={ex.Message}");
     }
 }
Beispiel #3
0
        public Color GetUniqueColor(int colorId)
        {
            if (m_mapColor.ContainsKey(colorId))
            {
                return(m_mapColor[colorId]);
            }

            Color c = new Color(random.Rnd(), random.Rnd(), random.Rnd());

            m_mapColor.Add(colorId, c);
            return(c);
        }
Beispiel #4
0
        public static void CreateView(string resPath, string resDefaultPath, EntityObject entity, Transform parent = null)
        {
            ViewObject obj         = null;
            string     recycleType = resPath;
            bool       useRecycler = true;

            obj = objRecycler.Pop(recycleType) as ViewObject;
            if (obj == null)
            {
                useRecycler = false;
                obj         = InstanceViewFromPrefab(recycleType, resDefaultPath);
            }

            if (obj != null)
            {
                if (!obj.gameObject.activeSelf)
                {
                    obj.gameObject.SetActive(true);
                }

                if (parent != null)
                {
                    obj.transform.SetParent(parent, false);
                }
                else
                {
                    obj.transform.SetParent(viewRoot, false);
                }

                obj.CreateInFactory(entity, recycleType);

                if (EnableLog && MyLogger.EnableLog)
                {
                    MyLogger.Log(LOG_TAG, "CreateView() {0}:{1} -> {2}:{3}, UseRecycler:{4}",
                                 entity.GetType().Name, entity.GetHashCode(),
                                 obj.GetRecycleType(), obj.GetInstanceID(),
                                 useRecycler);
                }

                if (mapObjectList.ContainsKey(entity))
                {
                    MyLogger.LogError(LOG_TAG, "CreateView()", " Mapping already exist!");
                }
                mapObjectList[entity] = obj;
            }
        }