public override void SaveToSnapshot(LogicJSONObject jsonObject, int layoutId)
        {
            if (this.m_upgLevel != 0 || this.m_constructionTimer == null || this.m_upgrading)
            {
                jsonObject.Put("lvl", new LogicJSONNumber(this.m_upgLevel));
            }
            else
            {
                jsonObject.Put("lvl", new LogicJSONNumber(-1));
            }

            if (this.m_constructionTimer != null)
            {
                jsonObject.Put("const_t", new LogicJSONNumber(this.m_constructionTimer.GetRemainingSeconds(this.m_level.GetLogicTime())));
            }

            LogicTrapData data = this.GetTrapData();

            if (data.HasAlternativeMode() || data.GetSpawnedCharAir() != null && data.GetSpawnedCharGround() != null)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        jsonObject.Put(layoutComponent.GetLayoutVariableNameAirMode(i, false), new LogicJSONBoolean(this.m_useAirMode[i]));
                    }
                }
            }

            if (data.GetDirectionCount() > 0)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        jsonObject.Put(layoutComponent.GetLayoutVariableNameTrapDirection(i, false), new LogicJSONNumber(this.m_direction[i]));
                    }
                }
            }

            base.SaveToSnapshot(jsonObject, layoutId);
        }
        public override void LoadFromSnapshot(LogicJSONObject jsonObject)
        {
            if (this.m_data.GetVillageType() == 1)
            {
                this.Load(jsonObject);
                return;
            }

            LogicTrapData data = this.GetTrapData();

            this.LoadUpgradeLevel(jsonObject);
            this.m_level.GetWorkerManagerAt(this.m_villageType).DeallocateWorker(this);

            if (this.m_constructionTimer != null)
            {
                this.m_constructionTimer.Destruct();
                this.m_constructionTimer = null;
            }

            if (data.HasAlternativeMode() || data.GetSpawnedCharAir() != null && data.GetSpawnedCharGround() != null)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        LogicJSONBoolean airModeObject = jsonObject.GetJSONBoolean(layoutComponent.GetLayoutVariableNameAirMode(i, false));

                        if (airModeObject != null)
                        {
                            this.m_useAirMode[i] = airModeObject.IsTrue();
                        }
                    }
                }

                LogicTriggerComponent triggerComponent = this.GetTriggerComponent();

                bool airMode = this.m_useAirMode[this.m_level.GetWarLayout()];

                triggerComponent.SetAirTrigger(airMode);
                triggerComponent.SetGroundTrigger(!airMode);
            }

            if (data.GetDirectionCount() > 0)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        LogicJSONNumber trapDistanceObject = jsonObject.GetJSONNumber(layoutComponent.GetLayoutVariableNameTrapDirection(i, false));

                        if (trapDistanceObject != null)
                        {
                            this.m_direction[i] = trapDistanceObject.GetIntValue();
                        }
                    }
                }
            }

            this.m_level.GetWorkerManagerAt(this.m_data.GetVillageType()).DeallocateWorker(this);

            if (this.m_constructionTimer != null)
            {
                this.m_constructionTimer.Destruct();
                this.m_constructionTimer = null;
            }

            this.SetUpgradeLevel(this.m_upgLevel);
            base.LoadFromSnapshot(jsonObject);
        }
        public override void Load(LogicJSONObject jsonObject)
        {
            this.LoadUpgradeLevel(jsonObject);

            LogicTrapData data = this.GetTrapData();

            if (data.HasAlternativeMode() || data.GetSpawnedCharAir() != null && data.GetSpawnedCharGround() != null)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        LogicJSONBoolean airModeObject = jsonObject.GetJSONBoolean(layoutComponent.GetLayoutVariableNameAirMode(i, false));

                        if (airModeObject != null)
                        {
                            this.m_useAirMode[i] = airModeObject.IsTrue();
                        }

                        LogicJSONBoolean draftAirModeObject = jsonObject.GetJSONBoolean(layoutComponent.GetLayoutVariableNameAirMode(i, true));

                        if (draftAirModeObject != null)
                        {
                            this.m_draftUseAirMode[i] = draftAirModeObject.IsTrue();
                        }
                    }
                }

                LogicTriggerComponent triggerComponent = this.GetTriggerComponent();

                int  layoutId = this.m_level.GetCurrentLayout();
                bool airMode  = this.m_useAirMode[layoutId];

                triggerComponent.SetAirTrigger(airMode);
                triggerComponent.SetGroundTrigger(!airMode);
            }

            if (data.GetDirectionCount() > 0)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        LogicJSONNumber trapDistanceObject = jsonObject.GetJSONNumber(layoutComponent.GetLayoutVariableNameTrapDirection(i, false));

                        if (trapDistanceObject != null)
                        {
                            this.m_direction[i] = trapDistanceObject.GetIntValue();
                        }

                        LogicJSONNumber draftTrapDistanceObject = jsonObject.GetJSONNumber(layoutComponent.GetLayoutVariableNameTrapDirection(i, true));

                        if (draftTrapDistanceObject != null)
                        {
                            this.m_draftDirection[i] = draftTrapDistanceObject.GetIntValue();
                        }
                    }
                }
            }

            this.m_level.GetWorkerManagerAt(this.m_villageType).DeallocateWorker(this);

            if (this.m_constructionTimer != null)
            {
                this.m_constructionTimer.Destruct();
                this.m_constructionTimer = null;
            }

            LogicJSONNumber constTimeObject = jsonObject.GetJSONNumber("const_t");

            if (constTimeObject != null)
            {
                int constTime = constTimeObject.GetIntValue();

                if (!LogicDataTables.GetGlobals().ClampBuildingTimes())
                {
                    if (this.m_upgLevel < data.GetUpgradeLevelCount() - 1)
                    {
                        constTime = LogicMath.Min(constTime, data.GetBuildTime(this.m_upgLevel + 1));
                    }
                }

                this.m_constructionTimer = new LogicTimer();
                this.m_constructionTimer.StartTimer(constTime, this.m_level.GetLogicTime(), false, -1);

                LogicJSONNumber constTimeEndObject = jsonObject.GetJSONNumber("const_t_end");

                if (constTimeEndObject != null)
                {
                    this.m_constructionTimer.SetEndTimestamp(constTimeEndObject.GetIntValue());
                }

                LogicJSONNumber conffObject = jsonObject.GetJSONNumber("con_ff");

                if (conffObject != null)
                {
                    this.m_constructionTimer.SetFastForward(conffObject.GetIntValue());
                }

                this.m_level.GetWorkerManagerAt(this.m_villageType).AllocateWorker(this);
                this.m_upgrading = this.m_upgLevel != -1;
            }

            LogicJSONBoolean disarmed = jsonObject.GetJSONBoolean("needs_repair");

            if (disarmed != null)
            {
                this.m_disarmed = disarmed.IsTrue();
            }

            this.SetUpgradeLevel(this.m_upgLevel);
            base.Load(jsonObject);
        }
        public override void Save(LogicJSONObject jsonObject, int villageType)
        {
            if (this.m_upgLevel != 0 || this.m_constructionTimer == null || this.m_upgrading)
            {
                jsonObject.Put("lvl", new LogicJSONNumber(this.m_upgLevel));
            }
            else
            {
                jsonObject.Put("lvl", new LogicJSONNumber(-1));
            }

            if (this.m_constructionTimer != null)
            {
                jsonObject.Put("const_t", new LogicJSONNumber(this.m_constructionTimer.GetRemainingSeconds(this.m_level.GetLogicTime())));

                if (this.m_constructionTimer.GetEndTimestamp() != -1)
                {
                    jsonObject.Put("const_t_end", new LogicJSONNumber(this.m_constructionTimer.GetEndTimestamp()));
                }

                if (this.m_constructionTimer.GetFastForward() != -1)
                {
                    jsonObject.Put("con_ff", new LogicJSONNumber(this.m_constructionTimer.GetFastForward()));
                }
            }

            if (this.m_disarmed && this.GetTrapData().GetVillageType() != 1)
            {
                jsonObject.Put("needs_repair", new LogicJSONBoolean(true));
            }

            LogicTrapData data = this.GetTrapData();

            if (data.HasAlternativeMode() || data.GetSpawnedCharAir() != null && data.GetSpawnedCharGround() != null)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        jsonObject.Put(layoutComponent.GetLayoutVariableNameAirMode(i, false), new LogicJSONBoolean(this.m_useAirMode[i]));
                        jsonObject.Put(layoutComponent.GetLayoutVariableNameAirMode(i, true), new LogicJSONBoolean(this.m_draftUseAirMode[i]));
                    }
                }
            }

            if (data.GetDirectionCount() > 0)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        jsonObject.Put(layoutComponent.GetLayoutVariableNameTrapDirection(i, false), new LogicJSONNumber(this.m_direction[i]));
                        jsonObject.Put(layoutComponent.GetLayoutVariableNameTrapDirection(i, true), new LogicJSONNumber(this.m_draftDirection[i]));
                    }
                }
            }

            base.Save(jsonObject, villageType);
        }