private void Clean() { try { this.Checker.Abort(); if (User != null) { if (User.SpaceInstance is AreaInstance) { if (User.SpaceUser.PathFinding != null) { User.SpaceUser.PathFinding.StopWalk(); } AreaInstance Area = (AreaInstance)User.SpaceInstance; ServerMessage Message1 = new ServerMessage(new byte[] { 128, 123 }, new object[] { User.SpaceUser.ID }); Area.SendToAllButMe(Message1, this.ID); AreaInstance Instance = (AreaInstance)User.SpaceInstance; Instance.RemoveUser(this.ID); } if (User.SpaceInstance is SalaInstance) { if (User.SpaceUser.PathFinding != null) { User.SpaceUser.PathFinding.StopWalk(); } SalaInstance Sala = (SalaInstance)User.SalaInstance; ServerMessage Message1 = new ServerMessage(new byte[] { 128, 123 }, new object[] { User.SpaceUser.ID }); Area.SendToAllButMe(Message1, this.ID); SalaInstance Instance = (SalaInstance)User.SalaInstance; Instance.RemoveUser(this.ID); } } } catch { } }
public void TestFlatten() { var area = new AreaInstance { Name = "root" }; var child1 = new AreaInstance { Name = "child1" }; var child2 = new AreaInstance { Name = "child2" }; area.InverseThis2ParentNavigation.Add(child1); child1.InverseThis2ParentNavigation.Add(child2); var list = new List <AreaInstance>(); list.Add(area); var flatten = list.Flatten(a => a.InverseThis2ParentNavigation).ToList(); Assert.NotNull(flatten); Assert.Equal(3, flatten.Count); }
public async Task AddAreaInstances() { var templates = Controller.GetTemplates().ToList(); var instances = Controller.GetInstances().ToList(); var rootInstance = instances.First(); var template = templates.First(); var newInstance = new AreaInstance { ObjId = Guid.NewGuid(), This2Parent = rootInstance.ObjId, Name = "TestInstance", Description = "testDesc", This2AreaTemplate = template.ObjId, Icon = template.Icon }; var newInstances = new List <AreaInstance> { newInstance }; var saved = (await Controller.AddAreaInstances(newInstances)).ToList(); Assert.NotNull(saved); Assert.NotEmpty(saved); Assert.Equal(newInstance.Name, saved.First().InverseThis2ParentNavigation.First().Name); Assert.Equal(newInstance.ObjId, saved.First().InverseThis2ParentNavigation.First().ObjId); }
public void UpdateCoconuts(int SendedAmount = 0, int ReceivedAmount = 0) { this.ReceivedCoconuts += ReceivedAmount; this.SendedCoconuts += SendedAmount; using (DatabaseClient DatabaseClient = DatabaseManager.GetClient()) { DatabaseClient.SetParameter("@ID", this.ID); DatabaseClient.SetParameter("@SendedAmount", SendedAmount); DatabaseClient.SetParameter("@ReceivedAmount", ReceivedAmount); DatabaseClient.ExecuteScalar("UPDATE boombang_users SET SendedCoconuts = SendedCoconuts+@SendedAmount, ReceivedCoconuts = ReceivedCoconuts+@ReceivedAmount WHERE ID = @ID"); } if (SessionsManager.Online(ID)) { if (this.SpaceInstance != null) { if (this.SpaceInstance is AreaInstance) { AreaInstance Area = (AreaInstance)this.SpaceInstance; Area.SendToAll(new ServerMessage(new byte[] { 146 }, new object[] { this.ID, 5, this.SendedCoconuts, this.ReceivedCoconuts })); } if (this.SpaceInstance is SalaInstance) { SalaInstance Sala = (SalaInstance)this.SpaceInstance; Sala.SendToAll(new ServerMessage(new byte[] { 146 }, new object[] { this.ID, 5, this.SendedCoconuts, this.ReceivedCoconuts })); } } } }
public override void AreaChange(AreaInstance area) { if (GameController.Player != null) { if (!WillBot.isBotPaused) { lock (MyLocks.UpdateTerrainDataLock) { WillBot.LogMessageCombo("AreaChange: Updating terrain data STARTED"); mover.UpdateTerrainData(doNotUpdateIfAlreadyExists: true); WillBot.LogMessageCombo("AreaChange: Updating terrain data FINISHED"); } } if (Settings.Enable.Value && area != null) { Cache.InHideout = area.IsHideout; Cache.InTown = area.IsTown; if (Cache.InHideout == true) { WillBot.Me.HasStashedItemsThisTownCycle = false; WillBot.Me.HasSoldItemsThisTownCycle = false; WillBot.Me.enemies.BlackListedMonsterAddresses.Clear(); ChaosRecipeBehavior.ResetData(); } } } }
/// <summary> /// /// </summary> public void Initialize() { foreach (var superAreaDAO in SuperAreaRepository.Instance.All) { var instance = new SuperAreaInstance(superAreaDAO); WorldService.Instance.AddUpdatable(instance); WorldService.Instance.Dispatcher.AddHandler(instance.SafeDispatch); m_superAreaById.Add(superAreaDAO.Id, instance); } foreach (var areaDAO in AreaRepository.Instance.All) { var instance = new AreaInstance(areaDAO); instance.SuperArea.AddUpdatable(instance); instance.SuperArea.AddHandler(instance.SafeDispatch); m_areaById.Add(areaDAO.Id, instance); } foreach (var subAreaDAO in SubAreaRepository.Instance.All) { var instance = new SubAreaInstance(subAreaDAO); instance.Area.AddHandler(instance.SafeDispatch); m_subAreaById.Add(subAreaDAO.Id, instance); } }
public override void AreaChange(AreaInstance area) { if (Settings.AutoLabDetection.Value) { switch (area.RealLevel) { case 33: Settings.LabType.Value = LabTypes[0]; break; case 55: Settings.LabType.Value = LabTypes[1]; break; case 68: Settings.LabType.Value = LabTypes[2]; break; case 75: case 83: Settings.LabType.Value = LabTypes[3]; break; } } }
internal async Task <IEnumerable <AreaInstance> > ProcessFile(AreaInstance parentInstance, IFormFile formFile) { var targetLocation = ServerInfo.GetTempPath(); var path = Path.Combine(targetLocation, formFile.FileName); // Uncomment to save the file await using (var fileStream = System.IO.File.Create(path)) { formFile.CopyTo(fileStream); } var etsProject = new EtsProjectParser().ParseEtsFile(path, GroupAddressStyle.ThreeLevel); foreach (var b in etsProject.Buildings) { var bInstance = CreateAreaInstance(parentInstance, b); parentInstance.InverseThis2ParentNavigation.Add(bInstance); } return(new List <AreaInstance> { parentInstance }); }
public override void AreaChange(AreaInstance area) { base.AreaChange(area); if (!Settings.Enable) { return; } CurrentZone = MapTypes.Skip; if (area.HasWaypoint || area.IsHideout || area.IsTown || area.RealLevel < 68) { CurrentZone = MapTypes.Skip; } else if (Contains(UniqueMaps, area.Name)) { CurrentZone = MapTypes.Skip; } else if (Contains(CancerMaps, area.Name)) { CurrentZone = MapTypes.Cancer; Play(DirectoryFullName + @"\Media\Cancer.wav"); } else if (Contains(STierMaps, area.Name)) { CurrentZone = MapTypes.Best; } else if (Contains(ATierMaps, area.Name)) { CurrentZone = MapTypes.Good; } else if (area.RealLevel >= 81) // t14+ = 81+ area lvl { CurrentZone = MapTypes.Unknown; } }
public static void CathChest(int IDCofre, Session Session) { Random Rand = new Random(); if (Session.User.SpaceInstance is AreaInstance) { AreaInstance Area = (AreaInstance)Session.User.SpaceInstance; if (Area.Chests.ContainsKey(IDCofre)) { int ChestsID = Area.Chests[IDCofre]; ChestData Chest = ChestManager.Chests[ChestsID]; Area.Chests.Remove(IDCofre); Area.ChestsPoints.Remove(IDCofre); //Sendtoall num 16-04-12 16:56 min 00:09 //Sendtoall num 16-04-12 16:56 min 00:09 if (Chest.Amount_type == "gold") { Session.SendMessage(new ServerMessage(new byte[] { 162 }, new object[] { Chest.Amount })); Session.User.GoldCoins += Chest.Amount; UserManager.UpdateCoins(Session.User); } if (Chest.Amount_type == "silver") { Session.SendMessage(new ServerMessage(new byte[] { 166 }, new object[] { Chest.Amount })); Session.User.SilverCoins += Chest.Amount; UserManager.UpdateCoins(Session.User); } if (Chest.Amount_type == "contest" && Chest.ContestID > 0) { UserManager.UpdateContest(Session.User, Chest.Amount, Chest.ContestID); } } } }
public IEnumerator DestroyArea(AreaInstance area, ExitAreaType type) { if (area != null && m_Areas.Remove(area)) { yield return(area.DestroyArea(this, type)); } }
/// <summary> /// 只能由Area调用 /// </summary> /// <param name="position"></param> /// <returns></returns> public IEnumerator BuildRoom(AreaInstance area) { GameEvent.RoomEvent.FireOnBeginBuildRoom(this); yield return(LoadRoomModel()); GameEvent.RoomEvent.FireOnBuildRoomComplete(this); }
private static AreaInstance RecursiveLoad(AreaInstance parent, AutomaticaContext dbContext) { var loaded = dbContext.AreaInstances .Include(a => a.InverseThis2ParentNavigation) .Include(a => a.This2AreaTemplateNavigation) .ThenInclude(a => a.This2AreaTypeNavigation) .Include(a => a.This2AreaTemplateNavigation) .ThenInclude(a => a.NeedsThis2AreaTypeNavigation) .Include(a => a.This2AreaTemplateNavigation) .ThenInclude(a => a.ProvidesThis2AreayTypeNavigation).SingleOrDefault(a => a.ObjId == parent.ObjId); var newChilds = new List <AreaInstance>(); if (loaded == null) { return(null); } foreach (var child in loaded.InverseThis2ParentNavigation) { newChilds.Add(RecursiveLoad(child, dbContext)); } loaded.InverseThis2ParentNavigation = newChilds; return(loaded); }
public override bool Initialise() { Input.RegisterKey(Keys.F10); Input.ReleaseKey += (sender, keys) => { if (keys == Keys.F10) { Settings.Enable.Value = !Settings.Enable; } }; GameController.LeftPanel.WantUse(() => Settings.Enable); CalcXp = new TimeCache <bool>(() => { partytime += time; time = 0; CalculateXp(); var areaCurrentArea = GameController.Area.CurrentArea; if (areaCurrentArea == null) { return(false); } timeSpan = DateTime.UtcNow - areaCurrentArea.TimeEntered; // Time = $"{timeSpan.TotalMinutes:00}:{timeSpan.Seconds:00}"; Time = AreaInstance.GetTimeString(timeSpan); xpReceivingText = $"{xpRate} *{levelXpPenalty * partyXpPenalty:p0}"; xpGetLeft = $"Got: {ConvertHelper.ToShorten(getXp, "0.00")} ({percentGot:P3}) Left: {ConvertHelper.ToShorten(xpLeftQ, "0.00")}"; maxX = MathHepler.Max(Graphics.MeasureText(fps).X, Graphics.MeasureText(ping).X, Graphics.MeasureText(latency).X, Graphics.MeasureText(areaName).X, Graphics.MeasureText(xpReceivingText).X) * 1.5f; if (partytime > 4900) { var levelPenaltyValue = LevelPenalty.Value; } return(true); }, 1000); LevelPenalty = new TimeCache <bool>(() => { partyXpPenalty = PartyXpPenalty(); levelXpPenalty = LevelXpPenalty(); return(true); }, 5000); GameController.EntityListWrapper.PlayerUpdate += OnEntityListWrapperOnPlayerUpdate; OnEntityListWrapperOnPlayerUpdate(this, GameController.Player); debugInformation = new DebugInformation("Game FPS", "Collect game fps", false); return(true); }
void OnDestroyArea(LevelInstance level, AreaInstance area, ExitLevelType type) { while (transform.childCount > 0) { DestroyImmediate(transform.GetChild(0).gameObject); } name = "RoomContainer"; m_RoomList.Clear(); }
IEnumerator DoBuildArea(AreaData areaData) { if (areaData != null) { AreaInstance area = AreaInstance.Create(this, areaData); m_Areas.Add(area); yield return(area.BuildArea()); } }
public override void AreaChange(AreaInstance area) { _followTarget = null; ResetPathing(); //Load initial transitions! ResetTransitions(); }
private AreaInstance CreateAreaInstance(AreaInstance parent, EtsBuildingPart building) { Guid typeGuid; var icon = AreaTemplateAttribute.GetAttributeFromEnum(AreaTemplates.BuildingPart).Icon; if (building is EtsBuilding) { typeGuid = AreaTemplateAttribute.GetFromEnum(AreaTemplates.Building); } else { switch (building.EtsBuildingType) { case EtsBuildingType.BuildingPart: typeGuid = AreaTemplateAttribute.GetFromEnum(AreaTemplates.BuildingPart); icon = AreaTemplateAttribute.GetAttributeFromEnum(AreaTemplates.BuildingPart).Icon; break; case EtsBuildingType.Floor: case EtsBuildingType.Corridor: typeGuid = AreaTemplateAttribute.GetFromEnum(AreaTemplates.Hallway); icon = AreaTemplateAttribute.GetAttributeFromEnum(AreaTemplates.Hallway).Icon; break; case EtsBuildingType.Stairway: typeGuid = AreaTemplateAttribute.GetFromEnum(AreaTemplates.Staircase); icon = AreaTemplateAttribute.GetAttributeFromEnum(AreaTemplates.Staircase).Icon; break; default: typeGuid = AreaTemplateAttribute.GetFromEnum(AreaTemplates.Room); icon = AreaTemplateAttribute.GetAttributeFromEnum(AreaTemplates.Room).Icon; break; } } var instance = new AreaInstance { ObjId = Guid.NewGuid(), Name = building.Name, Description = building.Description, Icon = icon, This2AreaTemplate = typeGuid, This2Parent = parent.ObjId }; foreach (var part in building.Children) { var partInstance = CreateAreaInstance(instance, part); instance.InverseThis2ParentNavigation.Add(partInstance); } return(instance); }
private void AreaOnOnAreaChange(AreaInstance area) { foreach (var plugin in Plugins) { if (plugin.IsEnable) { plugin.AreaChange(area); } } }
public override void AreaChange(AreaInstance area) { if (!Settings.Enable) { return; } var terrain = GameController.IngameState.Data.Terrain; var terrainBytes = GameController.Memory.ReadBytes(terrain.LayerMelee.First, terrain.LayerMelee.Size); _numCols = (int)terrain.NumCols * 23; _numRows = (int)terrain.NumRows * 23; if ((_numCols & 1) > 0) { _numCols++; } _bitmap = new int[_numCols * _numRows]; int k = 0; int dataIndex = 0; var color = Settings.TerrainColor.Value.ToRgba(); for (int i = 0; i < _numRows; i++) { for (int j = 0; j < _numCols; j += 2) { var b = terrainBytes[dataIndex + (j >> 1)]; _bitmap[k++] = (b >> 4) > 0 ? color : 0; _bitmap[k++] = (b & 0xf) > 0 ? color : 0; } dataIndex += terrain.BytesPerRow; } if (_bitmapHandle.IsAllocated) { _bitmapHandle.Free(); } _bitmapHandle = GCHandle.Alloc(_bitmap, GCHandleType.Pinned); var texture = new Texture2D(Graphics.LowLevel.D11Device, new Texture2DDescription { ArraySize = 1, Height = _numRows, Width = _numCols, Format = Format.R8G8B8A8_UNorm, BindFlags = BindFlags.ShaderResource, Usage = ResourceUsage.Default, MipLevels = 1, CpuAccessFlags = CpuAccessFlags.Write, SampleDescription = new SampleDescription(1, 0) }, new[] { new DataBox(_bitmapHandle.AddrOfPinnedObject(), sizeof(int) * _numCols, 0) }); var srv = new ShaderResourceView(Graphics.LowLevel.D11Device, texture); Graphics.LowLevel.AddOrUpdateTexture("terrain", srv); }
static public RoomInstance Create(AreaInstance area, RoomData roomData) { GameObject obj = new GameObject("RoomInstance " + roomData.index + " " + roomData.roomType); RoomInstance room = obj.AddComponent <RoomInstance>(); if (room.Initialize(area, roomData)) { return(room); } return(null); }
public override void AreaChange(AreaInstance area) { try { EntityAddedQueue.Clear(); NearbyPaths.Clear(); } catch { } }
public void AreaChange(AreaInstance area) { try { Plugin.AreaChange(area); } catch (Exception e) { LogError(e); } }
public void RefreshState() { var igsd = this.Root.Game.IngameState.Data; AreaTemplate clientsArea = igsd.CurrentArea; int curAreaHash = igsd.CurrentAreaHash; if (CurrentArea != null && curAreaHash == CurrentArea.Hash) return; CurrentArea = new AreaInstance(clientsArea, curAreaHash, igsd.CurrentAreaLevel); this.OnAreaChange(this); }
public override void AreaChange(AreaInstance area) { if (!Settings.Enable.Value) { return; } countedIds.Clear(); counters.Clear(); sessionCounter += summaryCounter; summaryCounter = 0; Init(); }
public IEnumerator DoEnterArea(int index) { AreaInstance area = GetAreaInstance(index); if (area != null) { yield return(DoExitArea(ExitAreaType.EnterNextArea)); curArea = area; yield return(curArea.EnterArea()); } }
private void Clear(AreaInstance area) { MaxDpsAoe = 0; MaxDpsSingle = 0; CurrentDpsAoe = 0; CurrentDpsSingle = 0; CurrentDmgAoe = 0; CurrentDmgSingle = 0; lastTime = DateTime.Now; SingleDamageMemory = new double[20]; AOEDamageMemory = new double[20]; }
public static AreaInstance Create(LevelInstance level, AreaData data) { GameObject obj = new GameObject("Area " + data.index); AreaInstance area = obj.AddComponent <AreaInstance>(); if (area.Initialize(level, data)) { area.transform.parent = level.transform; return(area); } DestroyImmediate(obj); return(null); }
public override void AreaChange(AreaInstance area) { if (Settings.Debug) { LogMessage(Name + ": Area has been changed.", LogmsgTime); } if (Settings.Enable.Value && area != null) { Cache.InHideout = area.IsHideout; Cache.InTown = area.IsTown; } }
public override void Render() { base.Render(); if (!Settings.Enable || (GameController.Player != null && GameController.Player.GetComponent <Player>().Level >= 100)) { return; } DateTime nowTime = DateTime.Now; TimeSpan elapsedTime = nowTime - lastTime; if (elapsedTime.TotalSeconds > 1) { CalculateXp(nowTime); lastTime = nowTime; } Vector2 position = StartDrawPointFunc(); int fontSize = Settings.TextSize; Size2 xpRateSize = Graphics.DrawText(xpRate, fontSize, position, FontDrawFlags.Right); Vector2 secondLine = position.Translate(0, xpRateSize.Height); Size2 xpLeftSize = Graphics.DrawText(timeLeft, fontSize, secondLine, FontDrawFlags.Right); Vector2 thirdLine = secondLine.Translate(0, xpLeftSize.Height); string areaName = GameController.Area.CurrentArea.DisplayName; Size2 areaNameSize = Graphics.DrawText(areaName, fontSize, thirdLine, FontDrawFlags.Right); string timer = AreaInstance.GetTimeString(nowTime - GameController.Area.CurrentArea.TimeEntered); Size2 timerSize = Graphics.MeasureText(timer, fontSize); float boxWidth = MathHepler.Max(xpRateSize.Width, xpLeftSize.Width, areaNameSize.Width + timerSize.Width + 20) + 15; float boxHeight = xpRateSize.Height + xpLeftSize.Height + areaNameSize.Height; var bounds = new RectangleF(position.X - boxWidth + 5, position.Y - 5, boxWidth, boxHeight + 10); string systemTime = string.Format("{0} ({1})", nowTime.ToShortTimeString(), GameController.Game.IngameState.CurFps); Size2 timeFpsSize = Graphics.MeasureText(systemTime, fontSize); var dif = bounds.Width - (12 + timeFpsSize.Width + xpRateSize.Width); if (dif < 0) { bounds.X += dif; bounds.Width -= dif; } Graphics.DrawText(systemTime, fontSize, new Vector2(bounds.X + 5, position.Y), Color.White); Graphics.DrawText(timer, fontSize, new Vector2(bounds.X + 5, thirdLine.Y), Color.White); Graphics.DrawBox(bounds, Settings.BackgroundColor); Size = bounds.Size; Margin = new Vector2(0, 5); }
public override void AreaChange(AreaInstance area) { lock (locker) { TownOrHideout = area.IsHideout || area.IsTown; queueOfWorldItems.Clear(); while (queueUpdatedItems.TryDequeue(out _)) { } currentLabels.Clear(); } }
public IResult Render(AreaInstance component) { return component.RenderingInstructions.AnnotateComponentPaths ? new AnnotatedResult(this.inner.Render(component), component.Path) : this.inner.Render(component); }
public IResult Render(AreaInstance area) { var result = new CompositeResult(area.Components.Select(c => c.Render(this))); return this.Annotate(area, result); }
public IResult Render(AreaInstance area) { throw new NotImplementedException(); }