Ejemplo n.º 1
0
        private static Tile GetOverlayTile(Track track, int tileX, int tileY)
        {
            RoadTileset tileset  = track.RoadTileset;
            Point       location = new Point(tileX, tileY);

            OverlayTiles overlay = track.OverlayTiles;

            for (int i = overlay.Count - 1; i >= 0; i--)
            {
                OverlayTile overlayTile = overlay[i];
                if (overlayTile.IntersectsWith(location))
                {
                    int  relativeX = tileX - overlayTile.X;
                    int  relativeY = tileY - overlayTile.Y;
                    byte tileId    = overlayTile.Pattern[relativeX, relativeY];

                    if (tileId != OverlayTile.None)
                    {
                        return(tileset[tileId]);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
    private void EnsureInit()
    {
        if (registerTile != null)
        {
            return;
        }
        if (SMALL_BURNING_PREFAB == null)
        {
            SMALL_BURNING_PREFAB = CommonPrefabs.Instance.BurningSmall;
            LARGE_BURNING_PREFAB = CommonPrefabs.Instance.BurningLarge;
        }

        if (SMALL_ASH == null)
        {
            SMALL_ASH = TileManager.GetTile(TileType.Effects, "SmallAsh") as OverlayTile;
            LARGE_ASH = TileManager.GetTile(TileType.Effects, "LargeAsh") as OverlayTile;
        }
        registerTile = GetComponent <RegisterTile>();
        pushable     = GetComponent <IPushable>();
        //this is just a guess - large items can't be picked up
        isLarge = GetComponent <Pickupable>() == null;
        if (Resistances.Flammable)
        {
            if (burningObjectOverlay == false)
            {
                burningObjectOverlay = GameObject.Instantiate(isLarge ? LARGE_BURNING_PREFAB : SMALL_BURNING_PREFAB, transform)
                                       .GetComponent <BurningOverlay>();
            }

            burningObjectOverlay.enabled = true;
            burningObjectOverlay.StopBurning();
        }
    }
Ejemplo n.º 3
0
    public void AddOverlay(Vector3Int cellPosition, OverlayTile overlayTile, Matrix4x4?transformMatrix = null,
                           Color?color = null)
    {
        //use remove methods to remove overlay instead
        if (overlayTile == null)
        {
            return;
        }

        cellPosition.z = 0;

        //Dont add the same overlay twice
        if (HasOverlay(cellPosition, overlayTile))
        {
            return;
        }

        var overlayPos = metaTileMap.GetFreeOverlayPos(cellPosition, overlayTile.LayerType);

        if (overlayPos == null)
        {
            return;
        }

        cellPosition = overlayPos.Value;

        InternalUpdateTile(cellPosition, overlayTile, transformMatrix, color);

        AlertClients(cellPosition, overlayTile.TileType, overlayTile.OverlayName, transformMatrix, color);

        AddToChangeList(cellPosition, overlayTile.LayerType, overlayTile.TileType, overlayTile.OverlayName, transformMatrix: transformMatrix, color: color);
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a new gas at runtime
        /// </summary>
        public void CreateNewGas(string name, float molarHeatCapacity, float molarMass, bool hasOverlay, float minMolesToSee,
                                 OverlayTile overlayTile = null, Color?colour = null, int fusionPower = 0, Reagent associatedReagent = null)
        {
            //Create new SO instance
            var newSo = ScriptableObject.CreateInstance <GasSO>();

            newSo.MolarHeatCapacity = molarHeatCapacity;
            newSo.MolarMass         = molarMass;
            newSo.Name          = name;
            newSo.HasOverlay    = hasOverlay;
            newSo.MinMolesToSee = minMolesToSee;
            newSo.OverlayTile   = overlayTile;
            newSo.HasOverlay    = overlayTile != null;

            if (colour != null)
            {
                newSo.CustomColour = true;
                newSo.Colour       = colour.Value;
            }

            newSo.FusionPower       = fusionPower;
            newSo.AssociatedReagent = associatedReagent;

            AddNewGasSo(newSo);
        }
Ejemplo n.º 5
0
 public override bool Equals(object other)
 {
     if (other != null && this.GetType().Equals(other.GetType()))
     {
         OverlayTile comparedOverlay = (OverlayTile)other;
         return((OverlayName == comparedOverlay.OverlayName) &&
                (PreviewSprite == comparedOverlay.PreviewSprite) &&
                (overlayType == comparedOverlay.OverlayType) &&
                (isCleanable == comparedOverlay.isCleanable) &&
                (isGraffiti == comparedOverlay.isGraffiti));
     }
     return(false);
 }
    public void UpdateOverlay(Vector3Int cellPosition, OverlayTile overlayTile)
    {
        cellPosition.z = 0;
        if (!metaTileMap.HasTile(cellPosition, overlayTile.LayerType, true))
        {
            return;
        }
        cellPosition.z = -1;
        if (IsDifferent(cellPosition, overlayTile))
        {
            InternalUpdateTile(cellPosition, overlayTile);

            RpcUpdateTile(cellPosition, overlayTile.TileType, overlayTile.name);

            AddToChangeList(cellPosition, overlayTile);
        }
    }
    public void UpdateOverlay(Vector3Int cellPosition, OverlayTile overlayTile, Matrix4x4?transformMatrix = null,
                              Color?color = null)
    {
        cellPosition.z = 0;
        if (!metaTileMap.HasTile(cellPosition, overlayTile.LayerType))
        {
            return;
        }
        cellPosition.z = -1;
        if (IsDifferent(cellPosition, overlayTile))
        {
            InternalUpdateTile(cellPosition, overlayTile, transformMatrix, color);

            AlertClients(cellPosition, overlayTile.TileType, overlayTile.name, transformMatrix, color);

            AddToChangeList(cellPosition, overlayTile, transformMatrix: transformMatrix, color: color);
        }
    }
Ejemplo n.º 8
0
 public bool HasOverlay(Vector3Int cellPosition, OverlayTile overlayTile)
 {
     return(metaTileMap.HasOverlay(cellPosition, overlayTile.LayerType, overlayTile));
 }
Ejemplo n.º 9
0
 protected override void Awake()
 {
     base.Awake();
     accessRestrictions = GetComponent <AccessRestrictions>();
     ashOverlay         = TileManager.GetTile(TileType.Effects, "SmallAsh") as OverlayTile;
 }