Esempio n. 1
0
        public void SetWallFixtureAtLayer(WallFixture fixture, WallFixtureLayers layer)
        {
            switch (layer)
            {
            case WallFixtureLayers.HighWallNorth:
                wallFixtureDefinition.highWallNorth = (HighWallFixture)fixture;
                wallFixtureDefinition.highWallNorth?.SetOrientation(WallFixture.Orientation.North);
                break;

            case WallFixtureLayers.HighWallEast:
                wallFixtureDefinition.highWallEast = (HighWallFixture)fixture;
                wallFixtureDefinition.highWallEast?.SetOrientation(WallFixture.Orientation.East);
                break;

            case WallFixtureLayers.HighWallSouth:
                wallFixtureDefinition.highWallSouth = (HighWallFixture)fixture;
                wallFixtureDefinition.highWallSouth?.SetOrientation(WallFixture.Orientation.South);
                break;

            case WallFixtureLayers.HighWallWest:
                wallFixtureDefinition.highWallWest = (HighWallFixture)fixture;
                wallFixtureDefinition.highWallWest?.SetOrientation(WallFixture.Orientation.West);
                break;

            case WallFixtureLayers.LowWallNorth:
                wallFixtureDefinition.lowWallNorth = (LowWallFixture)fixture;
                wallFixtureDefinition.lowWallNorth?.SetOrientation(WallFixture.Orientation.North);
                break;

            case WallFixtureLayers.LowWallEast:
                wallFixtureDefinition.lowWallEast = (LowWallFixture)fixture;
                wallFixtureDefinition.lowWallEast?.SetOrientation(WallFixture.Orientation.East);
                break;

            case WallFixtureLayers.LowWallSouth:
                wallFixtureDefinition.lowWallSouth = (LowWallFixture)fixture;
                wallFixtureDefinition.lowWallSouth?.SetOrientation(WallFixture.Orientation.South);
                break;

            case WallFixtureLayers.LowWallWest:
                wallFixtureDefinition.lowWallWest = (LowWallFixture)fixture;
                wallFixtureDefinition.lowWallWest?.SetOrientation(WallFixture.Orientation.West);
                break;
            }
        }
Esempio n. 2
0
        public void SetWallFixtureAtLayer(WallFixture fixture, WallFixtureLayers layer)
        {
            switch (layer)
            {
            case WallFixtureLayers.HighWallNorth:
                wallFixtureDefinition.highWallNorth = (HighWallFixture)fixture;
                break;

            case WallFixtureLayers.HighWallEast:
                wallFixtureDefinition.highWallEast = (HighWallFixture)fixture;
                break;

            case WallFixtureLayers.HighWallSouth:
                wallFixtureDefinition.highWallSouth = (HighWallFixture)fixture;
                break;

            case WallFixtureLayers.HighWallWest:
                wallFixtureDefinition.highWallWest = (HighWallFixture)fixture;
                break;

            case WallFixtureLayers.LowWallNorth:
                wallFixtureDefinition.lowWallNorth = (LowWallFixture)fixture;
                break;

            case WallFixtureLayers.LowWallEast:
                wallFixtureDefinition.lowWallEast = (LowWallFixture)fixture;
                break;

            case WallFixtureLayers.LowWallSouth:
                wallFixtureDefinition.lowWallSouth = (LowWallFixture)fixture;
                break;

            case WallFixtureLayers.LowWallWest:
                wallFixtureDefinition.lowWallWest = (LowWallFixture)fixture;
                break;
            }
        }
Esempio n. 3
0
        public static TileDefinition ReadNetworkableTileDefinition(this NetworkReader reader)
        {
            TileDefinition tileDefinition = new TileDefinition();

            tileDefinition.fixtures = new FixturesContainer();

            // Read plenum
            string plenumName = reader.ReadString();

            if (!string.IsNullOrEmpty(plenumName))
            {
                tileDefinition.plenum = plenums.FirstOrDefault(plenum => plenum.name == plenumName);
                if (tileDefinition.plenum == null)
                {
                    Debug.LogError($"Network recieved plenum with name {plenumName} could not be found");
                }
            }

            // Read turf
            string turfName = reader.ReadString();

            if (!string.IsNullOrEmpty(turfName))
            {
                tileDefinition.turf = turfs.FirstOrDefault(turf => turf.name == turfName);
                if (tileDefinition.turf == null)
                {
                    Debug.LogError($"Network recieved turf with name {turfName} could not be found");
                }
            }

            // Read tile fixtures
            foreach (TileFixtureLayers layer in TileDefinition.GetTileFixtureLayerNames())
            {
                string fixtureName = reader.ReadString();
                if (!string.IsNullOrEmpty(fixtureName))
                {
                    TileFixture tf = (TileFixture)fixtures.FirstOrDefault(fixture => fixture.name == fixtureName);

                    tileDefinition.fixtures.SetTileFixtureAtLayer(tf, layer);
                    if (tf == null)
                    {
                        Debug.LogError($"Network recieved fixture with name {fixtureName} could not be found");
                    }
                }
            }

            // Read wall fixtures
            foreach (WallFixtureLayers layer in TileDefinition.GetWallFixtureLayerNames())
            {
                string fixtureName = reader.ReadString();
                if (!string.IsNullOrEmpty(fixtureName))
                {
                    WallFixture wf = (WallFixture)fixtures.FirstOrDefault(fixture => fixture.name == fixtureName);

                    tileDefinition.fixtures.SetWallFixtureAtLayer(wf, layer);
                    if (wf == null)
                    {
                        Debug.LogError($"Network recieved fixture with name {fixtureName} could not be found");
                    }
                }
            }

            // Read floor fixtures
            foreach (FloorFixtureLayers layer in TileDefinition.GetFloorFixtureLayerNames())
            {
                string fixtureName = reader.ReadString();
                if (!string.IsNullOrEmpty(fixtureName))
                {
                    FloorFixture ff = (FloorFixture)fixtures.FirstOrDefault(fixture => fixture.name == fixtureName);

                    tileDefinition.fixtures.SetFloorFixtureAtLayer(ff, layer);
                    if (ff == null)
                    {
                        Debug.LogError($"Network recieved fixture with name {fixtureName} could not be found");
                    }
                }
            }

            // If the boolean is false, subStates should be null.
            if (reader.ReadBoolean())
            {
                using (var stream = new MemoryStream(reader.ReadBytesAndSize()))
                {
                    tileDefinition.subStates = new BinaryFormatter().Deserialize(stream) as object[];
                }
            }

            // TODO: Should substates be initialized to null array?
            return(tileDefinition);
        }