public void FillPosRect(int ix, int iz) { SceneEntityPosRect entityRect; IntVector2 idx = IntVector2.Tmp; idx.x = ix; idx.y = iz; if (!_entityRects.TryGetValue(idx, out entityRect)) { int cntNpc = SceneEntityPosRect.EntityNpcNum; int cntMonster = SceneEntityPosRect.EntityMonsterNum; IntVector2 key = new IntVector2(ix, iz); if (!_posRectNpcCnt.TryGetValue(key, out cntNpc)) { cntNpc = SceneEntityPosRect.EntityNpcNum; _posRectNpcCnt[key] = cntNpc; } if (SceneEntityPosRect.EntityNpcNum != 0 && Mathf.Abs(ix) > 16 || Mathf.Abs(iz) > 16) // Add limitation on npc's count { cntNpc = 0; } entityRect = new SceneEntityPosRect(ix, iz); entityRect.Fill(cntNpc, cntMonster); _entityRects[key] = entityRect; } }
public void Fill(int cntNpc, int cntMonster) { Vector3 center = RectIdxToCenterPos(_idx); bool bAvailable = false; SceneEntityPosAgent agent; System.Random rand = new System.Random(); for (int i = 0; i < cntNpc; i++) { Vector3 point = !PeGameMgr.randomMap ? GetEntityPoint(center, out bAvailable) : GetNpcPointInRndTer(center, out bAvailable); if (bAvailable) { if (VFDataRTGen.IsTownConnectionType(Mathf.RoundToInt(point.x), Mathf.RoundToInt(point.z))) { agent = NpcEntityCreator.CreateAgent(point); agent.spInfo = _rndNpcAgentInfo; _posRndNpcAgents.Add(agent); // npc entity would not be destroyed by scene } else { if (rand.NextDouble() < 0.25) { agent = NpcEntityCreator.CreateAgent(point); agent.spInfo = _rndNpcAgentInfo; _posRndNpcAgents.Add(agent); // npc entity would not be destroyed by scene } } } } for (int i = 0; i < cntMonster; i++) { Vector3 point = GetEntityPoint(center, out bAvailable); if (bAvailable && null == AIErodeMap.IsInErodeArea2D(point)) { _posRndMonsterAgents.Add(MonsterEntityCreator.CreateAgent(point)); } } SceneMan.AddSceneObjs(_posRndNpcAgents); SceneMan.AddSceneObjs(_posRndMonsterAgents); if (PeGameMgr.IsStory) { _posFixedMonsterIds = AISpawnPoint.Find(center.x - EntityCreationRadius, center.z - EntityCreationRadius, center.x + EntityCreationRadius, center.z + EntityCreationRadius); if (_posFixedMonsterIds.Count > 0) { SceneEntityCreatorArchiver.Instance.AddFixedSpawnPointToScene(_posFixedMonsterIds); } } else if (PeGameMgr.IsSingleAdventure) { SceneEntityPosRect.AddProcedualBossSpawnPointToScene(_idx); } }
void Update() { #if Have_ENTITY //if (EntityCreateMgr.DbgUseLegacyCode) // return; // single dungeon has pos of current, all entities but player and followers are inactive // multi mode's dungeon 's Y < -500, so agent with y==0 will not get a y to gen because raycast is from MaxHitTest to zero if ((PeGameMgr.IsSingleBuild) || (PeGameMgr.IsSingleAdventure && PeGameMgr.yirdName == AdventureScene.Dungen.ToString())) { return; } if (SceneMan.self == null || SceneMan.self.Observer == null) { return; } isNeedRefresh |= SceneMan.self.CenterMoved; if (!_bReadyToRefresh || !isNeedRefresh) { return; } isNeedRefresh = false; SceneEntityPosRect.EntityPosToRectIdx(SceneMan.self.Observer.position, IntVector2.Tmp); int cx = IntVector2.Tmp.x; int cz = IntVector2.Tmp.y; for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { SceneEntityCreatorArchiver.Instance.FillPosRect(cx + x, cz + z); } } #endif //TODO : Delete unused }
public RndNpcAgentInfo(SceneEntityPosRect posRect) : base() { _posRect = posRect; }