private void OnEntityKill(BaseEntity entity) { if (!(entity is SurveyCharge)) { return; } OilConfigInfo info = new OilConfigInfo(); if (wait.TryGetValue(entity, out info)) { Vector3 Pos = entity.transform.position; NextTick(() => { var list = new List <SurveyCrater>(); Vis.Entities(Pos, 1f, list); if (list.Count() > 0) { foreach (var survey in list) { if (readed.Contains(survey)) { continue; } if (UnityEngine.Random.Range(0, 100) < info.Chance) { survey.Kill(); SurveyCrater oilEntity = GameManager.server.CreateEntity("assets/prefabs/tools/surveycharge/survey_crater_oil.prefab", survey.transform.position) as SurveyCrater; if (oilEntity == null || oil == null) { continue; } oilEntity.Spawn(); var res = ResourceDepositManager.GetOrCreate(oilEntity.transform.position); if (res == null) { continue; } res._resources.Clear(); float pm = UnityEngine.Random.Range(info.PMMin, info.PMMax); float workNeeded = 45f / pm; int amount = UnityEngine.Random.Range(50000, 100000); res.Add(oil, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.OIL, true); oils.Add(new OilInfo(Pos, amount, workNeeded)); changed = true; readed.Add(oilEntity); } if (!survey.IsDestroyed) { readed.Add(survey); } } } }); wait.Remove(entity); } }
private void OnExplosiveThrown(BasePlayer player, BaseEntity entity) { if (!(entity is SurveyCharge)) { return; } OilConfigInfo info = HasPermission(player); if (info == null || info.Chance <= 0) { return; } wait.Add(entity, info); }
private OilConfigInfo HasPermission(BasePlayer player) { OilConfigInfo per = new OilConfigInfo(); int i = 0; foreach (var x in config.list) { if (permission.UserHasPermission(player.UserIDString, x.Per)) { if (x.Priority >= i) { i = x.Priority; per = x; } } } return(per); }