Ejemplo n.º 1
0
 public ScriptedMovement(ScriptedMovement original, CreatureObject clone)
     : base(clone)
 {
     _speed           = original._speed;
     _state           = original._state;
     _entry           = new SyncEntry();
     _entries         = original._entries;
     _current         = original._current;
     _waiting         = original._waiting;
     _position        = original.Position;
     _rotation        = original.Rotation;
     _direction       = original._direction;
     clone.OnSpawn   += ScriptedMovement_OnSpawn;
     clone.OnDestroy += ScriptedMovement_OnDestroy;
 }
Ejemplo n.º 2
0
        public static bool SelectAllMovements(out Dictionary <int, DB_Movement> data)
        {
            var locked = false;

            data = new Dictionary <int, DB_Movement>();
            if (!IsConnected)
            {
                return(false);
            }
            try
            {
                using (MySqlCommand _cmd = _connection.CreateCommand())
                {
                    _cmd.CommandText = $"SELECT * FROM {tb_12};";
                    Monitor.Enter(_connection, ref locked);
                    using (MySqlDataReader _result = _cmd.ExecuteReader())
                    {
                        ushort id; ushort state; DB_Movement script;
                        if (_result.HasRows)
                        {
                            while (_result.Read())
                            {
                                id    = _result.GetUInt16(0);
                                state = _result.GetUInt16(1);
                                if (!data.TryGetValue(id, out script))
                                {
                                    data[id] = script = new DB_Movement(id);
                                }
                                script.Entries.Add(state, new MovementEntry(_result.GetByte(2), _result.GetInt32(3), _result.GetInt32(4), _result.GetByte(5),
                                                                            _result.GetInt32(6), _result.GetInt32(7), _result.GetVector3(8), _result.GetVector3(11)));
                            }
                        }
                    }
                }
                return(true);
            }
            catch { return(false); }
            finally { if (locked)
                      {
                          Monitor.Exit(_connection);
                      }
            }
        }
Ejemplo n.º 3
0
 public static async Task <Dictionary <int, DB_Movement> > SelectAllMovementsAsync()
 {
     try
     {
         using (var connection = await GetConnectionAsync())
         {
             using (var command = connection.CreateCommand())
             {
                 command.CommandText = $"SELECT * FROM {tb_12};";
                 using (var reader = await command.ExecuteReaderAsyncEx())
                 {
                     var result = new Dictionary <int, DB_Movement>();
                     if (reader.HasRows)
                     {
                         while (await reader.ReadAsyncEx())
                         {
                             var id    = reader.GetUInt16(0);
                             var state = reader.GetUInt16(1);
                             if (!result.TryGetValue(id, out var entry))
                             {
                                 result[id] = entry = new DB_Movement(id);
                             }
                             entry.Entries.Add(state, new MovementEntry(reader.GetByte(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetByte(5),
                                                                        reader.GetInt32(6), reader.GetInt32(7), reader.GetVector3(8), reader.GetVector3(11)));
                         }
                     }
                     return(result);
                 }
             }
         }
     }
     catch (Exception exp)
     {
         ServerLogger.LogException(exp);
         return(null);
     }
 }
Ejemplo n.º 4
0
 public static bool Select(int id, out DB_Movement entry)
 {
     return(m_movements.TryGetValue(id, out entry));
 }