예제 #1
0
        // OnApplicationQuit gets called too early to shutdown the SteamAPI.
        // Because the SteamManager should be persistent and never disabled or destroyed we can shutdown the SteamAPI here.
        // Thus it is not recommended to perform any Steamworks work in other OnDestroy functions as the order of execution can not be garenteed upon Shutdown. Prefer OnDisable().
        protected virtual void OnDestroy()
        {
            if (s_instance != this)
            {
                return;
            }

            s_instance = null;

            if (!m_bInitialized)
            {
                return;
            }

            shutdownSteamAPI();
        }
예제 #2
0
        public static void load(string modPath)
        {
            foreach (var mod in Directory.EnumerateDirectories(modPath))
            {
                loadMod(mod);
            }
            if (SteamManager.Initialized && World.useWorkshop)
            {
                foreach (var mod in SteamManager.getSubscribedWorkshopItems())
                {
                    World.log("Loading workshop mod from " + mod);
                    loadMod(mod);
                }
            }

            World.log("NarrEvents loaded " + events.Count);
        }
예제 #3
0
        public void update()
        {
            ui.world.audioStore.playClick();

            status.gameObject.SetActive(true);
            status.text = "Loading...";

            bUpdate.gameObject.SetActive(false);
            SteamManager.updateWorkshopItem(data, path, res => {
                if (res)
                {
                    status.text = "Success!";
                }
                else
                {
                    status.text = "Error!";
                }
            });
        }
예제 #4
0
        // This should only ever get called on first load and after an Assembly reload, You should never Disable the Steamworks Manager yourself.
        protected virtual void OnEnable()
        {
            if (s_instance == null)
            {
                s_instance = this;
            }

            if (!m_bInitialized)
            {
                return;
            }

            if (m_SteamAPIWarningMessageHook == null)
            {
                // Set up our callback to receive warning messages from Steam.
                // You must launch with "-debug_steamapi" in the launch args to receive warnings.
                m_SteamAPIWarningMessageHook = new SteamAPIWarningMessageHook_t(SteamAPIDebugTextHook);
                SteamClient.SetWarningMessageHook(m_SteamAPIWarningMessageHook);
            }

            //// Run Steam client callbacks
            SteamAPI.RunCallbacks();
        }
예제 #5
0
        public void populate(ModData d, string p, bool owned)
        {
            data = d;
            path = p;

            title.text       = data.title;
            description.text = data.description;

            if (!owned)
            {
                bPublish.gameObject.SetActive(false);
                bUpdate.gameObject.SetActive(false);
            }
            else if (SteamManager.hasPublishedWorkshopItem(path))
            {
                bPublish.gameObject.SetActive(false);
                bUpdate.gameObject.SetActive(true);
            }
            else
            {
                bPublish.gameObject.SetActive(true);
                bUpdate.gameObject.SetActive(false);
            }
        }
예제 #6
0
        protected virtual void Awake()
        {
            // Only one instance of SteamManager at a time!
            if (s_instance != null)
            {
                Destroy(gameObject);
                return;
            }
            s_instance = this;

            if (s_EverInitialized)
            {
                // This is almost always an error.
                // The most common case where this happens is when SteamManager gets destroyed because of Application.Quit(),
                // and then some Steamworks code in some other OnDestroy gets called afterwards, creating a new SteamManager.
                // You should never call Steamworks functions in OnDestroy, always prefer OnDisable if possible.
                throw new System.Exception("Tried to Initialize the SteamAPI twice in one session!");
            }

            // We want our SteamManager Instance to persist across scenes.
            DontDestroyOnLoad(gameObject);

            if (!Packsize.Test())
            {
                Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);
            }

            if (!DllCheck.Test())
            {
                Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this);
            }

            //Steam API must only run in compiled mode, or it doesn't close properly, causing all manner of issues
            if (Application.isEditor)
            {
                return;
            }

            try
            {
                // If Steam is not running or the game wasn't started through Steam, SteamAPI_RestartAppIfNecessary starts the
                // Steam client and also launches this game again if the User owns it. This can act as a rudimentary form of DRM.

                // Once you get a Steam AppID assigned by Valve, you need to replace AppId_t.Invalid with it and
                // remove steam_appid.txt from the game depot. eg: "(AppId_t)480" or "new AppId_t(480)".
                // See the Valve documentation for more information: https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
                if (SteamAPI.RestartAppIfNecessary(AppId_t.Invalid))
                {
                    Application.Quit();
                    return;
                }
            }
            catch (System.DllNotFoundException e)
            {             // We catch this exception here, as it will be the first occurrence of it.
                Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + e, this);

                Application.Quit();
                return;
            }

            // Initializes the Steamworks API.
            // If this returns false then this indicates one of the following conditions:
            // [*] The Steam client isn't running. A running Steam client is required to provide implementations of the various Steamworks interfaces.
            // [*] The Steam client couldn't determine the App ID of game. If you're running your application from the executable or debugger directly then you must have a [code-inline]steam_appid.txt[/code-inline] in your game directory next to the executable, with your app ID in it and nothing else. Steam will look for this file in the current working directory. If you are running your executable from a different directory you may need to relocate the [code-inline]steam_appid.txt[/code-inline] file.
            // [*] Your application is not running under the same OS user context as the Steam client, such as a different user or administration access level.
            // [*] Ensure that you own a license for the App ID on the currently active Steam account. Your game must show up in your Steam library.
            // [*] Your App ID is not completely set up, i.e. in Release State: Unavailable, or it's missing default packages.
            // Valve's documentation for this is located here:
            // https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
            m_bInitialized = SteamAPI.Init();
            if (!m_bInitialized)
            {
                Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);
                return;
            }

            s_EverInitialized = true;
            World.log("Steamworks Awake method returned successfully");

            hasAchieved = new bool[achievementKeys.Length];
        }
예제 #7
0
 private static void InitOnPlayMode()
 {
     s_EverInitialized = false;
     s_instance        = null;
 }
예제 #8
0
        public void turnTick()
        {
            hasTakenAction = false;
            double powerGainMult = calculatePowerGainMult();
            double powerGain     = map.param.overmind_powerRegen * powerGainMult;

            if (power < map.param.overmind_maxPower - powerGain)
            {
                power += powerGain;
                if (map.burnInComplete)
                {
                    map.hintSystem.popHint(HintSystem.hintType.POWER);
                }
            }
            //power = Math.Min(power, map.param.overmind_maxPower);


            panicFromPowerUse -= map.param.panic_dropPerTurn;
            if (panicFromPowerUse < 0)
            {
                panicFromPowerUse = 0;
            }

            panicFromCluesDiscovered -= map.param.panic_dropPerTurn;
            if (panicFromCluesDiscovered < 0)
            {
                panicFromCluesDiscovered = 0;
            }

            processEnthralled();
            int    count             = 0;
            double sum               = 0;
            int    nHumanSettlements = 0;

            foreach (Location loc in map.locations)
            {
                if (loc.person() != null)
                {
                    sum += loc.person().shadow; count += 1;
                }
                if (loc.soc != null && loc.settlement != null && (loc.settlement is Set_Ruins == false) && (loc.settlement is Set_CityRuins == false) && loc.soc is Society)
                {
                    nHumanSettlements += 1;
                }
            }
            if (count == 0)
            {
                map.data_avrgEnshadowment = 0;
            }
            else
            {
                map.data_avrgEnshadowment = sum / count;
            }
            if ((!endOfGameAchieved) && map.data_avrgEnshadowment > map.param.victory_targetEnshadowmentAvrg)
            {
                victory();
            }
            if (nHumanSettlements == 0)
            {
                victory();
            }
            map.data_nSocietyLocations = nHumanSettlements;

            if (map.automatic)
            {
                autoAI.turnTick();
            }

            if (map.burnInComplete && (map.turn - map.param.mapGen_burnInSteps) % map.param.overmind_enthrallmentUseRegainPeriod == 0)
            {
                if (availableEnthrallments < maxEnthralled)
                {
                    availableEnthrallments += 1;
                }
            }

            if (map.data_globalTempSum <= map.data_globalTempInitial / 2)
            {
                SteamManager.unlockAchievement(SteamManager.achievement_key.WORLD_UNDER_ICE);
            }
            map.data_globalTempSum = 0;
            computeLightbringer();
        }
예제 #9
0
        public static void takeCommand(Map map, string command)
        {
            World.log("cheat command registered: " + command);


            //try
            {
                if (command == "power")
                {
                    map.overmind.power = 1024;
                    map.overmind.availableEnthrallments = 128;
                }
                if (command == "testsave")
                {
                    map.world.save("testSave.sv");
                    //map.world.prefabStore.popAutosave();
                }
                if (command == "testload")
                {
                    //map.world.load("testSave.sv");
                }
                if (command == "silence")
                {
                    World.self.displayMessages = !World.self.displayMessages;
                }
                if (command == "shadow")
                {
                    GraphicalMap.selectedHex.location.person().shadow = 1;
                }
                if (command == "music")
                {
                    map.world.ui.uiMusic.playTest();
                }
                if (command == "aware")
                {
                    GraphicalMap.selectedHex.location.person().awareness = 1;
                }
                if (command == "testproperty")
                {
                    Property.addProperty(map, GraphicalMap.selectedHex.location, "Military Aid");
                    World.staticMap.world.ui.checkData();
                }
                if (command == "playback")
                {
                    World.staticMap.world.ui.addBlocker(World.staticMap.world.prefabStore.getPlayback(World.staticMap.world, World.staticMap).gameObject);
                }
                if (command == "uivoting")
                {
                    World.staticMap.world.ui.uiVoting.populate((Society)GraphicalMap.selectedHex.location.soc, GraphicalMap.selectedHex.location.person());
                    World.staticMap.world.ui.setToVoting();
                }
                if (command == "100")
                {
                    World.staticMap.world.b100Turns();
                }
                if (command == "enthrall")
                {
                    if (GraphicalMap.selectedHex.location.person() == null)
                    {
                        int    c      = 0;
                        Person choice = null;
                        foreach (Person p in ((Society)GraphicalMap.selectedHex.location.soc).people)
                        {
                            if (p.getLocation() == GraphicalMap.selectedHex.location)
                            {
                                c += 1;
                                if (Eleven.random.Next(c) == 0)
                                {
                                    choice = p;
                                }
                            }
                        }
                        choice.state            = Person.personState.enthralled;
                        map.overmind.enthralled = choice;
                    }
                    else
                    {
                        map.overmind.enthralled       = GraphicalMap.selectedHex.location.person();
                        map.overmind.enthralled.state = Person.personState.enthralled;
                    }
                }
                if (command == "love")
                {
                    foreach (Person p in map.overmind.enthralled.society.people)
                    {
                        p.getRelation(map.overmind.enthralled).addLiking(100, "Cheat love", map.turn);
                    }
                }
                if (command == "hate")
                {
                    foreach (Person p in map.overmind.enthralled.society.people)
                    {
                        p.getRelation(map.overmind.enthralled).addLiking(-100, "Cheat hate", map.turn);
                    }
                }
                if (command == "resetSteamAchievements")
                {
                    SteamManager.reset_all_achievements();
                    World.staticMap.world.prefabStore.popMsg("All steam achievements reset");
                }
                if (command == "thetruth")
                {
                    foreach (Unit u in map.units)
                    {
                        if (u is Unit_Seeker seeker)
                        {
                            seeker.knowsTruth = true;
                        }
                    }
                }
                if (command == "insanity")
                {
                    GraphicalMap.selectedHex.location.person().goInsane();
                }
                if (command == "ruin")
                {
                    GraphicalMap.selectedHex.location.settlement.fallIntoRuin();
                }
                if (command == "redDeath")
                {
                    Property.addProperty(GraphicalMap.map, GraphicalMap.selectedHex.location, "Red Death");
                }
                if (command == "rotting" || command == "rotting sickness")
                {
                    Property.addProperty(GraphicalMap.map, GraphicalMap.selectedHex.location, "Rotting Sickness");
                }
                if (command == "fogSource")
                {
                    Property.addProperty(GraphicalMap.map, GraphicalMap.selectedHex.location, "Well of Fog");
                }
                if (command == "hot")
                {
                    for (int i = 0; i < map.tempMap.Length; i++)
                    {
                        for (int j = 0; j < map.tempMap[0].Length; j++)
                        {
                            map.tempMap[i][j] += 0.1f;
                            if (map.tempMap[i][j] > 1)
                            {
                                map.tempMap[i][j] = 1;
                            }
                        }
                    }
                    map.assignTerrainFromClimate();
                    map.world.ui.checkData();
                }
                if (command == "cold")
                {
                    //for (int i = 0; i < map.tempMap.Length; i++)
                    //{
                    //    for (int j = 0; j < map.tempMap[0].Length; j++)
                    //    {
                    //        map.tempMap[i][j] -= 0.1f;
                    //        if (map.tempMap[i][j] < 0) { map.tempMap[i][j] = 0; }
                    //    }
                    //}
                    foreach (Hex[] row in map.grid)
                    {
                        foreach (Hex h in row)
                        {
                            h.transientTempDelta -= 0.1f;
                        }
                    }
                    map.assignTerrainFromClimate();
                    map.world.ui.checkData();
                }
                if (command == "globalcooling")
                {
                    World.cheat_globalCooling = !World.cheat_globalCooling;
                }
                if (command == "min sanity")
                {
                    GraphicalMap.selectedHex.location.person().sanity = 0.01;
                }
                if (command == "die")
                {
                    GraphicalMap.selectedHex.location.person().die("Killed by console", true);
                }
                if (command == "inquisitor")
                {
                    Unit_Investigator inv = (Unit_Investigator)GraphicalMap.selectedSelectable;
                    inv.changeState(Unit_Investigator.unitState.inquisitor);
                }
                if (command == "civilWar")
                {
                    List <Person> rebels = new List <Person>();
                    Society       soc    = (Society)GraphicalMap.selectedHex.location.soc;
                    int           c      = 0;
                    foreach (Person p in soc.people)
                    {
                        if (p.title_land == null)
                        {
                            continue;
                        }
                        if (p.getLocation().province != soc.getCapital().province)
                        {
                            rebels.Add(p);
                        }
                    }
                    soc.triggerCivilWar(rebels);
                }
                if (command == "evidence")
                {
                    GraphicalMap.selectedHex.location.person().evidence = 1;
                }
                if (command == "disrupt")
                {
                    GraphicalMap.selectedHex.location.person().action = new Act_Disrupted();
                }
                if (command == "10 evidence")
                {
                    GraphicalMap.selectedHex.location.person().evidence += 0.1;
                    if (GraphicalMap.selectedHex.location.person().evidence > 1)
                    {
                        GraphicalMap.selectedHex.location.person().evidence = 1;
                    }
                }
                if (command == "refresh")
                {
                    World.staticMap.overmind.hasTakenAction = false;
                }
                if (command == "nextAge")
                {
                    World.staticMap.overmind.progressToNextAge();
                }
                if (command == "unit")
                {
                    Unit u = new Unit_Investigator(GraphicalMap.selectedHex.location, (Society)GraphicalMap.selectedHex.location.soc);
                    map.units.Add(u);
                    GraphicalMap.selectedHex.location.units.Add(u);
                }
                if (command == "victory")
                {
                    World.staticMap.overmind.victory();
                }
                if (command == "defeat")
                {
                    World.staticMap.overmind.defeat();
                }
                if (command == "course")
                {
                    World.staticMap.world.prefabStore.popEndgameCyclic();
                }
                if (command == "worm")
                {
                    SG_WormHive add = new SG_WormHive(map, GraphicalMap.selectedHex.location);
                    map.socialGroups.Add(add);
                }
                if (command == "placeevidence")
                {
                    GraphicalMap.selectedHex.location.evidence.Add(new Evidence(map.turn));
                    World.log("Placing evidence");
                }
                if (command == "vote")
                {
                    Society soc = map.overmind.enthralled.society;
                    if (soc.voteSession != null)
                    {
                        soc.voteSession.assignVoters();
                        World.log("Attempting to build blocker");
                        map.world.ui.addBlocker(map.world.prefabStore.getScrollSet(soc.voteSession, soc.voteSession.issue.options).gameObject);
                    }
                }
                if (command == "infiltrate")
                {
                    GraphicalMap.selectedHex.location.settlement.infiltration = 1;
                    World.log("Infiltrate");
                }
                if (command == "infiltratehalf")
                {
                    GraphicalMap.selectedHex.location.settlement.infiltration = 0.5;
                    World.log("Infiltrate half");
                }
                map.world.ui.checkData();
            }
            //catch(Exception e)
            //{
            //    World.log(e.Message);
            //}
        }