Beispiel #1
0
 public void RemoveCsScript(GameVpObject gameVpObject)
 {
     if (_csScripts.ContainsKey(gameVpObject.Id))
     {
         var host = _csScripts[gameVpObject.Id];
         host = null;
         _csScripts.Remove(gameVpObject.Id);
     }
 }
Beispiel #2
0
 public void AttachCsScript(GameVpObject gameVpObject, string csScriptName)
 {
     if (!_list.ContainsKey(gameVpObject.Id))
     {
         var script = Path.Combine(_instance.GameInstanceConfiguration.StorageDataPath, "CsScript", csScriptName).LoadTextFile();
         Add(gameVpObject, script);
     }
     _csScripts.Add(gameVpObject.Id, new GameScript(_instance, gameVpObject, csScriptName));
 }
Beispiel #3
0
 public GameVpObject Get(GameVpObject vpObject)
 {
     if (File.Exists(GetPath(vpObject)))
     {
         return(JsonConvert.DeserializeObject <GameVpObject>(GetPath(vpObject).LoadTextFile()));
         //return SerializableExtensions.Deserialize<GameVpObject>(GetPath(vpObject));
     }
     return(null);
 }
Beispiel #4
0
 public bool Add(GameVpObject vpObject)
 {
     if (File.Exists(GetPath(vpObject)))
     {
         return(false);
     }
     JsonConvert.SerializeObject(vpObject, Formatting.Indented).SaveTextFile(GetPath(vpObject));
     return(true);
 }
Beispiel #5
0
 public RcDefault Add(GameVpObject prototype)
 {
     if (_list.ContainsKey(prototype.Id))
     {
         return(new RcDefault(0));
     }
     _list.Add(prototype.Id, prototype);
     // refresh the object.
     return(_instance.GetObject(prototype.Id));
 }
Beispiel #6
0
 public GameScript(GameInstance instance, GameVpObject vpObject, string csScriptName)
 {
     _instance                = instance;
     _vpObject                = vpObject;
     _csScriptName            = csScriptName;
     _fsw                     = new FileSystemWatcher(Path.Combine(instance.GameInstanceConfiguration.StorageDataPath, "CsScript"), _csScriptName);
     _fsw.Changed            += _fsw_Changed;
     _fsw.EnableRaisingEvents = true;
     _fsw.NotifyFilter        = NotifyFilters.LastWrite;
     Execute(_csScriptName);
 }
Beispiel #7
0
 public void Remove(GameVpObject vpObject)
 {
     File.Delete(GetPath(vpObject));
 }
Beispiel #8
0
 private string GetPath(GameVpObject vpObject)
 {
     return(Path.Combine(StorageDirectory, vpObject.Id.ToString()));
 }