示例#1
0
        private object OnSwitchToggle(FuelGenerator eswitch, BasePlayer player)
        {
            if (eswitch == null)
            {
                return(null);
            }
            if (player == null)
            {
                return(null);
            }

            if (switches.Contains(eswitch.net.ID))
            {
#if DEBUG
                Puts("OnSwitchToggle called for one of our generators!");
#endif
                if (IsLocked(eswitch.net.ID))
                {
                    if (eswitch.OwnerID == player.userID && ownerBypass)
                    {
#if DEBUG
                        Puts("OnSwitchToggle: Per config, owner can bypass");
#endif
                        return(null);
                    }
                    Message(player.IPlayer, "locked");
                    return(true);
                }
            }
            return(null);
        }
示例#2
0
        private void OnEntitySpawned(FuelGenerator eswitch)
        {
            if (eswitch != null)
            {
                BasePlayer player = FindOwner(eswitch.OwnerID);
                if (player == null)
                {
#if DEBUG
                    Puts($"Could not find owner of this generator.");
#endif
                    return;
                }

                if (!player.IPlayer.HasPermission(permElectrolockUse))
                {
#if DEBUG
                    Puts($"Player {player.displayName} denied permission.");
#endif
                    return;
                }
                if (!userenabled.ContainsKey(player.userID))
                {
#if DEBUG
                    Puts($"Player {player.displayName} has never enabled ElectroLock.");
#endif
                    Message(player.IPlayer, "disabled");
                    return;
                }
                if (userenabled[player.userID] == false || userenabled[player.userID] == null)
                {
#if DEBUG
                    Puts($"Player {player.displayName} has ElectroLock disabled.");
#endif
                    Message(player.IPlayer, "disabled");
                    return;
                }

                if (eswitch)
                {
                    if (AddLock(eswitch, true))
                    {
                        switches.Add(eswitch.net.ID);
                        Message(player.IPlayer, "gspawned");
                        SaveData();
#if DEBUG
                        Puts($"Spawned generator with lock");
#endif
                    }
                    else
                    {
#if DEBUG
                        Puts($"Failed to spawn generator with lock");
#endif
                        Message(player.IPlayer, "gfailed");
                    }
                }
                player = null;
            }
        }
示例#3
0
    IEnumerator AddTerrain()
    {
        int spawnAscenderChance;
        int stayTheSameChanceBottom;
        int stayTheSameChanceTop;

        while (true)
        {
            terrainInstanceBottom = Instantiate(terrainBasicToLoad, startPositionBottom, transform.rotation) as GameObject;
            terrainBasicsBottom.Add(terrainInstanceBottom);

            previousTerrainHeight = terrainHeightBottom;

            stayTheSameChanceBottom = Random.Range(1, 3);                                                                                                       //creates a larger chance for terrain to stay the same height

            if (stayTheSameChanceBottom != 1)
            {
                terrainHeightBottom = Random.Range(1, 4);
            }

            if (terrainHeightBottom == previousTerrainHeight)                                                                                                   //spawns fuel if 2 terrain columns are the same height
            {
                FuelGenerator.SpawnFuel();
            }

            spawnAscenderChance = Random.Range(1, 6);                                                                                                                   //only spawns ascenders on 20% of terrain during an ascender event

            if (ShipGenerator.eventToLoad == 3 && spawnAscenderChance == 1)
            {
                ascenderSpawnPosition = new Vector2(9.191f, yValueAscender);

                StartCoroutine(AscenderEvent());
            }

            switch (terrainHeightBottom)
            {
            case 1:
                FuelGenerator.yValueChangeFuel = -4.121f;
                yValueAscender = -4.056f;
                break;

            case 2:
                terrainInstanceBottom = Instantiate(terrainBasicToLoad, startPositionBottom2, transform.rotation) as GameObject;
                terrainBasicsBottom.Add(terrainInstanceBottom);

                FuelGenerator.yValueChangeFuel = -3.621f;
                yValueAscender = -3.556f;
                break;

            case 3:
                terrainInstanceBottom = Instantiate(terrainBasicToLoad, startPositionBottom2, transform.rotation) as GameObject;
                terrainBasicsBottom.Add(terrainInstanceBottom);

                terrainInstanceBottom = Instantiate(terrainBasicToLoad, startPositionBottom3, transform.rotation) as GameObject;
                terrainBasicsBottom.Add(terrainInstanceBottom);

                FuelGenerator.yValueChangeFuel = -3.121f;
                yValueAscender = -3.056f;
                break;
            }

            terrainInstanceTop = Instantiate(terrainBasicToLoad, startPositionTop, transform.rotation) as GameObject;
            terrainBasicsTop.Add(terrainInstanceTop);

            stayTheSameChanceTop = Random.Range(1, 3);

            if (stayTheSameChanceTop != 1)
            {
                terrainHeightTop = Random.Range(1, 4);
            }

            switch (terrainHeightTop)
            {
            case 1:
                break;

            case 2:
                terrainInstanceTop = Instantiate(terrainBasicToLoad, startPositionTop2, transform.rotation) as GameObject;
                terrainBasicsTop.Add(terrainInstanceTop);
                break;

            case 3:
                terrainInstanceTop = Instantiate(terrainBasicToLoad, startPositionTop2, transform.rotation) as GameObject;
                terrainBasicsTop.Add(terrainInstanceTop);

                terrainInstanceTop = Instantiate(terrainBasicToLoad, startPositionTop3, transform.rotation) as GameObject;
                terrainBasicsTop.Add(terrainInstanceTop);
                break;
            }
            yield return(new WaitForSeconds(0.135f));
        }
    }