Exemplo n.º 1
0
        void TestPrefabs(BasePlayer player)
        {
            //string prefab = "assets/prefabs/deployable/covers/cover_b.prefab";
            string     prefab = "assets/bundled/prefabs/system/debug/debug_camera.prefab";
            GameObject obj    = GameManager.server.CreatePrefab(prefab);

            obj.transform.position = player.transform.position;
            //obj.transform.SetParent(player.transform);
            foreach (Component comp in obj.GetComponents <Component>())
            {
                JakePlugin.Write(comp);
            }

            /*BaseNetworkable entity =
             * if (entity != null)
             * {
             *  entity.Spawn();
             *  entity.SetParent(player, "RustPlayer");
             *  entity.transform.position = new Vector3(0, 0, 0);
             *  BuildingBlock block = (BuildingBlock)entity;
             *  //entity.transform.position = player.transform.position;
             *  entity.transform.rotation = Quaternion.Euler(0, 0, 0);
             *  //entity.SendNetworkUpdate();
             *  fakeEntities.Add(entity);
             *  JakePlugin.Write("Object spawned");
             * }
             * return entity;*/
        }
Exemplo n.º 2
0
        void SpawnEntity(Vector3 pos, BasePlayer player)
        {
            //string prefab = "assets/prefabs/weapons/ak47u/ak47u.entity.prefab";
            string prefab = "assets/prefabs/ammo/arrow/arrow.prefab";
            //BaseEntity bear = SpawnAsBear(player);
            BaseEntity entity = GameManager.server.CreateEntity(prefab);

            if (entity != null)
            {
                //entity.transform.localPosition = new Vector3(0, 5, 0);
                entity.Spawn();
                for (int i = 0; i < player.skeletonProperties.bones.Length - 30; i++)
                {
                    JakePlugin.Write(player.skeletonProperties.bones[i].bone.name);
                }
                entity.SetParent(player, "RustPlayer");
                //entity.SetParent(bear, "RustPlayer");
                entity.transform.position = new Vector3(0, 0, 0);
                entity.transform.rotation = Quaternion.Euler(0, 0, 0);
                entity.SendNetworkUpdateImmediate();
                fakeEntities.Add(entity);
                JakePlugin.Write("Object spawned");
            }
            //BaseNetworkable entity = GameManager.server.CreateEntity(prefab, parent:player.transform);
        }
Exemplo n.º 3
0
        void InitHiddenRooms()
        {
            foreach (BaseEntity item in GameObject.FindObjectsOfType <BaseEntity>())
            {
                if (true)
                {
                    //JakePlugin.Write(string.Format("{0} Found, has {1}", item.ShortPrefabName, item.GetEntityLinks(false).Count));
                }
            }
            foreach (BuildingBlock floor in GameObject.FindObjectsOfType <BuildingBlock>())
            {
                //JakePlugin.Write(floor.ShortPrefabName);
                if (floorPrefabNames.Contains(floor.ShortPrefabName))
                {
                    MyRoom room = new MyRoom();
                    room.floor = floor;
                    Stack <BaseEntity> queueToCheck = new Stack <BaseEntity>();
                    queueToCheck.Push(floor);
                    floor.gameObject.transform.DestroyAllChildren();
                    //JakePlugin.Write(string.Format("{0} has {1} entity links", floor.ShortPrefabName, ));
                    if (floor.children != null)
                    {
                        JakePlugin.Write(string.Format("{1} has {0} children", floor.children.Count, floor.ShortPrefabName));
                    }
                    while (queueToCheck.Count > 0)
                    {
                        BaseEntity current = queueToCheck.Pop();
                        if (current.children != null)
                        {
                            foreach (BaseEntity item in current.children)
                            {
                                queueToCheck.Push(item);
                                room.contents.Add(item);
                            }
                        }
                    }
                    if (!individualRooms.ContainsKey(room.floor.net.ID))
                    {
                        individualRooms.Add(room.floor.net.ID, room);
                    }
                    else
                    {
                        JakePlugin.Write("Room already exists!");
                    }

                    JakePlugin.Write(string.Format("Room has {0} children", room.contents.Count));
                }
            }
            JakePlugin.Write(string.Format("{0} rooms", individualRooms.Count));
            InitConnectRooms();
        }
Exemplo n.º 4
0
        BaseEntity SpawnAsBear(BasePlayer player)
        {
            string     prefab = "assets/bundled/prefabs/autospawn/animals/bear.prefab";
            BaseEntity entity = GameManager.server.CreateEntity(prefab);

            if (entity != null)
            {
                entity.Spawn();
                entity.SetParent(player, "RustPlayer");
                entity.transform.position = new Vector3(0, 0, 0);
                entity.transform.rotation = Quaternion.Euler(0, 0, 0);
                entity.SendNetworkUpdate();
                fakeEntities.Add(entity);
                JakePlugin.Write("Object spawned");
            }
            return(entity);
        }
Exemplo n.º 5
0
        BaseEntity TestPrefab(BasePlayer player)
        {
            //string prefab = "assets/prefabs/deployable/covers/cover_b.prefab";
            string     prefab = "assets/prefabs/tools/flashlight/flashlight.weapon.prefab";
            BaseEntity entity = GameManager.server.CreateEntity(prefab, player.transform.position);

            if (entity != null)
            {
                entity.Spawn();
                //entity.SetParent(player, "RustPlayer");
                entity.transform.position = player.transform.position;
                //entity.transform.position = player.transform.position;
                entity.transform.rotation = Quaternion.Euler(0, 0, 0);
                entity.SendNetworkUpdate();
                fakeEntities.Add(entity);
                JakePlugin.Write("Object spawned");
            }
            return(entity);
        }
Exemplo n.º 6
0
        void InitConnectRooms()
        {
            foreach (MyRoom room in individualRooms.Values)
            {
                if (room.connectedRooms.rooms == null)
                {
                    room.connectedRooms.rooms = new HashSet <MyRoom>();
                    room.connectedRooms.rooms.Add(room);
                }
                List <EntityLink> entityLinks = room.floor.GetEntityLinks(true);
                //JakePlugin.Write("Entity Links:", entityLinks.Count);
                for (int i = 0; i < entityLinks.Count; i++)
                {
                    //JakePlugin.Write(entityLinks[i].name);
                }
                if (entityLinks.Count == 9) //Triangle
                {
                    for (int i = 0; i < 3; i++)
                    {
                        //JakePlugin.Write(entityLinks[i].name);
                        if (entityLinks[i + 6].IsEmpty())    //Wall is empty
                        {
                            if (entityLinks[i].IsOccupied()) //Foundation Is attached
                            {
                                BuildingBlock connectedFloor = entityLinks[i].connections[0].owner as BuildingBlock;
                                MyRoom        adjacentRoom   = individualRooms[connectedFloor.net.ID];
                                if (adjacentRoom.connectedRooms.rooms != null)
                                {
                                    room.connectedRooms.rooms.UnionWith(adjacentRoom.connectedRooms.rooms);
                                    adjacentRoom.connectedRooms = room.connectedRooms;
                                }
                                else
                                {
                                    room.connectedRooms.rooms.Add(adjacentRoom);
                                    adjacentRoom.connectedRooms = room.connectedRooms;
                                }
                            }
                            else
                            {
                                room.connectedRooms.visibleOutside = true;
                            }
                        }
                        //JakePlugin.Write(string.Format("Slot {0} empty, {1}", i, entityLinks[i].gender));
                    }
                }
            }

            foreach (MyRoom room in individualRooms.Values)
            {
                JakePlugin.Write(room.connectedRooms.rooms.Count, "rooms connected");
                completeRooms.Add(room.connectedRooms);
            }

            int count = 0;

            foreach (CompletedRoom room in completeRooms)
            {
                count++;
                if (room.visibleOutside)
                {
                    JakePlugin.Write("Room visible outside");
                }
                else
                {
                    JakePlugin.Write("Room invisible");
                }
            }

            JakePlugin.Write(completeRooms.Count, "individual rooms");
        }