Beispiel #1
0
        public Package(string packagePath, Game game)
        {
            PackagePath = packagePath;

            _game   = game;
            _logger = LoggerProvider.GetLogger();
        }
 private void Update()
 {
     if ((this.dbLoader != null) && this.dbLoader.IsDone)
     {
         Engine engine = EngineService.Engine;
         base.enabled = false;
         if (!string.IsNullOrEmpty(this.dbLoader.Error))
         {
             string message = $"AssetBundleDatabase loading was failed. URL: {this.dbLoader.URL}, Error: {this.dbLoader.Error}";
             LoggerProvider.GetLogger(this).Error(message);
             this.dbLoader.Dispose();
             this.dbLoader = null;
             engine.ScheduleEvent <InvalidGameDataErrorEvent>(engine.CreateEntity("RemoteConfigLoading"));
         }
         else
         {
             this.dbLoader.Dispose();
             this.dbLoader = null;
             AssetBundleDatabaseComponent component = new AssetBundleDatabaseComponent {
                 AssetBundleDatabase = this.DeserializeDatabase(this.dbLoader.Bytes)
             };
             this.dbEntity.AddComponent(component);
             base.Complete();
         }
     }
 }
Beispiel #3
0
        public GameServerLauncher(ushort serverPort, string configJson, string blowfishKey)
        {
            ConfigJson = configJson;
            ServerPort = serverPort;
            _logger    = LoggerProvider.GetLogger();
            var itemManager = new ItemManager();

            game    = new Game(itemManager);
            _server = new Server(game, serverPort, configJson, blowfishKey);

#if !DEBUG
            try
            {
#endif
            ExecutingDirectory = ServerContext.ExecutingDirectory;
            _server.Start();
#if !DEBUG
        }

        catch (Exception e)
        {
            _logger.Error(e);
        }
#endif
        }
Beispiel #4
0
        public GameServerLauncher(string serverHost, ushort serverPort, string configJson,
                                  string blowfishKey, int human_count, int agent_count, float multiplier,
                                  string replay_path, ushort redis_port, float step_multiplier)
        {
            ConfigJson = configJson;
            ServerPort = serverPort;
            ServerHost = serverHost;
            _logger    = LoggerProvider.GetLogger();
            game       = new Game(serverHost, human_count, agent_count, multiplier,
                                  replay_path, redis_port, step_multiplier);

            _server = new Server(game, serverHost, serverPort, configJson);

#if !DEBUG
            try
            {
#endif
            ExecutingDirectory = ServerContext.ExecutingDirectory;
            _server.Start();
#if !DEBUG
        }

        catch (Exception e)
        {
            _logger.Error(e);
        }
#endif
        }
 private void LoadingFromHTTP()
 {
     if (!string.IsNullOrEmpty(this.wwwLoader.Error))
     {
         int num;
         this.loadFromHttpAttempts = (num = this.loadFromHttpAttempts) - 1;
         if (num <= 0)
         {
             this.Error = $"{this.wwwLoader.Error}, url: {this.url}";
             this.State = AssetBundleDiskCacheState.COMPLETE;
         }
         else
         {
             int num2 = (RELOAD_FROM_HTTP_ATTEMPTS - this.loadFromHttpAttempts) + 2;
             LoggerProvider.GetLogger(this).WarnFormat("AssetBundle download failed, try attempt {0}, URL: {1}, ERROR: {2}", num2, this.url, this.wwwLoader.Error);
             this.wwwLoader.Dispose();
             this.State = AssetBundleDiskCacheState.START_LOAD_FROM_HTTP;
         }
     }
     else
     {
         this.Progress = this.wwwLoader.Progress;
         if (this.wwwLoader.IsDone)
         {
             this.buffer = this.wwwLoader.Bytes;
             if (!this.AssetBundleDiskCacheRequest.UseCrcCheck || this.CheckCrc())
             {
                 this.wwwLoader.Dispose();
                 this.State = AssetBundleDiskCacheState.START_WRITE_TO_DISK;
             }
         }
     }
 }
Beispiel #6
0
        static void Main(string[] args)
        {
            // var logger = LoggerProvider.GetLogger("Unsupported Logger");
            var logger = LoggerProvider.GetLogger("TextLogger");

            logger.LogInfo("CSharpLoggingSample - In Main() method");
        }
Beispiel #7
0
        private T ReadToConfigTree <T>(Stream inputStream, ConfigurationProfile configurationProfile) where T : ConfigTreeNode, new()
        {
            T             local  = Activator.CreateInstance <T>();
            ConfigsMerger merger = new ConfigsMerger();
            string        str    = null;

            try
            {
                IReader reader = ReaderFactory.Open(inputStream, Options.KeepStreamsOpen);
                while (reader.MoveToNextEntry())
                {
                    str = NormalizePath(reader.Entry.FilePath);
                    if (!string.IsNullOrEmpty(str))
                    {
                        if (reader.Entry.IsDirectory)
                        {
                            local.FindOrCreateNode(str);
                            continue;
                        }
                        if (configurationProfile.Match(Path.GetFileName(str)))
                        {
                            merger.Put(local.FindOrCreateNode(this.GetDirectoryName(str)), Path.GetFileNameWithoutExtension(str), this.LoadYaml(reader));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                LoggerProvider.GetLogger(this).Fatal("Error read configs " + str, exception);
                throw;
            }
            merger.Merge();
            return(local);
        }
Beispiel #8
0
 public DebugParticlesCommand(ChatCommandManager chatCommandManager, Game game)
     : base(chatCommandManager, game)
 {
     _logger        = LoggerProvider.GetLogger();
     _playerManager = game.PlayerManager;
     _game          = game;
 }
Beispiel #9
0
 public void Launch(Action onComplete = null)
 {
     LoggerProvider.GetLogger(this).InfoFormat("Activate {0}", this);
     this.onComplete = onComplete;
     this.Activate();
     Activator.CreateInstance <TCompletionStrategy>().TryAutoCompletion(new Action(this.Complete));
 }
Beispiel #10
0
        public Map(Game game)
        {
            _game   = game;
            _logger = LoggerProvider.GetLogger();
            Id      = _game.Config.GameConfig.Map;
            var path = Path.Combine(
                game.Config.ContentPath,
                _game.Config.ContentManager.GameModeName,
                "AIMesh",
                "Map" + Id,
                "AIPath.aimesh_ngrid"
                );

            if (File.Exists(path))
            {
                NavGrid = NavGridReader.ReadBinary(path);
            }
            else
            {
                _logger.Error("Failed to load navigation graph. Aborting map load.");
                return;
            }

            AnnouncerEvents  = new List <Announce>();
            CollisionHandler = new CollisionHandler(_game, this);
            MapGameScript    = GetMapScript(Id);
        }
Beispiel #11
0
        public AttackableUnit(
            Game game,
            string model,
            IStats stats,
            int collisionRadius = 40,
            float x             = 0,
            float y             = 0,
            int visionRadius    = 0,
            uint netId          = 0
            ) : base(game, x, y, collisionRadius, visionRadius, netId)

        {
            Logger = LoggerProvider.GetLogger();
            Stats  = stats;
            Model  = model;
            if (collisionRadius != 0)
            {
                CollisionRadius = collisionRadius;
            }
            else
            {
                CollisionRadius = 40;
            }
            Stats.AttackSpeedMultiplier.BaseValue = 1.0f;
        }
Beispiel #12
0
        private void HandleError <T>(string errorMessage, Exception e) where T : Event, new()
        {
            LoggerProvider.GetLogger(this).Error(errorMessage, e);
            Engine engine = EngineService.Engine;

            engine.ScheduleEvent <T>(engine.CreateEntity("StartupConfigLoading"));
        }
Beispiel #13
0
 public HandleChatBoxMessage(Game game)
 {
     _game = game;
     _chatCommandManager = game.ChatCommandManager;
     _playerManager      = game.PlayerManager;
     _logger             = LoggerProvider.GetLogger();
 }
Beispiel #14
0
 public WWWLoader(UnityEngine.WWW www)
 {
     this.www = www;
     this.Log = LoggerProvider.GetLogger(this);
     this.Log.InfoFormat("Loading {0}", www.url);
     activeLoaders.AddLast(this);
 }
Beispiel #15
0
        private void SendCommand(TankNode tankNode, MoveCommand moveCommand)
        {
            TankMovementSenderComponent tankMovementSender = tankNode.tankMovementSender;
            Movement?movement = moveCommand.Movement;

            if (movement != null)
            {
                if (!PhysicsUtil.ValidateMovement(movement.Value))
                {
                    return;
                }
                tankMovementSender.LastSentMovement     = movement;
                tankMovementSender.LastSentMovementTime = PreciseTime.Time;
                base.Log.Debug("SEND MOVEMENT");
            }
            if (moveCommand.WeaponRotation != null)
            {
                if (!PhysicsUtil.IsValidFloat(moveCommand.WeaponRotation.Value))
                {
                    LoggerProvider.GetLogger(typeof(PhysicsUtil)).ErrorFormat("Invalid WeaponRotation. StackTrace:[{0}]", Environment.StackTrace);
                    return;
                }
                tankMovementSender.LastSentWeaponRotationTime = PreciseTime.Time;
                base.Log.Debug("SEND WEAPON_ROTATION");
            }
            base.ScheduleEvent(new MoveCommandEvent(moveCommand), tankNode.Entity);
            base.Log.Debug("SEND DISCRETE");
        }
Beispiel #16
0
 public HandleSpawn(Game game)
 {
     _logger           = LoggerProvider.GetLogger();
     _game             = game;
     _itemManager      = game.ItemManager;
     _playerManager    = game.PlayerManager;
     _networkIdManager = game.NetworkIdManager;
 }
Beispiel #17
0
 protected void Complete()
 {
     LoggerProvider.GetLogger(this).InfoFormat("Complete {0}", this);
     if (this.onComplete != null)
     {
         this.onComplete();
     }
 }
Beispiel #18
0
 public Server(Game game, ushort port, string configJson, string blowfishKey)
 {
     _logger      = LoggerProvider.GetLogger();
     _game        = game;
     _serverPort  = port;
     _blowfishKey = blowfishKey;
     _config      = Config.LoadFromJson(game, configJson);
 }
Beispiel #19
0
 public Game(ItemManager itemManager)
 {
     _logger            = LoggerProvider.GetLogger();
     ItemManager        = itemManager;
     ChatCommandManager = new ChatCommandManager(this);
     NetworkIdManager   = new NetworkIdManager();
     PlayerManager      = new PlayerManager(this);
     ScriptEngine       = new CSharpScriptEngine();
 }
 // TODO: The first two parameters are in milliseconds, the third is seconds. QoL fix this?
 public SurrenderHandler(Game g, TeamId team, float minTime, float restTime, float length)
 {
     _log  = LoggerProvider.GetLogger();
     _game = g;
     Team  = team;
     SurrenderMinimumTime = minTime;
     SurrenderRestTime    = restTime;
     SurrenderLength      = length;
 }
Beispiel #21
0
 public static bool ValidateQuaternion(Quaternion rot)
 {
     if (IsValidQuaternion(rot))
     {
         return(true);
     }
     LoggerProvider.GetLogger(typeof(PhysicsUtil)).WarnFormat("Invalid Quaternion: {0} StackTrace:[{1}]", rot, Environment.StackTrace);
     return(false);
 }
Beispiel #22
0
 public static bool ValidateVector3(Vector3 v)
 {
     if (IsValidVector3(v))
     {
         return(true);
     }
     LoggerProvider.GetLogger(typeof(PhysicsUtil)).WarnFormat("Invalid Vector3: {0} StackTrace:[{1}]", v, Environment.StackTrace);
     return(false);
 }
Beispiel #23
0
 private void ShowDebugSkipInfo(Handler handler, ArgumentNode fromArgumentNode, ArgumentNode toArgumentNode)
 {
     if (handler.SkipInfo)
     {
         Optional <JoinType> joinType = toArgumentNode.argument.JoinType;
         string message = SkipInfoBuilder.GetSkipReasonDetails(handler, fromArgumentNode, toArgumentNode, joinType);
         LoggerProvider.GetLogger(this).Warn(message);
     }
 }
Beispiel #24
0
        public override object Decode(ProtocolBuffer protocolBuffer)
        {
            long  serverTime   = protocolBuffer.Reader.ReadInt64();
            long  diffToServer = TimeService.DiffToServer;
            float num3         = Date.FromServerTime(diffToServer, serverTime);

            LoggerProvider.GetLogger(this).InfoFormat("Decode: serverTime={0} diffToServer={1} unityTime={2}", serverTime, diffToServer, num3);
            return(new Date(num3));
        }
Beispiel #25
0
 public static void InitCursor(CursorType type, Texture2D cursorTexture, Vector2 cursorHotspot)
 {
     if (cursorTexture == null)
     {
         LoggerProvider.GetLogger(typeof(Cursors)).ErrorFormat("CursorService:InitCursor argument 'cursorTexture' is null, argument 'type' is {0}", type);
     }
     else
     {
         type2Data.Add(type, new CursorData(cursorTexture, cursorHotspot));
     }
 }
Beispiel #26
0
 public static void AddTorqueSafe(this Rigidbody rigidbody, Vector3 torque)
 {
     if (!IsValidVector3(torque))
     {
         LoggerProvider.GetLogger(typeof(PhysicsUtil)).WarnFormat("Invalid add torque (Vector3) StackTrace:[{0}]", Environment.StackTrace);
     }
     else
     {
         rigidbody.AddTorque(torque);
     }
 }
Beispiel #27
0
 public static void AddTorqueSafe(this Rigidbody rigidbody, float x, float y, float z)
 {
     if (!IsValidVector3(new Vector3(x, y, z)))
     {
         LoggerProvider.GetLogger(typeof(PhysicsUtil)).WarnFormat("Invalid add torque (float, float, float) StackTrace:[{0}]", Environment.StackTrace);
     }
     else
     {
         rigidbody.AddTorque(x, y, z);
     }
 }
Beispiel #28
0
        public Server(Game game, ushort port, string configJson, string blowfishKey)
        {
            _logger      = LoggerProvider.GetLogger();
            _game        = game;
            _serverPort  = port;
            _blowfishKey = blowfishKey;
            _config      = Config.LoadFromJson(game, configJson);

            AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;
            AppDomain.CurrentDomain.UnhandledException   += CurrentDomain_UnhandledException;
        }
Beispiel #29
0
 public Game()
 {
     _logger            = LoggerProvider.GetLogger();
     ItemManager        = new ItemManager();
     ChatCommandManager = new ChatCommandManager(this);
     NetworkIdManager   = new NetworkIdManager();
     PlayerManager      = new PlayerManager(this);
     ScriptEngine       = new CSharpScriptEngine();
     RequestHandler     = new NetworkHandler <ICoreRequest>();
     ResponseHandler    = new NetworkHandler <ICoreResponse>();
 }
 private void SetLoadingStopTimeout()
 {
     try
     {
         WWWLoader.DEFAULT_TIMEOUT_SECONDS = int.Parse(ConfigurationService.GetConfig(ConfigPath.LOADING_STOP_TIMEOUT).GetStringValue("timeoutInSec"));
     }
     catch (Exception exception)
     {
         LoggerProvider.GetLogger(this).Error(exception.Message, exception);
     }
 }