예제 #1
0
        BaseEntity SpawnBackpack(BasePlayer player)
        {
            //string prefab = "assets/prefabs/deployable/woodenbox/woodbox_deployed.prefab";
            string           prefab = "assets/prefabs/deployable/small stash/small_stash_deployed.prefab";
            StorageContainer entity = (StorageContainer)GameManager.server.CreateEntity(prefab);

            if (entity != null)
            {
                backpackNetworking.Add(entity, player);
                if (entity.children != null)
                {
                    foreach (BaseEntity child in entity.children)
                    {
                        Puts("Child entity");
                        backpackNetworking.Add(entity, player);
                    }
                }
                entity.Spawn();
                entity.SetParent(player, "spine1");
                if (MyBackpackComponent.positionSettings.ContainsKey(prefab))
                {
                    entity.transform.position = MyBackpackComponent.positionSettings[prefab].offset;
                    entity.transform.rotation = Quaternion.Euler(MyBackpackComponent.positionSettings[prefab].rotation);
                }

                var colliders = entity.GetComponents <Collider>();
                foreach (Collider collider in colliders)
                {
                    //entity.gameObject.compon(collider);
                }

                Puts(entity.GetComponentsInParent <Collider>().Length.ToString());
                entity.SendNetworkUpdate();
                fakeEntities.Add(entity);
                var backPack = player.GetComponent <MyBackpackComponent>();
                if (backPack == null)
                {
                    backPack           = player.gameObject.AddComponent <MyBackpackComponent>();
                    backPack.container = entity;
                    backPack.lootPanel = "smallstash";
                    backpackData.Add(player, backPack);
                }
            }
            return(entity);
        }