示例#1
0
        public static TriggerCondition ReadFrom(PrimitiveReader reader)
        {
            TriggerCondition condition = new TriggerCondition();

            condition.Type  = reader.ReadInt32();
            condition.Check = reader.ReadInt32();
            if (condition.Check != 0x10)
            {
                throw new InvalidDataException("Expected 0x10 for check.");
            }

            condition.Amount       = reader.ReadInt32();
            condition.ResourceType = reader.ReadInt32();

            condition.UnitObject   = reader.ReadInt32();
            condition.UnitLocation = reader.ReadInt32();
            condition.UnitType     = reader.ReadInt32();

            condition.Player     = reader.ReadInt32();
            condition.Technology = reader.ReadInt32();
            condition.Timer      = reader.ReadInt32();
            condition.Unknown    = reader.ReadInt32();

            condition.BottomLeft = new Point2I(reader.ReadInt32(), reader.ReadInt32());
            condition.UpperRight = new Point2I(reader.ReadInt32(), reader.ReadInt32());

            condition.UnitGroup     = reader.ReadInt32();
            condition.UnitGroupType = reader.ReadInt32();
            condition.AiSignal      = reader.ReadInt32();
            return(condition);
        }
示例#2
0
        public static Trigger ReadFrom(PrimitiveReader reader)
        {
            Trigger trigger = new Trigger();

            //System.Diagnostics.Debugger.Break();

            trigger.Enabled                    = reader.ReadUInt32() != 0;
            trigger.Looping                    = reader.ReadUInt32() != 0;
            trigger.Unknown1                   = reader.ReadUInt8();
            trigger.DisplayAsObjective         = reader.ReadUInt8() != 0;
            trigger.ObjectivesDescriptionOrder = reader.ReadUInt32();
            trigger.Unknown2                   = reader.ReadUInt32();
            trigger.Description                = Utils.ReadUInt32LengthPrefixedString(reader);
            trigger.Name = Utils.ReadUInt32LengthPrefixedString(reader);

            //System.Diagnostics.Debugger.Break();

            int effectsCount = reader.ReadInt32();

            if (effectsCount < 0)
            {
                effectsCount = 0;
            }
            TriggerEffect[] effects = new TriggerEffect[effectsCount];
            for (int i = 0; i < effects.Length; i++)
            {
                effects[i] = TriggerEffect.ReadFrom(reader);
            }
            for (int i = 0; i < effects.Length; i++)
            {
                effects[i].DisplayOrder = reader.ReadInt32();
            }
            trigger.Effects = effects;

            int conditionsCount = reader.ReadInt32();

            if (conditionsCount < 0)
            {
                conditionsCount = 0;
            }
            TriggerCondition[] conditions = new TriggerCondition[conditionsCount];
            for (int i = 0; i < conditions.Length; i++)
            {
                conditions[i] = TriggerCondition.ReadFrom(reader);
            }
            for (int i = 0; i < conditions.Length; i++)
            {
                conditions[i].DisplayOrder = reader.ReadInt32();
            }
            trigger.Conditions = conditions;
            //System.Diagnostics.Debugger.Break();
            return(trigger);
        }