예제 #1
0
		public WorldStateCollection(IWorldSpace area, WorldState[] states)
		{
			Area = area;
			States = states;
			CompiledState = new byte[8 * States.Length];

			// init default states
			for (var i = 0; i < States.Length; i++)
			{
				var state = States[i];
				Array.Copy(BitConverter.GetBytes((uint)state.Key), 0, CompiledState, i * 8, 4);
				Array.Copy(BitConverter.GetBytes(state.DefaultValue), 0, CompiledState, 4 + i * 8, 4);
			}
		}
예제 #2
0
		static WorldStates()
		{
			CreateStates();

			foreach (var state in AllStates)
			{
				if (state != null)
				{
					WorldState[] arr;
					if (state.ZoneId != ZoneId.None)
					{
						arr = GetStates(state.ZoneId);
						if (arr == null)
						{
							arr = new WorldState[1];
						}
						ArrayUtil.AddOnlyOne(ref arr, state);
						ZoneStates[(int)state.MapId] = arr;
					}
					else if (state.MapId != MapId.End)
					{
						arr = GetStates(state.MapId);
						if (arr == null)
						{
							arr = new WorldState[1];
						}
						ArrayUtil.AddOnlyOne(ref arr, state);
						MapStates[(int)state.MapId] = arr;
					}
					else
					{
						ArrayUtil.AddOnlyOne(ref GlobalStates, state);
						arr = GlobalStates;
					}
					state.Index = (uint)arr.Length - 1;
				}
			}
		}
예제 #3
0
		private static void AddState(WorldState state)
		{
			AllStates[(int)state.Key] = state;
		}
예제 #4
0
 public static void SendUpdateWorldState(IPacketReceiver rcv, WorldState state)
 {
     SendUpdateWorldState(rcv, state.Key, state.DefaultValue);
 }
예제 #5
0
		private void OnStateChanged(WorldState state, int value)
		{
			Area.CallOnAllCharacters(chr => WorldStateHandler.SendUpdateWorldState(chr, state.Key, value));
		}
예제 #6
0
		public void SetUInt32(WorldState state, uint value)
		{
			Array.Copy(BitConverter.GetBytes(value), 0, CompiledState, 4 + state.Index * 8, 4);
			OnStateChanged(state, (int)value);
		}
예제 #7
0
 private static void AddState(WorldState state)
 {
     AllStates[(int)state.Key] = state;
 }