public static GameAction.ExecutionContext GetActionContext(ISimWorldReadAccessor accessor, Entity actionInstigator, Entity actionEntity, NativeArray <Entity> targets) { Entity firstPhysicalInstigator = actionInstigator; if (accessor.TryGetComponent(actionInstigator, out FirstInstigator firstInstigatorComponent)) { firstPhysicalInstigator = firstInstigatorComponent.Value; } Entity lastPhysicalInstigator = firstPhysicalInstigator; if (lastPhysicalInstigator != actionInstigator && accessor.HasComponent <FixTranslation>(actionInstigator)) { lastPhysicalInstigator = actionInstigator; } GameAction.ExecutionContext useContext = new GameAction.ExecutionContext() { Action = actionEntity, FirstPhysicalInstigator = firstPhysicalInstigator, LastPhysicalInstigator = lastPhysicalInstigator, ActionInstigatorActor = actionInstigator, Targets = targets, }; return(useContext); }
private void StartNewSurvey(SurveyBaseController surveyPrefab) { if (SurveyManager.Instance.IsSurveyRunning) { SurveyManager.Instance.StopCurrentSurvey(); } if (surveyPrefab != null) { var useContext = new GameAction.ExecutionContext(); UIStateMachine.Instance.TransitionTo(UIStateType.ParameterSelection); SurveyManager.Instance.BeginSurvey(_focusLocation, useContext, new List <GameAction.ParameterData>(), surveyPrefab.CreateDebugQuery(), surveyPrefab, this.OnSurveyComplete, this.OnSurveyCancel); } }
public void BeginSurvey(Vector3 surveyLocation, GameAction.ExecutionContext useContext, List <GameAction.ParameterData> currentResultData, GameAction.ParameterDescription[] parameters, SurveyBaseController surveyPrefab, System.Action <List <GameAction.ParameterData> > onCompleteCallback, System.Action onCancelCallback) { GameObject surveyInstance = Instantiate(surveyPrefab.gameObject, surveyLocation, Quaternion.identity, _surveyContainer); SurveyBaseController surveyController = surveyInstance.GetComponent <SurveyBaseController>(); if (surveyController != null) { _currentSurvey = surveyController; surveyController.StartSurvey(delegate(List <GameAction.ParameterData> resultData) { onCompleteCallback.Invoke(resultData); if (surveyController.DelayBeforeDestruction > 0) { GameObject surveyObject = surveyController.gameObject; this.DelayedCall(surveyController.DelayBeforeDestruction, () => { if (surveyObject != null) { Destroy(surveyObject); } }); } else { Destroy(surveyController.gameObject); } }, onCancelCallback, useContext, currentResultData, parameters); } else { Debug.LogError("Skipping request because it couldn't start"); // can't start mini-game, complete it immediatly List <GameAction.ParameterData> DefaultResults = new List <GameAction.ParameterData>(); onCompleteCallback.Invoke(DefaultResults); } }
public void BeginDefaultSurvey(Vector3 requestLocation, GameAction.ExecutionContext useContext, List <GameAction.ParameterData> currentResultData, GameAction.ParameterDescription parameterDescription, System.Action <List <GameAction.ParameterData> > onCompleteCallback, System.Action onCancelCallback) { SurveyBaseController surveyPrefab = null; // find default survey for param foreach (DefaultSurveyReference request in _defaultSurveys) { if (request.ParameterType == parameterDescription.GetParameterDescriptionType()) { surveyPrefab = request.Survey.GetComponent <SurveyBaseController>(); break; } } if (surveyPrefab != null) { BeginSurvey(requestLocation, useContext, currentResultData, new GameAction.ParameterDescription[] { parameterDescription }, surveyPrefab, onCompleteCallback, onCancelCallback); } }
public static bool GetItemTrajectorySettings(GamePresentationCache cache, GameAction.ExecutionContext useContext, Vector2 direction, out Vector2 spawnOffset, out float radius) { spawnOffset = Vector2.zero; radius = 0.05f; if (cache.SimWorld.TryGetComponent(useContext.ActionInstigatorActor, out ItemAction itemAction)) { GameActionThrow throwAction = GetGameAction <GameActionThrow>(cache.SimWorld, itemAction.Value); if (throwAction != null) { spawnOffset = (Vector2)throwAction.GetSpawnPosOffset(cache.SimWorld, useContext, itemAction.Value, (fix2)direction); radius = (float)throwAction.GetProjectileRadius(cache.SimWorld, itemAction.Value); return(true); } } return(false); }
public static float GetProjectileGravityScale(GamePresentationCache cache, GameAction.ExecutionContext useContext) { if (cache.SimWorld == null) { return(1); } if (!cache.SimWorld.Exists(useContext.ActionInstigatorActor)) { return(1); } if (cache.SimWorld.TryGetComponent(useContext.ActionInstigatorActor, out ItemAction itemAction)) { if (cache.SimWorld.TryGetComponent(itemAction.Value, out GameActionThrow.Settings throwSettings)) { return(GetEntityGravScale(throwSettings.ProjectilePrefab)); } } return(1); float GetEntityGravScale(Entity entity) { if (!cache.SimWorld.Exists(entity)) { return(1); } if (!cache.SimWorld.TryGetComponent(entity, out PhysicsGravity grav)) { return(1); } return((float)grav.Scale); } }
public void StartSurvey(System.Action <List <GameAction.ParameterData> > completeCallback, System.Action cancelCallback, GameAction.ExecutionContext useContext, List <GameAction.ParameterData> currentResultData, params GameAction.ParameterDescription[] parameters) { Running = true; InfoTextDisplay.Instance.SetText(_tooltip); var context = new Context() { QueryParams = parameters, UseContext = useContext, CurrentData = currentResultData }; CurrentContext = context; _onCompleteCallback = completeCallback; _cancelCallback = cancelCallback; _result.Clear(); ShowCostPreview(); _currentLoop = StartCoroutine(SurveyRoutine(context, _result, Complete, Cancel)); }