Example #1
0
    public static void ApplyLinedefBehavior()
    {
        Transform holder = new GameObject("DynamicMeshes").transform;

        holder.transform.SetParent(GameManager.Instance.transform);

        int index = -1;

        foreach (Linedef l in linedefs)
        {
            index++;

            if (l.lineType == 0)
            {
                continue;
            }

            switch (l.lineType)
            {
            default:
                Debug.Log("Linedef " + index + " has unknown type (" + l.lineType + ")");
                break;

            //common door
            case 1:
            case 26:     //keycard doors
            case 27:
            case 28:
            {
                if (l.TopFrontObject == null)
                {
                    break;
                }

                if (l.Back == null)
                {
                    break;
                }

                l.Back.Sector.ceilingObject.transform.SetParent(holder);

                Door1Controller lc = l.TopFrontObject.AddComponent <Door1Controller>();

                if (l.lineType == 26)
                {
                    lc.requiresKeycard = 0;
                }
                if (l.lineType == 27)
                {
                    lc.requiresKeycard = 1;
                }
                if (l.lineType == 28)
                {
                    lc.requiresKeycard = 2;
                }

                SlowRepeatableDoorController sc = l.Back.Sector.ceilingObject.GetComponent <SlowRepeatableDoorController>();
                if (sc == null)
                {
                    sc = l.Back.Sector.ceilingObject.AddComponent <SlowRepeatableDoorController>();
                }

                sc.Init(l.Back.Sector);
                lc.sectorController = sc;

                l.Back.Sector.Dynamic = true;
            }
            break;

            //single use door, walk trigger
            case 2:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <SlowOneshotDoorController> linked = new List <SlowOneshotDoorController>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.ceilingObject.transform.SetParent(holder);

                    SlowOneshotDoorController sc = sector.ceilingObject.GetComponent <SlowOneshotDoorController>();
                    if (sc == null)
                    {
                        sc = sector.ceilingObject.gameObject.AddComponent <SlowOneshotDoorController>();
                        sc.Init(sector);
                    }
                    linked.Add(sc);

                    sector.Dynamic = true;
                }

                BoxCollider mc = Mesher.CreateLineTriggerCollider(
                    l,
                    Mathf.Min(l.Front.Sector.minimumFloorHeight, l.Back.Sector.minimumFloorHeight),
                    Mathf.Max(l.Front.Sector.maximumCeilingHeight, l.Back.Sector.maximumCeilingHeight),
                    "Tag_" + l.lineTag + "_trigger",
                    holder
                    );

                if (mc == null)
                {
                    Debug.LogError("Linedef " + index + " could not create trigger. Type(" + l.lineType + ")");
                    break;
                }

                mc.isTrigger = true;

                LineTrigger lt = mc.gameObject.AddComponent <LineTrigger>();
                lt.TriggerAction = (c) =>
                {
                    PlayerThing player = c.GetComponent <PlayerThing>();

                    if (player == null)
                    {
                        return;
                    }

                    foreach (SlowOneshotDoorController lc in linked)
                    {
                        if (lc.CurrentState == SlowOneshotDoorController.State.Closed)
                        {
                            lc.CurrentState = SlowOneshotDoorController.State.Opening;
                        }
                    }
                };
            }
            break;

            //stairbuilder, walktrigger
            case 8:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <StairbuilderSlow> linked = new List <StairbuilderSlow>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.floorObject.transform.SetParent(holder);

                    List <Sector> stairSectors = new List <Sector>();
                    Sector        targetSector = sector;

                    int  count  = 0;
                    bool failed = false;
                    while (!failed)
                    {
                        count++;
                        stairSectors.Add(targetSector);
                        targetSector.Dynamic = true;
                        targetSector.floorObject.transform.SetParent(holder);

                        failed = true;
                        foreach (Sidedef s in targetSector.Sidedefs)
                        {
                            if (s.Line.Back == null)
                            {
                                continue;
                            }

                            if (s.Line.Back.Sector == targetSector)
                            {
                                continue;
                            }

                            if (s.Line.Back.Sector.floorTexture != targetSector.floorTexture)
                            {
                                continue;
                            }

                            if (stairSectors.Contains(s.Line.Back.Sector))
                            {
                                continue;
                            }

                            targetSector = s.Line.Back.Sector;
                            failed       = false;
                        }
                    }

                    StairbuilderSlow sc = sector.floorObject.GetComponent <StairbuilderSlow>();
                    if (sc == null)
                    {
                        sc = sector.floorObject.gameObject.AddComponent <StairbuilderSlow>();
                        sc.Init(stairSectors);
                    }
                    linked.Add(sc);
                }

                BoxCollider mc = Mesher.CreateLineTriggerCollider(
                    l,
                    Mathf.Min(l.Front.Sector.minimumFloorHeight, l.Back.Sector.minimumFloorHeight),
                    Mathf.Max(l.Front.Sector.maximumCeilingHeight, l.Back.Sector.maximumCeilingHeight),
                    "Tag_" + l.lineTag + "_trigger",
                    holder
                    );

                if (mc == null)
                {
                    Debug.LogError("Linedef " + index + " could not create trigger. Type(" + l.lineType + ")");
                    break;
                }

                mc.isTrigger = true;

                LineTrigger lt = mc.gameObject.AddComponent <LineTrigger>();
                lt.TriggerAction = (c) =>
                {
                    PlayerThing player = c.GetComponent <PlayerThing>();

                    if (player == null)
                    {
                        return;
                    }

                    foreach (StairbuilderSlow lc in linked)
                    {
                        if (lc.CurrentState == StairbuilderSlow.State.Waiting)
                        {
                            lc.CurrentState = StairbuilderSlow.State.Active;
                        }
                    }
                };
            }
            break;

            //donut, switch
            case 9:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <Sector> sectors = Sector.TaggedSectors[l.lineTag];
                if (sectors.Count == 0)
                {
                    break;
                }

                sectors[0].floorObject.transform.SetParent(holder);

                Sector ringSector = null;
                foreach (Sidedef s in sectors[0].Sidedefs)
                {
                    if (s.Line.Back == null)
                    {
                        continue;
                    }

                    if (s.Line.Front.Sector == sectors[0])
                    {
                        ringSector = s.Line.Back.Sector;
                        ringSector.floorObject.transform.SetParent(holder);
                        break;
                    }

                    if (s.Line.Back.Sector == sectors[0])
                    {
                        ringSector = s.Line.Front.Sector;
                        ringSector.floorObject.transform.SetParent(holder);
                        break;
                    }
                }

                if (ringSector == null)
                {
                    Debug.LogError("MapLoader: Donut9Controller: No ring sector found!");
                }

                Donut9SectorController sc = sectors[0].floorObject.gameObject.AddComponent <Donut9SectorController>();

                Donut9LinedefController script = null;
                if (l.BotFrontObject != null)
                {
                    script = l.BotFrontObject.AddComponent <Donut9LinedefController>();
                }
                else if (l.MidFrontObject != null)
                {
                    script = l.MidFrontObject.AddComponent <Donut9LinedefController>();
                }

                if (script != null)
                {
                    script.sectorController = sc;
                    sc.Init(sectors[0], ringSector);
                }

                sectors[0].Dynamic = true;
                ringSector.Dynamic = true;
            }
            break;

            //level end switch
            case 11:
            {
                if (l.BotFrontObject != null)
                {
                    End11LinedefController lc = l.BotFrontObject.AddComponent <End11LinedefController>();
                    lc.CurrentTexture = l.Front.tLow;
                    l.BotFrontObject.transform.SetParent(holder);
                }
                else if (l.MidFrontObject != null)
                {
                    End11LinedefController lc = l.MidFrontObject.AddComponent <End11LinedefController>();
                    lc.CurrentTexture = l.Front.tMid;
                    l.MidFrontObject.transform.SetParent(holder);
                }
            }
            break;

            //raise floor to next, one use
            case 20:
            {
                List <Floor20SectorController> linked = new List <Floor20SectorController>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.floorObject.transform.SetParent(holder);

                    Floor20SectorController sc = sector.floorObject.GetComponent <Floor20SectorController>();
                    if (sc == null)
                    {
                        sc = sector.floorObject.gameObject.AddComponent <Floor20SectorController>();
                        sc.Init(sector);
                    }

                    linked.Add(sc);

                    sector.Dynamic = true;
                }

                if (l.BotFrontObject != null)
                {
                    if (index == 1020)
                    {
                        l.BotFrontObject.transform.SetParent(GameManager.Instance.TemporaryObjectsHolder);
                    }

                    Floor20LinedefController lc = l.BotFrontObject.AddComponent <Floor20LinedefController>();
                    lc.sectorControllers = linked;
                    lc.CurrentTexture    = l.Front.tLow;
                    l.BotFrontObject.transform.SetParent(holder);
                }
                else if (l.MidFrontObject != null)
                {
                    Floor20LinedefController lc = l.MidFrontObject.AddComponent <Floor20LinedefController>();
                    lc.sectorControllers = linked;
                    lc.CurrentTexture    = l.Front.tMid;
                    l.MidFrontObject.transform.SetParent(holder);
                }
            }
            break;

            //single use door, pokeable
            case 31:
            {
                if (l.TopFrontObject == null)
                {
                    break;
                }

                if (l.Back == null)
                {
                    break;
                }

                l.Back.Sector.ceilingObject.transform.SetParent(holder);

                Door31Controller          lc = l.TopFrontObject.AddComponent <Door31Controller>();
                SlowOneshotDoorController sc = l.Back.Sector.ceilingObject.GetComponent <SlowOneshotDoorController>();
                if (sc == null)
                {
                    sc = l.Back.Sector.ceilingObject.AddComponent <SlowOneshotDoorController>();
                }

                sc.Init(l.Back.Sector);
                lc.sectorController = sc;

                l.Back.Sector.Dynamic = true;
            }
            break;

            //make sectors dark, walktrigger
            case 35:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                BoxCollider mc = Mesher.CreateLineTriggerCollider(
                    l,
                    Mathf.Min(l.Front.Sector.minimumFloorHeight, l.Back.Sector.minimumFloorHeight),
                    Mathf.Max(l.Front.Sector.maximumCeilingHeight, l.Back.Sector.maximumCeilingHeight),
                    "Tag_" + l.lineTag + "_trigger",
                    holder
                    );

                if (mc == null)
                {
                    Debug.LogError("Linedef " + index + " could not create trigger. Type(" + l.lineType + ")");
                    break;
                }

                mc.isTrigger = true;

                LineTrigger lt = mc.gameObject.AddComponent <LineTrigger>();
                lt.TriggerAction = (c) =>
                {
                    if (c.GetComponent <PlayerThing>() == null)
                    {
                        return;
                    }

                    foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                    {
                        sector.brightness = (float)35 / 255f;
                        sector.floorObject.ChangeBrightness(sector.brightness);
                    }
                };
            }
            break;

            //single use floor lower, walktrigger
            case 36:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <Floor36Controller> linked = new List <Floor36Controller>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.floorObject.transform.SetParent(holder);

                    Floor36Controller sc = sector.floorObject.GetComponent <Floor36Controller>();
                    if (sc == null)
                    {
                        sc = sector.floorObject.gameObject.AddComponent <Floor36Controller>();
                        sc.Init(sector);
                    }
                    linked.Add(sc);

                    sector.Dynamic = true;
                }

                BoxCollider mc = Mesher.CreateLineTriggerCollider(
                    l,
                    Mathf.Min(l.Front.Sector.minimumFloorHeight, l.Back.Sector.minimumFloorHeight),
                    Mathf.Max(l.Front.Sector.maximumCeilingHeight, l.Back.Sector.maximumCeilingHeight),
                    "Tag_" + l.lineTag + "_trigger",
                    holder
                    );

                if (mc == null)
                {
                    Debug.LogError("Linedef " + index + " could not create trigger. Type(" + l.lineType + ")");
                    break;
                }

                mc.isTrigger = true;

                LineTrigger lt = mc.gameObject.AddComponent <LineTrigger>();
                lt.TriggerAction = (c) =>
                {
                    PlayerThing player = c.GetComponent <PlayerThing>();

                    if (player == null)
                    {
                        return;
                    }

                    foreach (Floor36Controller lc in linked)
                    {
                        if (lc.CurrentState == Floor36Controller.State.AtTop)
                        {
                            lc.CurrentState = Floor36Controller.State.Lowering;
                        }
                    }
                };
            }
            break;

            //single use door, shootable
            case 46:
            {
                if (l.TopFrontObject == null)
                {
                    break;
                }

                if (l.Back == null)
                {
                    break;
                }

                l.Back.Sector.ceilingObject.transform.SetParent(GameManager.Instance.transform);

                Door46Controller          lc = l.TopFrontObject.AddComponent <Door46Controller>();
                SlowOneshotDoorController sc = l.Back.Sector.ceilingObject.GetComponent <SlowOneshotDoorController>();
                if (sc == null)
                {
                    sc = l.Back.Sector.ceilingObject.AddComponent <SlowOneshotDoorController>();
                }

                sc.Init(l.Back.Sector);
                lc.sectorController = sc;

                l.Back.Sector.Dynamic = true;
            }
            break;

            //scroll animation, left
            case 48:
            {
                foreach (GameObject g in l.gameObjects)
                {
                    if (g != null)
                    {
                        g.AddComponent <ScrollLeftAnimation>();
                    }
                }
            }
            break;

            //secret level end switch
            case 51:
            {
                if (l.BotFrontObject != null)
                {
                    End51LinedefController lc = l.BotFrontObject.AddComponent <End51LinedefController>();
                    lc.CurrentTexture = l.Front.tLow;
                    l.BotFrontObject.transform.SetParent(holder);
                }
                else if (l.MidFrontObject != null)
                {
                    End51LinedefController lc = l.MidFrontObject.AddComponent <End51LinedefController>();
                    lc.CurrentTexture = l.Front.tMid;
                    l.MidFrontObject.transform.SetParent(holder);
                }
            }
            break;

            //common lift, pokeable
            case 62:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                if (l.BotFrontObject == null)
                {
                    break;
                }

                List <Slow3sLiftController> linked = new List <Slow3sLiftController>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.floorObject.transform.SetParent(holder);

                    Slow3sLiftController script = sector.floorObject.GetComponent <Slow3sLiftController>();
                    if (script == null)
                    {
                        script = sector.floorObject.gameObject.AddComponent <Slow3sLiftController>();
                        script.Init(sector);
                    }

                    linked.Add(script);

                    sector.Dynamic = true;
                }

                Lift62Controller lc = l.BotFrontObject.AddComponent <Lift62Controller>();
                lc.liftControllers = linked;
            }
            break;

            //repeatable door, switch
            case 63:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <SlowRepeatableDoorController> linked = new List <SlowRepeatableDoorController>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.ceilingObject.transform.SetParent(holder);

                    SlowRepeatableDoorController sc = sector.ceilingObject.GetComponent <SlowRepeatableDoorController>();
                    if (sc == null)
                    {
                        sc = sector.ceilingObject.AddComponent <SlowRepeatableDoorController>();
                        sc.Init(sector);
                    }

                    linked.Add(sc);

                    sector.Dynamic = true;
                }

                if (l.BotFrontObject != null)
                {
                    Door63Controller lc = l.BotFrontObject.AddComponent <Door63Controller>();
                    lc.sectorControllers = linked;
                    lc.CurrentTexture    = l.Front.tLow;
                    l.BotFrontObject.transform.SetParent(holder);
                }
                else if (l.MidFrontObject != null)
                {
                    Door63Controller lc = l.MidFrontObject.AddComponent <Door63Controller>();
                    lc.sectorControllers = linked;
                    lc.CurrentTexture    = l.Front.tMid;
                    l.MidFrontObject.transform.SetParent(holder);
                }
            }
            break;

            //common lift, walktrigger
            case 88:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <Slow3sLiftController> linked = new List <Slow3sLiftController>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.floorObject.transform.SetParent(holder);

                    Slow3sLiftController sc = sector.floorObject.GetComponent <Slow3sLiftController>();
                    if (sc == null)
                    {
                        sc = sector.floorObject.gameObject.AddComponent <Slow3sLiftController>();
                        sc.Init(sector);
                    }

                    linked.Add(sc);

                    sector.Dynamic = true;
                }

                BoxCollider mc = Mesher.CreateLineTriggerCollider(
                    l,
                    Mathf.Min(l.Front.Sector.minimumFloorHeight, l.Back.Sector.minimumFloorHeight),
                    Mathf.Max(l.Front.Sector.maximumCeilingHeight, l.Back.Sector.maximumCeilingHeight),
                    "Tag_" + l.lineTag + "_trigger",
                    holder
                    );

                if (mc == null)
                {
                    Debug.LogError("Linedef " + index + " could not create trigger. Type(" + l.lineType + ")");
                    break;
                }

                mc.isTrigger = true;

                LineTrigger lt = mc.gameObject.AddComponent <LineTrigger>();
                lt.TriggerAction = (c) =>
                {
                    foreach (Slow3sLiftController lc in linked)
                    {
                        if (lc.CurrentState == Slow3sLiftController.State.AtTop)
                        {
                            lc.CurrentState = Slow3sLiftController.State.Lowering;
                        }
                    }
                };
            }
            break;

            //repeatable door, walktrigger
            case 90:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <SlowRepeatableDoorController> linked = new List <SlowRepeatableDoorController>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.ceilingObject.transform.SetParent(holder);

                    SlowRepeatableDoorController sc = sector.ceilingObject.GetComponent <SlowRepeatableDoorController>();
                    if (sc == null)
                    {
                        sc = sector.ceilingObject.gameObject.AddComponent <SlowRepeatableDoorController>();
                        sc.Init(sector);
                    }
                    linked.Add(sc);

                    sector.Dynamic = true;
                }

                BoxCollider mc = Mesher.CreateLineTriggerCollider(
                    l,
                    Mathf.Min(l.Front.Sector.minimumFloorHeight, l.Back.Sector.minimumFloorHeight),
                    Mathf.Max(l.Front.Sector.maximumCeilingHeight, l.Back.Sector.maximumCeilingHeight),
                    "Tag_" + l.lineTag + "_trigger",
                    holder
                    );

                if (mc == null)
                {
                    Debug.LogError("Linedef " + index + " could not create trigger. Type(" + l.lineType + ")");
                    break;
                }

                mc.isTrigger = true;

                LineTrigger lt = mc.gameObject.AddComponent <LineTrigger>();
                lt.TriggerAction = (c) =>
                {
                    PlayerThing player = c.GetComponent <PlayerThing>();

                    if (player == null)
                    {
                        return;
                    }

                    foreach (SlowRepeatableDoorController lc in linked)
                    {
                        if (lc.CurrentState == SlowRepeatableDoorController.State.Closed)
                        {
                            lc.CurrentState = SlowRepeatableDoorController.State.Opening;
                        }
                    }
                };
            }
            break;

            //single use door, switch
            case 103:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <SlowOneshotDoorController> linked = new List <SlowOneshotDoorController>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.ceilingObject.transform.SetParent(holder);

                    SlowOneshotDoorController sc = sector.ceilingObject.GetComponent <SlowOneshotDoorController>();
                    if (sc == null)
                    {
                        sc = sector.ceilingObject.AddComponent <SlowOneshotDoorController>();
                        sc.Init(sector);
                    }

                    linked.Add(sc);

                    sector.Dynamic = true;
                }

                if (l.BotFrontObject != null)
                {
                    Door103Controller lc = l.BotFrontObject.AddComponent <Door103Controller>();
                    lc.sectorControllers = linked;
                    lc.CurrentTexture    = l.Front.tLow;
                    l.BotFrontObject.transform.SetParent(holder);
                }
                else if (l.MidFrontObject != null)
                {
                    Door103Controller lc = l.MidFrontObject.AddComponent <Door103Controller>();
                    lc.sectorControllers = linked;
                    lc.CurrentTexture    = l.Front.tMid;
                    l.MidFrontObject.transform.SetParent(holder);
                }
            }
            break;
            }
        }
    }
Example #2
0
    public void ApplyLinedefBehavior()
    {
        Transform holder = new GameObject("DynamicMeshes").transform;

        holder.transform.SetParent(transform);

        foreach (Linedef l in linedefs)
        {
            if (l.lineType == 0)
            {
                continue;
            }

            switch (l.lineType)
            {
            default:
                break;

            case 1:
            case 26:     //keycard doors
            case 27:
            case 28:
            {
                if (l.TopFrontObject == null)
                {
                    break;
                }

                l.Back.Sector.ceilingObject.transform.SetParent(holder);
                Door1LinedefController script = l.TopFrontObject.AddComponent <Door1LinedefController>();
                script.Init(l);
            }
            break;

            case 36:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <Floor36Controller> linked = new List <Floor36Controller>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    sector.floorObject.transform.SetParent(holder);

                    Floor36Controller script = sector.floorObject.GetComponent <Floor36Controller>();
                    if (script == null)
                    {
                        script = sector.floorObject.AddComponent <Floor36Controller>();
                        script.Init(sector);
                    }
                    linked.Add(script);
                }

                BoxCollider mc = Mesher.Instance.CreateLineCollider(
                    l,
                    Mathf.Max(l.Front.Sector.floorHeight, l.Back.Sector.floorHeight),
                    Mathf.Min(l.Front.Sector.ceilingHeight, l.Back.Sector.ceilingHeight),
                    "Tag_" + l.lineTag + "_trigger",
                    holder
                    );

                if (mc == null)
                {
                    break;
                }

                mc.isTrigger = true;
                LineTrigger lt = mc.gameObject.AddComponent <LineTrigger>();
                lt.TriggerAction = (c) =>
                {
                    if (c.gameObject != WadLoader.Instance.PlayerObject)
                    {
                        return;
                    }

                    foreach (Floor36Controller lc in linked)
                    {
                        if (lc.CurrentState == Floor36Controller.State.AtTop)
                        {
                            lc.CurrentState = Floor36Controller.State.Lowering;
                        }
                    }
                };
            }
            break;

            case 48:
            {
                foreach (GameObject g in l.gameObjects)
                {
                    if (g != null)
                    {
                        g.AddComponent <ScrollLeftAnimation>();
                    }
                }
            }
            break;

            case 88:
            {
                if (!Sector.TaggedSectors.ContainsKey(l.lineTag))
                {
                    break;
                }

                List <Platform88Controller> linked = new List <Platform88Controller>();
                foreach (Sector sector in Sector.TaggedSectors[l.lineTag])
                {
                    // hacky handling for a scene reload - I don't actually understand why we're getting here *after* we've cleared the linedefs it's looping through
                    if (sector.floorObject == null)
                    {
                        return;
                    }

                    sector.floorObject.transform.SetParent(holder);

                    Platform88Controller script = sector.floorObject.GetComponent <Platform88Controller>();
                    if (script == null)
                    {
                        script = sector.floorObject.AddComponent <Platform88Controller>();
                        script.Init(sector);
                    }

                    linked.Add(script);
                }

                BoxCollider mc = Mesher.Instance.CreateLineCollider(
                    l,
                    Mathf.Max(l.Front.Sector.floorHeight, l.Back.Sector.floorHeight),
                    Mathf.Min(l.Front.Sector.ceilingHeight, l.Back.Sector.ceilingHeight),
                    "Tag_" + l.lineTag + "_trigger",
                    holder
                    );

                if (mc == null)
                {
                    break;
                }

                mc.isTrigger = true;
                LineTrigger lt = mc.gameObject.AddComponent <LineTrigger>();
                lt.TriggerAction = (c) =>
                {
                    if (c.gameObject != WadLoader.Instance.PlayerObject)
                    {
                        return;
                    }

                    foreach (Platform88Controller lc in linked)
                    {
                        if (lc.CurrentState == Platform88Controller.State.AtTop)
                        {
                            lc.CurrentState = Platform88Controller.State.Lowering;
                            lc.waitTime     = 4f;
                        }
                    }
                };
            }
            break;
            }
        }
    }