public void ResetLayerData(Layer layer) { CellLayerData data = GetLayerData(layer.Id); if (data != null) { data.Value = Mathf.Clamp01(data.BaseValue); data.Offset = 0; //#if DEBUG // if (Manager.WorldIsReady) // { // Debug.Log("Reseting cell " + Position + " layer data. data.Value: " + data.Value + ", data.BaseValue: " + data.BaseValue + ", data.BaseOffset: " + data.BaseOffset); // } //#endif } else { //#if DEBUG // if (Manager.WorldIsReady) // { // Debug.Log("Reseting cell " + Position + " layer data. Data is null"); // } //#endif } if (layer.MaxPresentValue < data.Value) { layer.MaxPresentValue = data.Value; } }
public CellLayerData(CellLayerData source) { Id = source.Id; Value = source.Value; BaseValue = source.BaseValue; Offset = source.Offset; }
public override void AddCellBeforeModification(TerrainCell cellBefore) { LayerOffsetPair pair; if (!_layerOffsetPairs.TryGetValue(cellBefore.Position, out pair)) { CellLayerData data = null; CellLayerData cellData = cellBefore.GetLayerData(LayerId); if (cellData != null) { data = new CellLayerData(cellData); } pair = new LayerOffsetPair { Position = cellBefore.Position, Before = data }; _layerOffsetPairs.Add(cellBefore.Position, pair); } }
public void SetLayerData(Layer layer, float value, float offset, CellLayerData data) { if (data == null) { if ((value <= 0) && (offset == 0)) { return; } data = new CellLayerData(); PresentLayerIds.Add(layer.Id); LayerData.Add(data); _layerData[layer.Id] = data; } data.BaseValue = value - offset; data.Offset = offset; data.Id = layer.Id; data.Value = Mathf.Clamp01(value); //#if DEBUG // if (Manager.WorldIsReady) // { // Debug.Log("Setting cell " + Position + " layer data. data.Value: " + data.Value + ", data.BaseValue: " + data.BaseValue + ", data.BaseOffset: " + data.BaseOffset); // } //#endif if (layer.MaxPresentValue < data.Value) { layer.MaxPresentValue = data.Value; } }