private static void InitializeNavAgentView(GameEntity traveler, NavTilemapController navController) { var travelerObject = GameLinkUtils.GetObject(traveler); var navAgentView = travelerObject.AddComponent <NavAgentComponentView>(); navAgentView.Initialize(); var navComponent = navAgentView.Component; var navAgent = navComponent.agent; navAgent.nav = navController; }
public void OnBeforeDestroy(GameEntity entity) { GameObject entityObject = GameLinkUtils.GetObject(entity.id.value); DebugUtil.Assert(entityObject != null, "Expected link at before destroy entity=" + entity); if (entityObject == null) { return; } UnityEngine.Object.Destroy(entityObject); }
public void OnSpawn(GameEntity entity, GameObject prefab) { GameObject origin = GameLinkUtils.GetObject(entity.id.value); DebugUtil.Assert(origin != null, "Expected link at spawn entity=" + entity + ". Spawning at world origin. prefab=" + prefab); if (origin == null) { UnityEngine.Object.Instantiate(prefab); return; } GameObject clone = UnityEngine.Object.Instantiate(prefab, origin.transform); clone.transform.SetParent(null, true); }
protected override void Execute(List <GameEntity> entities) { foreach (GameEntity attractor in entities) { var trigger = attractor.triggerEnter; GameEntity traveler = m_Context.GetEntityWithId(trigger.otherId); if (!traveler.hasNavAgent) { InitializeNavAgentView(traveler, attractor.navAgent.agent.nav); } SetDestinationIfIsCloser(traveler.navAgent.agent, GameLinkUtils.GetObject(attractor).transform.position); } }