public override void FinishLoading()
        {
            base.FinishLoading();
            if (legacyJSON != null)
            {
                foreach (var pair in legacyJSON.LoopObject())
                {
                    try {
                        Players.Player player = Players.GetPlayer(NetworkID.Parse(pair.Key));

                        for (int i = 0; i < pair.Value.ChildCount; i++)
                        {
                            JSONNode jobNode = pair.Value[i];

                            int        npcID = jobNode.GetAsOrDefault("npcID", 0);
                            Vector3Int min   = (Vector3Int)jobNode["positionMin"];
                            Vector3Int max   = (Vector3Int)jobNode["positionMax"];

                            var job = new DefaultFarmerAreaJob <FlaxFarmerDefinition>(player, min, max, npcID);
                            if (!AreaJobTracker.RegisterAreaJob(job))
                            {
                                job.OnRemove();
                            }
                        }
                    } catch (System.Exception e) {
                        Log.WriteException("Exception loading legacy area job data", e);
                    }
                }
                legacyJSON = null;
            }
        }
예제 #2
0
        public virtual void LoadJSON(JSONNode node)
        {
            JSONNode table = node.GetAs <JSONNode>("table");

            foreach (var pair in table.LoopObject())
            {
                Players.Player player = Players.GetPlayer(NetworkID.Parse(pair.Key));
                JSONNode       array  = pair.Value;
                for (int i = 0; i < array.ChildCount; i++)
                {
                    var job = CreateAreaJob(player, array[i]);
                    if (!AreaJobTracker.RegisterAreaJob(job))
                    {
                        job.OnRemove();
                    }
                }
            }
        }