コード例 #1
0
 public void SpawnItemFromSpawnPoint(DatabaseConfigItemEntry item)
 {
     if (plugin.db.Spawns[item.SpawnName].RoomName.ToLower().Equals("none"))
     {
         SpawnPosition spos      = plugin.db.Spawns[item.SpawnName].Position;
         Vector3       pos       = new Vector3(spos.X, spos.Y, spos.Z);
         ItemType      type      = (ItemType)Enum.Parse(typeof(ItemType), item.ItemName, true);
         Pickup        itemworld = type.Spawn(0f, pos);
         itemworld.RefreshDurability(true, true);
         Log.Debug("Spawning " + type.ToString() + " at: " + pos.ToString());
         return;
     }
     foreach (var room in Map.Rooms)
     {
         if (room.Name.ToLower().Contains(plugin.db.Spawns[item.SpawnName].RoomName.ToLower()))
         {
             SpawnPosition spos      = plugin.db.Spawns[item.SpawnName].Position;
             Vector3       pos       = new Vector3(spos.X, spos.Y, spos.Z);
             ItemType      type      = (ItemType)Enum.Parse(typeof(ItemType), item.ItemName, true);
             Pickup        itemworld = type.Spawn(0f, room.Transform.TransformPoint(pos));
             itemworld.RefreshDurability(true, true);
             Log.Debug("Spawning " + type.ToString() + " at: " + pos.ToString());
         }
     }
 }
コード例 #2
0
        public void SpawnGameObjFromSpawnPoint(GameObject item, string spawn, string tag)
        {
            if (plugin.db.Spawns[spawn].RoomName.ToLower().Equals("none"))
            {
                if (plugin.Config.csp_replace_player_spawns && !replacedPlayerSpawns.Contains(tag))
                {
                    GameObject[] spawns = GameObject.FindGameObjectsWithTag(tag);
                    for (int i = 0; i < spawns.Length; i++)
                    {
                        GameObject.Destroy(spawns[i]);
                    }
                    replacedPlayerSpawns.Add(tag);
                }
                SpawnPosition spos = plugin.db.Spawns[spawn].Position;
                Vector3       pos  = new Vector3(spos.X, spos.Y, spos.Z);
                var           go   = GameObject.Instantiate(item);
                go.transform.position = pos;
                go.tag = tag;
                Log.Debug("Spawning at: " + pos.ToString());
                return;
            }
            int found = 0;

            foreach (var room in Map.Rooms)
            {
                if (room.Name.ToLower().Contains(plugin.db.Spawns[spawn].RoomName.ToLower()))
                {
                    SpawnPosition spos = plugin.db.Spawns[spawn].Position;
                    Vector3       pos  = new Vector3(spos.X, spos.Y, spos.Z);
                    var           go   = GameObject.Instantiate(item);
                    go.transform.position = room.Transform.TransformPoint(pos);
                    go.tag = tag;
                    Log.Debug("Spawning at: " + pos.ToString());
                    found++;
                }
            }
            if (found > 0 && plugin.Config.csp_replace_player_spawns && !replacedPlayerSpawns.Contains(tag))
            {
                GameObject[] spawns = GameObject.FindGameObjectsWithTag(tag);
                for (int i = 0; i < spawns.Length; i++)
                {
                    GameObject.Destroy(spawns[i]);
                }
                replacedPlayerSpawns.Add(tag);
            }
            foreach (var room in Map.Rooms)
            {
                if (room.Name.ToLower().Contains(plugin.db.Spawns[spawn].RoomName.ToLower()))
                {
                    SpawnPosition spos = plugin.db.Spawns[spawn].Position;
                    Vector3       pos  = new Vector3(spos.X, spos.Y, spos.Z);
                    var           go   = GameObject.Instantiate(item);
                    go.transform.position = room.Transform.TransformPoint(pos);
                    go.tag = tag;
                    Log.Debug("Spawning at: " + pos.ToString());
                }
            }
        }