protected virtual PlayAreaBAnchor AddNewChildBAnchor(bool directlyStartPlacing = true) { if (IS_NOT_NULL(playAreaBAnchorPrefab) && IS_NULL(CurrentPlayAreaBAnchorBeingPlaced)) { PlayAreaBAnchor spawnedPlayAreaBAnchor = Instantiate(playAreaBAnchorPrefab); if (IS_NOT_NULL(spawnedPlayAreaBAnchor)) { spawnedPlayAreaBAnchor.transform.parent = transform; PlayAreaBAnchors.Add(spawnedPlayAreaBAnchor); LogConsole("Adding new play area BAnchor : " + PlayAreaBAnchors.Count); spawnedPlayAreaBAnchor.StartedPlacing += On_SpawnedPlayAreaBAnchor_StartedPlacing; spawnedPlayAreaBAnchor.EndedPlacing += On_SpawnedPlayAreaBAnchor_EndedPlacing; if (directlyStartPlacing) { spawnedPlayAreaBAnchor.OnStartPlacing(); } return(spawnedPlayAreaBAnchor); } } return(null); }
protected virtual void On_SpawnedPlayAreaBAnchor_EndedPlacing(PlayAreaBAnchor playAreaBAnchor) { if (IS_NOT_NULL(playAreaBAnchor) && IS_VALUE_CONTAINED(PlayAreaBAnchors, playAreaBAnchor) && ARE_EQUAL(CurrentPlayAreaBAnchorBeingPlaced, playAreaBAnchor)) { int index = PlayAreaBAnchors.IndexOf(playAreaBAnchor); InvokeEventIfBound(NewPlayAreaBAnchorSet, playAreaBAnchor, index); CurrentPlayAreaBAnchorBeingPlaced = null; } }
public override void SetUpPlayArea() { if (IS_NOT_NULL(ARCursor.Instance)) { // Reset (existing) BAnchors setAnchorsCount = 0; PlayAreaBAnchor[] playAreaBAnchorsCopy = PlayAreaBAnchors.ToArray(); foreach (PlayAreaBAnchor playAreaBAnchor in playAreaBAnchorsCopy) { Destroy(playAreaBAnchor.gameObject); } PlayAreaBAnchors.Clear(); ExtentPoints.Clear(); CurrentPlayAreaBAnchorBeingPlaced = null; DrawPlayAreaExtensions(); LogConsole("Started setting up play area. Setting first anchor..."); PlayAreaState = EPlayAreaState.SETTING_ANCHORS; StartSettingFirstAnchor(); } }
protected virtual bool RemoveChildBAnchor(PlayAreaBAnchor playAreaBAnchor) { if (IS_NOT_NULL(playAreaBAnchor)) { if (IS_VALUE_CONTAINED(PlayAreaBAnchors, playAreaBAnchor)) { playAreaBAnchor.StartedPlacing -= On_SpawnedPlayAreaBAnchor_StartedPlacing; playAreaBAnchor.EndedPlacing -= On_SpawnedPlayAreaBAnchor_EndedPlacing; PlayAreaBAnchors.Remove(playAreaBAnchor); if (CurrentPlayAreaBAnchorBeingPlaced == playAreaBAnchor) { CurrentPlayAreaBAnchorBeingPlaced = null; } Destroy(playAreaBAnchor.gameObject); return(true); } LogConsoleWarning("Couldn't remove the given PlayAreaBAnchor : " + playAreaBAnchor.gameObject.name); } return(false); }