public static GameObject Spawn(string prefab, Vector3 position, Quaternion rotation, int count)
        {
            GameObject gameObject = null;

            for (int i = 0; i < count; i++)
            {
                if (prefab == ":player_soldier")
                {
                    gameObject = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, position, rotation);
                }
                else if (prefab.Contains("C130"))
                {
                    gameObject = NetCull.InstantiateClassic(prefab, position, rotation, 0);
                }
                else
                {
                    gameObject = NetCull.InstantiateStatic(prefab, position, rotation);
                    gameObject.GetComponent <StructureComponent>();
                    DeployableObject component = gameObject.GetComponent <DeployableObject>();
                    if (component != null)
                    {
                        component.ownerID   = 0uL;
                        component.creatorID = 0uL;
                        component.CacheCreator();
                        component.CreatorSet();
                    }
                }
            }
            return(gameObject);
        }
Example #2
0
        private object Spawn(string prefab, Vector3 location, Quaternion rotation, int rep)
        {
            prefab = prefab.Trim();
            object obj2 = null;

            try
            {
                for (int i = 0; i < rep; i++)
                {
                    if (prefab == ":player_soldier")
                    {
                        obj2 = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, location, rotation);
                    }
                    else if (prefab.Contains("C130"))
                    {
                        obj2 = NetCull.InstantiateClassic(prefab, location, rotation, 0);
                    }
                    else
                    {
                        GameObject obj3 = NetCull.InstantiateStatic(prefab, location, rotation);
                        obj2 = obj3;
                        StructureComponent component = obj3.GetComponent <StructureComponent>();
                        if (component != null)
                        {
                            obj2 = new Entity(component);
                        }
                        else if (obj3.GetComponent <LootableObject>())
                        {
                            obj2 = new Entity(obj3.GetComponent <LootableObject>());
                        }
                        else if (obj3.GetComponent <SupplyCrate>())
                        {
                            obj2 = new Entity(obj3.GetComponent <SupplyCrate>());
                        }
                        else if (obj3.GetComponent <ResourceTarget>())
                        {
                            obj2 = new Entity(obj3.GetComponent <ResourceTarget>());
                        }
                        else
                        {
                            DeployableObject obj4 = obj3.GetComponent <DeployableObject>();
                            if (obj4 != null)
                            {
                                obj4.ownerID   = 0L;
                                obj4.creatorID = 0L;
                                obj4.CacheCreator();
                                obj4.CreatorSet();
                                obj2 = new Entity(obj4);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogError("Spawn error: " + e.ToString());
            }
            return(obj2);
        }
Example #3
0
            public GameObject SpawnGeneric(Spawns.SpawnerGeneric.SpawnInstance instance)
            {
                Vector3 startPos = this.Position + UnityEngine.Random.insideUnitSphere * this.SpawnRadius;

                startPos.y = this.Position.y;
                Quaternion quaternion = Quaternion.Euler(new Vector3(0f, (float)UnityEngine.Random.Range(0, 360), 0f));
                Vector3    vector;

                if (instance.UseNavmeshSample && TransformHelpers.GetGroundInfoNavMesh(startPos, out vector, 15f, -1))
                {
                    startPos = vector;
                }
                Vector3    up;
                GameObject result;

                if (TransformHelpers.GetGroundInfoTerrainOnly(startPos, 300f, out vector, out up))
                {
                    vector.y += 0.05f;
                    if (instance.PrefabName == "BoxLoot")
                    {
                        vector.y += 0.35f;
                    }
                    quaternion = TransformHelpers.LookRotationForcedUp(quaternion * Vector3.forward, up);
                    GameObject gameObject;
                    if (!instance.StaticInstantiate && !instance.PrefabName.StartsWith(";"))
                    {
                        gameObject = NetCull.InstantiateDynamic(instance.PrefabName, vector, quaternion);
                    }
                    else
                    {
                        gameObject = NetCull.InstantiateStatic(instance.PrefabName, vector, quaternion);
                    }
                    if (gameObject != null)
                    {
                        instance.Spawned.Add(gameObject);
                    }
                    result = gameObject;
                }
                else
                {
                    result = null;
                }
                return(result);
            }
Example #4
0
        private object Spawn(string prefab, Vector3 location, Quaternion rotation, int rep)
        {
            Contract.Requires(!string.IsNullOrEmpty(prefab));
            Contract.Requires(rep >= 0);

            object obj2 = null;

            for (int i = 0; i < rep; i++)
            {
                if (prefab == ":player_soldier")
                {
                    obj2 = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, location, rotation);
                }
                else if (prefab.Contains("C130"))
                {
                    obj2 = NetCull.InstantiateClassic(prefab, location, rotation, 0);
                }
                else
                {
                    GameObject obj3 = NetCull.InstantiateStatic(prefab, location, rotation);
                    obj2 = obj3;
                    StructureComponent component = obj3.GetComponent <StructureComponent>();
                    if (component != null)
                    {
                        obj2 = new Entity(component);
                    }
                    else
                    {
                        DeployableObject obj4 = obj3.GetComponent <DeployableObject>();
                        if (obj4 != null)
                        {
                            obj4.ownerID   = 0L;
                            obj4.creatorID = 0L;
                            obj4.CacheCreator();
                            obj4.CreatorSet();
                            obj2 = new Entity(obj4);
                        }
                    }
                }
            }
            return(obj2);
        }
        private object Spawn(string prefab, Vector3 location, Quaternion rotation, int rep)
        {
            object result = null;

            for (int i = 0; i < rep; i++)
            {
                if (prefab == ":player_soldier")
                {
                    result = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, location, rotation);
                }
                else if (prefab.Contains("C130"))
                {
                    result = NetCull.InstantiateClassic(prefab, location, rotation, 0);
                }
                else
                {
                    GameObject gameObject = NetCull.InstantiateStatic(prefab, location, rotation);
                    result = gameObject;
                    StructureComponent component = gameObject.GetComponent <StructureComponent>();
                    if (component != null)
                    {
                        result = new Entity(component);
                    }
                    else
                    {
                        DeployableObject component2 = gameObject.GetComponent <DeployableObject>();
                        if (component2 != null)
                        {
                            component2.ownerID   = 0uL;
                            component2.creatorID = 0uL;
                            component2.CacheCreator();
                            component2.CreatorSet();
                            result = new Entity(component2);
                        }
                    }
                }
            }
            return(result);
        }
        public static void OnShoot(ShootEvent se)
        {
            if (RustPP.Data.Globals.UserIsLogged(se.Player))
            {
                RustPP.Data.Entities.User user = RustPP.Data.Globals.GetInternalUser(se.Player);
                if (user.SpawningPrefab)
                {
                    UnityEngine.Quaternion rotation = se.Player.Character.rotation;

                    /*Controllable controllable = se.Player.Character.controllable;
                     * if (user.PrefabName == ":player_soldier")
                     * {
                     *  ServerManagement.Get().EraseCharactersForClient(se.Player.PlayerClient, true, se.Player.NetUser);
                     * }*/
                    NetCull.InstantiateDynamic(user.PrefabName, se.EndPos, rotation);

                    /*if(user.PrefabName == ":player_soldier")
                     * {
                     *  se.Player.PlayerClient = ServerManagement.Get().CreatePlayerClientForUser(se.Player.NetUser);
                     * }*/
                }
            }
        }