private void Workspace_Changed(Events.Abstract e) { Changed = true; switch (e.type) { case Blockly.Events.CREATE: var cre = (Events.Create)e; BlockCreated?.Invoke(this, cre); break; case Blockly.Events.DELETE: var del = (Events.Delete)e; BlockDeleted?.Invoke(this, del); break; case Blockly.Events.CHANGE: var chg = (Events.Change)e; BlockChanged?.Invoke(this, chg); break; case Blockly.Events.MOVE: var mov = (Events.Move)e; BlockMoveed?.Invoke(this, mov); break; case Blockly.Events.UI: var ui = (Events.Ui)e; UiEvent?.Invoke(this, ui); break; } }
/// <summary> /// /// </summary> private void ThreadProcess() { int i = 0; while (!mIsClosed) { resetEvent.WaitOne(); if (mIsClosed) { break; } resetEvent.Reset(); if (NotifyType == RealDataNotifyType.Tag || NotifyType == RealDataNotifyType.All) { if (ValueChanged != null && mChangedIds.Length > 0) { var vids = mChangedIds; lock (mLockObject) { if (mChangedIds == mChangedId1) { mChangedIds = mChangedId2; } else { mChangedIds = mChangedId1; } } ValueChanged?.Invoke(vids.Buffer, vids.Length); vids.Length = 0; } } if (NotifyType == RealDataNotifyType.All || NotifyType == RealDataNotifyType.Block) { if ((BlockChanged != null) && i % 10 == 0) { i = 0; lock (mBlockChangeds) { foreach (var vv in mBlockChangeds) { if (vv.Value.IsDirty) { vv.Value.IsDirty = false; BlockChanged?.Invoke(vv.Value); } } } } } i++; Thread.Sleep(10); } }
private void EventTimer_Tick(object sender, EventArgs e) { string source = GetSource(); if (backSource != source) { backSource = source; BlockChanged?.Invoke(); } }
public void Dispose() { if (BlockChanged != null) { BlockChanged.GetInvocationList().ForEach(o => { BlockChanged -= (Action <object, bool>)o; }); } BlockChanged = null; }
/// <summary> /// 获取某个特定格子的状态 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public virtual GameBoardBlock this[int x, int y] { get { return(Blocks[x][y]); } protected set { Blocks[x][y] = value; BlockChanged?.Invoke(x, y); } }
public virtual void SetBlock(uint x, uint y, uint z, ushort id, byte metadata) { if (y >= Height) { return; } var nx = (uint)(x % MaxX); var nz = (uint)(z % MaxZ); var chunk = GetChunk(nx / Chunk.Width, nz / Chunk.Depth); chunk.SetBlock((int)(nx % Chunk.Width), (int)y, (int)(nz % Chunk.Depth), id, metadata); BlockChanged?.Invoke(this, new BlockChangedEventArgs(nx, y, nz)); }
public void Destroy() { if (musicPlayer != null) { Destroy(musicPlayer); } Stop(); backingTrackPlayers = null; Started?.RemoveAllListeners(); Stopped?.RemoveAllListeners(); BlockChanged?.RemoveAllListeners(); EntryPoint.Instance.Updated?.RemoveListener(Update); }
/// <summary> /// Sets the block at the given location, and optionally records map history. /// </summary> /// <param name="x"></param> /// <param name="z"></param> /// <param name="y"></param> /// <param name="type"></param> public void SetBlockId(short x, short y, short z, byte type) { if (!BlockInBounds(x, y, z)) { return; } if (!Loaded) { return; } //int index = (y * CwMap.SizeZ + z) * CwMap.SizeX + x; //CwMap.BlockData[index] = type; MapProvider.SetBlock(x, y, z, type); BlockChanged?.Invoke(new Vector3S(x, y, z), type); }
public virtual void OnBlockChanged(bool oValue, bool nValue) { BlockChanged?.Invoke(this, EventArgs.Empty); }
public void SetBlock(GameBoardBlock block, int x, int y, string detail = null) { this[x, y] = block; BlockDetails[x][y] = detail; BlockChanged?.Invoke(x, y); }
public override bool Equals(object obj) { BlockChanged o = obj as BlockChanged; return(o != null && target.Equals(o.target) && changed.Equals(o.changed)); }
private void cboColors_SelectedIndexChanged(object sender, EventArgs e) { BlockChanged?.Invoke(this, new GeoColorChangedEventArgs(SelectedColor)); }
private void AdvanceBlock() { ProcessEvents(currentBlock); BlockChanged.Invoke(currentBlock); ++currentBlock; }
public override void applyAction(BlockAction action) { if (!isServerBlock) { return; } BlockChanged bc = action as BlockChanged; if (bc != null) { //Debug.Log("Applying " + action); Liquid liq = bc.changed as Liquid; if (liq != null || bc.changed is Air) { float otherPressure = liq != null?liq.getPressure() : 0; float otherLvl = otherPressure; if (bc.changed.getCoordinates().y > coords.y) { otherPressure += density; } if (bc.changed.getCoordinates().y < coords.y) { otherPressure -= density; } float dt = Math.Min((float)DateTime.Now.Subtract(lastPressureUpdate).TotalSeconds, bc.getAge()); float delta = Math.Min(0.1f, FLOW_RATE * dt) * (otherPressure - getPressure()); delta = Math.Max(-(getPressure() - MIN_LEVEL), delta); if (delta < 0 && otherLvl - delta <= MIN_LEVEL) { delta = -(MIN_LEVEL - otherLvl + 0.001f); if (getPressure() + delta < MIN_LEVEL && coords.y <= bc.changed.getCoordinates().y) { delta = 0; } } delta = Math.Max(-getPressure(), Math.Min(otherLvl, delta)); if (Math.Abs(delta) / dt > MIN_CHANGE_PER_SECOND) { //Debug.Log("Trying to flow " + delta); if (delta + getPressure() < MIN_LEVEL) { delta = -getPressure(); } if (-delta + otherLvl < MIN_LEVEL) { delta = otherLvl; } addPressure(delta); if (liq != null) { liq.addPressure(-delta); } else { liq = spreadTo(bc.changed.getPosition(), -delta) as Liquid; } Debug.Log(this + ": Flown " + delta + " - " + this + " is now " + getPressure() + " " + liq + " is now " + liq.getPressure()); if (level < MIN_LEVEL && level > 0.001f) { Debug.LogError("Lost water"); } } else if (level < MIN_LEVEL) { if (data.pressure > 0) { Debug.LogError("Lost water " + data.pressure + " in " + this); } //Debug.Log(this + ": Removed placeholder"); pos.getChunk().setBlock(pos, new Air(coords, true)); } else { //Debug.Log(this + ": " + delta + " / " + dt + " too small for change"); } } else { //Debug.Log("Invalid neighbour"); } } else { Debug.LogError("Unknown action: " + action); } }