示例#1
0
        static IEnumerable <ObjectGroup> BuildTriggers(
            MapData2D map,
            TilemapProperties properties,
            EventFormatter eventFormatter,
            ref int nextObjectGroupId,
            ref int nextObjectId)
        {
            var objectGroups = new List <ObjectGroup>();

            var regions = TriggerZoneBuilder.BuildZones(map);
            var groupedByTriggerType = regions
                                       .Where(x => x.Item1.Chain != null)
                                       .GroupBy(x => x.Item1.Trigger)
                                       .OrderBy(x => x.Key);

            foreach (var triggerType in groupedByTriggerType)
            {
                objectGroups.Add(BuildTriggerObjectGroup(
                                     nextObjectGroupId++,
                                     $"T:{triggerType.Key}",
                                     triggerType,
                                     properties,
                                     eventFormatter,
                                     ref nextObjectId));
            }

            return(objectGroups);
        }
示例#2
0
    public static IEnumerable <ObjectGroup> BuildTriggers(
        BaseMapData map,
        int tileWidth,
        int tileHeight,
        Dictionary <ushort, string> functionsByEventId,
        ref int nextObjectGroupId,
        ref int nextObjectId)
    {
        var objectGroups = new List <ObjectGroup>();
        var regions      = TriggerZoneBuilder.BuildZones(map);

        if (map.GlobalZones.Count > 0)
        {
            var globalRegions = new List <(ZoneKey, Geometry.Polygon)>();
            for (var index = 0; index < map.GlobalZones.Count; index++)
            {
                var global = map.GlobalZones[index];
                var(x, y) = DiagonalLayout.GetPositionForIndex(index);
                var polygon = new Geometry.Polygon
                {
                    OffsetX = -x - 1,
                    OffsetY = -y - 1,
                    Points  = new List <(int, int)> {
                        (0, 0), (1, 0), (1, 1), (0, 1)
                    }
                };
                globalRegions.Add((new ZoneKey(global), polygon));
            }

            objectGroups.Add(BuildTriggerObjectGroup(
                                 nextObjectGroupId++,
                                 "T:Global",
                                 globalRegions,
                                 tileWidth,
                                 tileHeight,
                                 functionsByEventId,
                                 ref nextObjectId));
        }

        var groupedByTriggerType = regions
                                   .Where(x => !x.Item1.Global)
                                   .GroupBy(x => x.Item1.Trigger)
                                   .OrderBy(x => x.Key);

        foreach (var polygonsForTriggerType in groupedByTriggerType)
        {
            objectGroups.Add(BuildTriggerObjectGroup(
                                 nextObjectGroupId++,
                                 $"T:{polygonsForTriggerType.Key}",
                                 polygonsForTriggerType,
                                 tileWidth,
                                 tileHeight,
                                 functionsByEventId,
                                 ref nextObjectId));

            if (polygonsForTriggerType.Key == TriggerTypes.Examine)
            {
                objectGroups[^ 1].Hidden = true;