using System; using KKSG; using UnityEngine; using XUtliPoolLib; namespace XMainClient { internal class XLevelSpawnTask : XLevelBaseTask { public uint _EnemyID; public int _MonsterRotate; public int _MonsterIndex; public Vector3 _MonsterPos; public LevelSpawnType _SpawnType; public bool _IsSummonTask; public XLevelSpawnTask(XLevelSpawnInfo ls) : base(ls) { this._IsSummonTask = false; } public XEntity CreateClientMonster(uint id, float yRotate, Vector3 pos, int _waveid) { Quaternion rotation = Quaternion.Euler(0f, yRotate, 0f); XEntity xentity = XSingleton.singleton.CreateEntity(id, pos, rotation, true, uint.MaxValue); bool flag = xentity != null; XEntity result; if (flag) { xentity.Wave = _waveid; xentity.CreateTime = Time.realtimeSinceStartup; XAIEventArgs @event = XEventPool.GetEvent(); @event.DepracatedPass = true; @event.Firer = XSingleton.singleton.Player; @event.EventType = 1; @event.EventArg = "SpawnMonster"; XSingleton.singleton.FireEvent(@event, 0.05f); result = xentity; } else { result = null; } return result; } public XEntity CreateServerAttrMonster(UnitAppearance data, float yRotate, Vector3 pos, int _waveid) { XAttributes xattributes = XSingleton.singleton.InitAttrFromServer(data.uID, data.nickid, data.unitType, data.unitName, data.attributes, data.fightgroup, data.isServerControl, data.skills, data.bindskills, new XOutLookAttr((OutLook)null), data.level, 0u); xattributes.Outlook.SetData(data.outlook, xattributes.TypeID); bool flag = xattributes.Type == EntitySpecies.Species_Role; XEntity xentity; if (flag) { xentity = XSingleton.singleton.Add(XSingleton.singleton.CreateRole(xattributes, pos, Quaternion.Euler(0f, yRotate, 0f), false, false)); } else { xentity = XSingleton.singleton.Add(XSingleton.singleton.CreateEntity(xattributes, pos, Quaternion.Euler(0f, yRotate, 0f), false)); } bool flag2 = xentity != null; XEntity result; if (flag2) { xentity.Wave = _waveid; bool flag3 = XSingleton.singleton.SceneType == SceneType.SCENE_BOSSRUSH; if (flag3) { XLevelDocument specificDocument = XDocuments.GetSpecificDocument(XLevelDocument.uuID); BossRushTable.RowData bossRushConfig = specificDocument.GetBossRushConfig(XSingleton.singleton.SceneID, (uint)(XSingleton.singleton.ls._total_kill + 1)); bool flag4 = data != null; if (flag4) { float num = 1f; double attr = xentity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Basic); double value = attr * (double)num; xentity.Attributes.SetAttr(XAttributeDefine.XAttr_MaxHP_Basic, value); xentity.Attributes.SetAttr(XAttributeDefine.XAttr_CurrentHP_Basic, value); } } bool isDead = data.IsDead; if (isDead) { XSingleton.singleton.DeathDetect(xentity, null, true); result = null; } else { result = xentity; } } else { result = null; } return result; } public override bool Execute(float time) { base.Execute(time); XLevelDynamicInfo xlevelDynamicInfo = null; bool flag = !this._IsSummonTask; if (flag) { xlevelDynamicInfo = this._spawner.GetWaveDynamicInfo(this._id); bool flag2 = xlevelDynamicInfo == null; if (flag2) { return true; } } XEntity xentity = null; bool flag3 = this._SpawnType == LevelSpawnType.Spawn_Source_Monster; if (flag3) { xentity = this.CreateClientMonster(this._EnemyID, (float)this._MonsterRotate, this._MonsterPos + new Vector3(0f, 0.02f, 0f), this._id); XSingleton.singleton.ls.AddLevelSpawnEntityCount(xentity.ID); } else { bool flag4 = this._SpawnType == LevelSpawnType.Spawn_Source_Doodad; if (!flag4) { UnitAppearance cacheServerMonster = XSingleton.singleton.GetCacheServerMonster((uint)this._id); bool flag5 = cacheServerMonster != null; if (flag5) { xentity = this.CreateServerAttrMonster(cacheServerMonster, (float)this._MonsterRotate, this._MonsterPos + new Vector3(0f, 0.02f, 0f), this._id); } XSingleton.singleton.ls.AddLevelSpawnEntityCount(xentity.ID); } } bool flag6 = xlevelDynamicInfo != null; if (flag6) { bool flag7 = xentity != null; if (flag7) { xlevelDynamicInfo._generateCount++; xlevelDynamicInfo._enemyIds.Add(xentity.ID); } bool flag8 = xlevelDynamicInfo._generateCount == xlevelDynamicInfo._TotalCount; if (flag8) { xlevelDynamicInfo._generatetime = time; } bool flag9 = xentity != null && xentity.IsBoss; if (flag9) { XSingleton.singleton.HasBoss = true; return false; } } return true; } } }