public void AddSegment(SegmentInformation segmentInfo) { var sap = segmentInfo.SegmentAlignedPosition; Preconditions.Assert(!_tokensDict.ContainsKey(sap), $"There arleady is segment of sap {sap}"); RequiredSegmentSituation requiredSituation; bool fillingIsNecessary; if (segmentInfo.SegmentState == SegmentState.Active) { fillingIsNecessary = true; requiredSituation = RequiredSegmentSituation.Filled; } else if (segmentInfo.SegmentState == SegmentState.Standby) { fillingIsNecessary = false; requiredSituation = RequiredSegmentSituation.Filled; } else { fillingIsNecessary = false; requiredSituation = RequiredSegmentSituation.Created; } var newToken = new SegmentGenerationProcessToken(SegmentGenerationProcessSituation.BeforeStartOfCreation, requiredSituation); _tokensDict[sap] = new SegmentGenerationProcessTokenWithFillingNecessity() { Token = newToken, FillingIsNecessary = fillingIsNecessary }; _executor.ExecuteSegmentAction(newToken, sap); }
public void RemoveSegment(SegmentInformation segmentInfo) { var sap = segmentInfo.SegmentAlignedPosition; Preconditions.Assert(_tokensDict.ContainsKey(sap), "Cannot remove segment, as it was never present in dict " + segmentInfo.SegmentAlignedPosition); var token = _tokensDict[sap].Token; token.RequiredSituation = RequiredSegmentSituation.Removed; _executor.ExecuteSegmentAction(token, sap); _tokensDict.Remove(sap); }
private void SetTokenState(SegmentInformation segmentInfo) { var go = _segmentTokens[segmentInfo.SegmentAlignedPosition]; if (segmentInfo.SegmentState == SegmentState.Active) { go.GetComponent <MeshRenderer>().material.color = Color.yellow; } else { go.GetComponent <MeshRenderer>().material.color = Color.green; } }
private void AddToken(SegmentInformation segmentInfo) { var pos = segmentInfo.SegmentAlignedPosition; var go = GameObject.CreatePrimitive(PrimitiveType.Cube); go.transform.localPosition = new Vector3(pos.X * _sectorSize.x, 0, pos.Y * _sectorSize.y); go.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); if (_segmentTokens.ContainsKey(pos)) { GameObject.Destroy(_segmentTokens[pos]); } _segmentTokens[pos] = go; SetTokenState(segmentInfo); }
public void SegmentStateChange(SegmentInformation segmentInfo) { var sap = segmentInfo.SegmentAlignedPosition; Preconditions.Assert(_tokensDict.ContainsKey(sap), "During segmentStateChange to Active there is no tokens in dict"); var token = _tokensDict[sap]; if (segmentInfo.SegmentState == SegmentState.Active) { token.Token.RequiredSituation = RequiredSegmentSituation.Filled; token.FillingIsNecessary = true; _executor.ExecuteSegmentAction(token.Token, sap); } else if (segmentInfo.SegmentState == SegmentState.Standby) { token.Token.RequiredSituation = RequiredSegmentSituation.Filled; token.FillingIsNecessary = false; } else { token.Token.RequiredSituation = RequiredSegmentSituation.Created; token.FillingIsNecessary = false; } }
public void SegmentStateChange(SegmentInformation segmentInfo) { _changeSegmentState(segmentInfo); }
public void RemoveSegment(SegmentInformation segmentInfo) { _removeSegment(segmentInfo); }
public void AddSegment(SegmentInformation segmentInfo) { _addSegment(segmentInfo); }