예제 #1
0
        private void OnServerInitialized()
        {
            LoadConfig();
            var customMessages = (Dictionary <string, object>)Config["messages"];

            if (customMessages != null)
            {
                foreach (var pair in customMessages)
                {
                    messages[pair.Key] = Convert.ToString(pair.Value);
                }
                Log("Loaded " + customMessages.Count + " translation strings");
            }

            // Initialize helpers
            BuildingBlockHelpers.Initialize();

            // Force an update on all blocks when first started
            var  fs         = Interface.GetMod().DataFileSystem;
            var  data       = fs.GetDatafile("BetterStability");
            bool firstStart = false;

            if (data["firststart"] == null)
            {
                Log("Starting the first time, forcing update on ALL blocks");
                firstStart         = true;
                data["firststart"] = false;
                fs.SaveDatafile("BetterStability");
            }

            // Schedule stability updates for all blocks that support anything
            var allBlocks = UnityEngine.Object.FindObjectsOfType <BuildingBlock>();
            int n         = 0;

            foreach (var block in allBlocks)
            {
                if (firstStart || (!BuildingBlockHelpers.IsFoundation(block) && BuildingBlockHelpers.IsSupportForAnything(block)))
                {
                    EnqueueUpdate(block);
                    ++n;
                }
            }
            Log("Queued " + n + " blocks for stability updates");
        }