Beispiel #1
0
    private void Awake()
    {
        initialOffset     = Vector3Int.CeilToInt(gameObject.transform.position);
        reactionManager   = GetComponent <ReactionManager>();
        metaDataLayer     = GetComponent <MetaDataLayer>();
        MatrixMove        = GetComponentInParent <MatrixMove>();
        tileChangeManager = GetComponentInParent <TileChangeManager>();
        underFloorLayer   = GetComponentInChildren <UnderFloorLayer>();

        OnEarthquake.AddListener((worldPos, magnitude) =>
        {
            var cellPos = metaTileMap.WorldToCell(worldPos);

            var bounds =
                new BoundsInt(cellPos - new Vector3Int(magnitude, magnitude, 0), new Vector3Int(magnitude * 2, magnitude * 2, 1));

            foreach (var pos in bounds.allPositionsWithin)
            {
                foreach (var player in Get <PlayerScript>(pos, true))
                {
                    if (player.IsGhost)
                    {
                        continue;
                    }
                    player.registerTile.ServerSlip(true);
                }
                //maybe shake items somehow, too
            }
        });
    }
Beispiel #2
0
    public void AddElectricalNode(Vector3Int position, ElectricalCableTile electricalCableTile, bool AddTile = false)
    {
        var checkPos = position;

        checkPos.z = 0;
        var metaData = metaDataLayer.Get(checkPos, true);
        var newdata  = new ElectricalMetaData();

        newdata.Initialise(electricalCableTile, metaData, position, this);
        metaData.ElectricalData.Add(newdata);
        if (AddTile)
        {
            if (electricalCableTile != null)
            {
                if (UnderFloorLayer == null)
                {
                    underFloorLayer = GetComponentInChildren <UnderFloorLayer>();
                }
                if (UnderFloorLayer != null)
                {
                    UnderFloorLayer.SetTile(position, electricalCableTile, Matrix4x4.identity);
                }
            }
        }
    }
Beispiel #3
0
 public void RemoveUnderFloorTile(Vector3Int position, LayerTile tile)
 {
     if (UnderFloorLayer == null)
     {
         underFloorLayer = GetComponentInChildren <UnderFloorLayer>();
     }
     UnderFloorLayer.RemoveSpecifiedTile(position, tile);
 }
Beispiel #4
0
    public void AddUnderFloorTile(Vector3Int position, LayerTile tile, Matrix4x4 transformMatrix, Color color)
    {
        if (UnderFloorLayer == null)
        {
            underFloorLayer = GetComponentInChildren <UnderFloorLayer>();
        }

        UnderFloorLayer.SetTile(position, tile, transformMatrix, color);
    }
Beispiel #5
0
    private void Awake()
    {
        metaTileMap = GetComponent <MetaTileMap>();
        if (metaTileMap == null)
        {
            Logger.LogError($"MetaTileMap was null on {gameObject.name}");
        }

        networkedMatrix   = transform.parent.GetComponent <NetworkedMatrix>();
        initialOffset     = Vector3Int.CeilToInt(gameObject.transform.position);
        reactionManager   = GetComponent <ReactionManager>();
        metaDataLayer     = GetComponent <MetaDataLayer>();
        MatrixMove        = GetComponentInParent <MatrixMove>();
        tileChangeManager = GetComponentInParent <TileChangeManager>();
        underFloorLayer   = GetComponentInChildren <UnderFloorLayer>();
        tilemapsDamage    = GetComponentsInChildren <TilemapDamage>().ToList();

        if (MatrixManager.Instance.InitializingMatrixes.ContainsKey(gameObject.scene) == false)
        {
            MatrixManager.Instance.InitializingMatrixes.Add(gameObject.scene, new List <Matrix>());
        }
        MatrixManager.Instance.InitializingMatrixes[gameObject.scene].Add(this);


        OnEarthquake.AddListener((worldPos, magnitude) =>
        {
            var cellPos = metaTileMap.WorldToCell(worldPos);

            var bounds =
                new BoundsInt(cellPos - new Vector3Int(magnitude, magnitude, 0),
                              new Vector3Int(magnitude * 2, magnitude * 2, 1));

            foreach (var pos in bounds.allPositionsWithin)
            {
                foreach (var player in Get <PlayerScript>(pos, true))
                {
                    if (player.IsGhost)
                    {
                        continue;
                    }

                    player.registerTile.ServerSlip(true);
                }

                //maybe shake items somehow, too
            }
        });
    }
Beispiel #6
0
    private void UnderFloorElectricalSetTile(Connection WireEndA, Connection WireEndB, PowerTypeCategory powerTypeCategory, Vector3Int position, ElectricalMetaData newdata = null)
    {
        ElectricalCableTile Tile = ElectricityFunctions.RetrieveElectricalTile(WireEndA, WireEndB, powerTypeCategory);

        if (newdata != null)
        {
            newdata.RelatedTile = Tile;
        }
        if (Tile != null)
        {
            if (UnderFloorLayer == null)
            {
                underFloorLayer = GetComponentInChildren <UnderFloorLayer>();
            }
            if (UnderFloorLayer != null)
            {
                UnderFloorLayer.SetTile(position, Tile, Matrix4x4.identity);
            }
        }
    }
Beispiel #7
0
 public IEnumerable <Objects.Disposals.DisposalPipe> GetDisposalPipesAt(Vector3Int position)
 {
     // Return a list, because we may allow disposal pipes to overlap each other - NS with EW e.g.
     return(UnderFloorLayer.GetAllTilesByType <Objects.Disposals.DisposalPipe>(position));
 }