Beispiel #1
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>();
        checkedMatrixMove = new CheckedComponent <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 #2
0
 protected virtual void Awake()
 {
     LocalPositionServer = TransformState.HiddenPos;
     LocalPositionClient = TransformState.HiddenPos;
     if (transform.parent)         //clients dont have this set yet
     {
         objectLayer = transform.parent.GetComponent <ObjectLayer>() ?? transform.parent.GetComponentInParent <ObjectLayer>();
     }
     customNetTransform  = GetComponent <CustomNetTransform>();
     matrixRotationHooks = GetComponents <IMatrixRotation>();
     fireExposables      = GetComponents <IFireExposable>();
     IPlayerEntersTiles  = GetComponents <IPlayerEntersTile>();
     IObjectEntersTiles  = GetComponents <IObjectEntersTile>();
     CurrentsortingGroup = GetComponent <SortingGroup>();
     iPushable           = GetComponent <IPushable>();
     pushPull            = new CheckedComponent <PushPull>(this);
 }