Ejemplo n.º 1
0
        /// <summary>
        /// Automatically called for each technite state chunk received from the server.
        /// </summary>
        /// <param name="state"></param>
        public static void CreateOrUpdate(Interface.Struct.TechniteState state)
        {
            Grid.CellID loc = new CompressedLocation(state.location).CellID;

            Grid.Content cellContent = Grid.World.CellStacks[loc.StackID].volumeCell[loc.Layer].content;

            Technite tech;

            if (map.TryGetValue(loc, out tech))
            {
                if (tech.state.TTL < new CompressedState(state.state).GetTTL())
                {
                    tech.transitionState = TransitionState.RemoveFromMap;
                    map.Remove(loc);
                }
                else
                {
                    tech.ImportState(state);
                    all.Add(tech);

                    if (cellContent != Grid.Content.Technite)
                    {
                        Out.Log(Significance.Unusual, "Expected technite content in cell, but found " + cellContent + " (reused state is " + tech + ")");
                    }


                    return;
                }
            }
            tech = createNew(loc);
            //new Technite(loc);
            tech.ImportState(state);
            map.Add(loc, tech);
            all.Add(tech);
            if (++createdThisRound <= MaxLogPerRound)
            {
                Out.Log(Significance.Low, tech + " created");
            }

            if (cellContent != Grid.Content.Technite)
            {
                Out.Log(Significance.Unusual, "Expected technite content in cell, but found " + cellContent + " (new state is " + tech + ")");
            }
        }
Ejemplo n.º 2
0
        private void                            ImportState(Interface.Struct.TechniteState state)
        {
            taskParameter   = 0;
            lastResources   = resources;
            resources       = state.resources;
            taskResult      = (TaskResult)state.taskResult;
            this.state      = new CompressedState(state.state).Decoded;
            transitionState = TransitionState.Preserved;

            if (taskResult == Technite.TaskResult.OperationWindowMissed)
            {
                if (++windowMissedThisRound < MaxLogPerRound)
                {
                    Out.Log(Significance.Unusual, "Operation Window Missed on " + nextTask + " of " + this);
                }
            }


            if (taskResult != TaskResult.MoreWorkNeeded)
            {
                nextTask = Task.None;
            }
        }