コード例 #1
0
            private static GameObject smethod_183(Spawns.SpawnerLootable spawnerLootable_0)
            {
                GameObject result;

                if (spawnerLootable_0.SpawnedObject == null && spawnerLootable_0.vector3_0 != Vector3.zero && spawnerLootable_0.List.Count > 0)
                {
                    string text = spawnerLootable_0.method_0();
                    if (text != null)
                    {
                        Vector3 vector;
                        Vector3 vector2;
                        TransformHelpers.GetGroundInfo(spawnerLootable_0.vector3_0, out vector, out vector2);
                        if (text == "BoxLoot")
                        {
                            vector.y += 0.35f;
                        }
                        Quaternion     quaternion = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f);
                        GameObject     gameObject = NetCull.InstantiateStatic(text, vector, quaternion);
                        LootableObject component  = gameObject.GetComponent <LootableObject>();
                        if (component != null)
                        {
                            component.LootCycle = spawnerLootable_0.List[text].LootCycle;
                            component.lifeTime  = spawnerLootable_0.List[text].LifeTime;
                            component.ResetInvokes();
                        }
                        result = gameObject;
                        return(result);
                    }
                }
                result = spawnerLootable_0.SpawnedObject;
                return(result);
            }
コード例 #2
0
        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);
        }
コード例 #3
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);
        }
コード例 #4
0
        DeployableObject SpawnDeployable(string prefab, Vector3 pos, Quaternion angles)
        {
            DeployableObject build = NetCull.InstantiateStatic(prefab, pos, angles).GetComponent <DeployableObject>();

            if (build == null)
            {
                return(null);
            }
            return(build);
        }
コード例 #5
0
        StructureComponent SpawnStructure(string prefab, Vector3 pos, Quaternion angle)
        {
            StructureComponent build = NetCull.InstantiateStatic(prefab, pos, angle).GetComponent <StructureComponent>();

            if (build == null)
            {
                return(null);
            }
            return(build);
        }
コード例 #6
0
        /// <summary>
        /// Spawns a prefab at the given vector, rotation, N times.
        /// IMPORTANT: Returns the prefab as an Entity class.
        /// Entity class only supports specific types, like LootableObject
        /// SupplyCrate, ResourceTarget, DeployableObject, StructureComponent,
        /// StructureMaster.
        /// The other spawn methods are returning the gameobject instead.
        /// </summary>
        /// <param name="prefab"></param>
        /// <param name="location"></param>
        /// <param name="rotation"></param>
        /// <param name="rep"></param>
        /// <returns></returns>
        public Entity SpawnEntity(string prefab, Vector3 location, Quaternion rotation, int rep = 1)
        {
            Entity obj2 = null;

            prefab = prefab.Trim();
            try
            {
                for (int i = 0; i < rep; i++)
                {
                    GameObject         obj3  = NetCull.InstantiateStatic(prefab, location, rotation);
                    StructureComponent build = obj3.GetComponent <StructureComponent>();
                    if (build != null)
                    {
                        obj2 = new Entity(build);
                    }
                    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("SpawnEntity error: " + e.ToString());
            }
            return(obj2);
        }
コード例 #7
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);
            }
コード例 #8
0
ファイル: World.cs プロジェクト: balu92/Fougerite
        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);
        }
コード例 #9
0
        private IEnumerator RefillAndSpawnCoroutine(LootStorage lootStorage)
        {
            foreach (var collider in Facepunch.MeshBatch.MeshBatchPhysics.OverlapSphere(
                         transform.position, 2))
            {
                if (collider.name.Contains("WoodBoxLarge"))
                {
                    NetCull.Destroy(collider.gameObject);
                }
            }

            var loot           = NetCull.InstantiateStatic(";deploy_wood_storage_large", transform.position, Quaternion.identity);
            var lootableObject = loot.GetComponent <LootableObject>();

            FillWithItems(lootableObject, lootStorage.GetItems());

            while (true)
            {
                var foundBox = false;

                foreach (var collider in Facepunch.MeshBatch.MeshBatchPhysics.OverlapSphere(
                             transform.position, 2))
                {
                    if (collider.name.Contains("WoodBoxLarge"))
                    {
                        foundBox = true;
                        break;
                    }
                }

                if (!foundBox)
                {
                    loot           = NetCull.InstantiateStatic(";deploy_wood_storage_large", transform.position, Quaternion.identity);
                    lootableObject = loot.GetComponent <LootableObject>();
                }

                lootableObject._inventory.Clear();
                FillWithItems(lootableObject, lootStorage.GetItems());

                yield return(new WaitForSeconds(lootStorage.RefillSeconds));
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
 public void NewObject()
 {
     DeployableObject = NetCull.InstantiateStatic(";deploy_wood_box", origin + h, character.rotation).GetComponent <DeployableObject>();
     DeployableObject.SetupCreator(character.controllable);
 }
コード例 #12
0
ファイル: Fly.cs プロジェクト: wilddip/oxideplugins
 void NewObject()
 {
     lastObject = NetCull.InstantiateStatic(";deploy_wood_box", nextForward + heightAdjusment, character.rotation).GetComponent <DeployableObject>();
     lastObject.SetupCreator(character.controllable);
 }