public override void UpdateBuilding(string mapName, IBuildingSaveData building) { ExecuteNonQuery("UPDATE buildings SET " + "parentId=@parentId, " + "entityId=@entityId, " + "currentHp=@currentHp, " + "positionX=@positionX, " + "positionY=@positionY, " + "positionZ=@positionZ, " + "rotationX=@rotationX, " + "rotationY=@rotationY, " + "rotationZ=@rotationZ, " + "isLocked=@isLocked, " + "lockPassword=@lockPassword, " + "creatorId=@creatorId, " + "creatorName=@creatorName " + "WHERE id=@id AND mapName=@mapName", new SqliteParameter("@id", building.Id), new SqliteParameter("@parentId", building.ParentId), new SqliteParameter("@entityId", building.EntityId), new SqliteParameter("@currentHp", building.CurrentHp), new SqliteParameter("@mapName", mapName), new SqliteParameter("@positionX", building.Position.x), new SqliteParameter("@positionY", building.Position.y), new SqliteParameter("@positionZ", building.Position.z), new SqliteParameter("@rotationX", building.Rotation.eulerAngles.x), new SqliteParameter("@rotationY", building.Rotation.eulerAngles.y), new SqliteParameter("@rotationZ", building.Rotation.eulerAngles.z), new SqliteParameter("@isLocked", building.IsLocked), new SqliteParameter("@lockPassword", building.LockPassword), new SqliteParameter("@creatorId", building.CreatorId), new SqliteParameter("@creatorName", building.CreatorName)); }
public override void UpdateBuilding(string mapName, IBuildingSaveData building) { MySqlConnection connection = NewConnection(); connection.Open(); ExecuteNonQuery(connection, null, "UPDATE buildings SET " + "parentId=@parentId, " + "dataId=@dataId, " + "currentHp=@currentHp, " + "positionX=@positionX, " + "positionY=@positionY, " + "positionZ=@positionZ, " + "rotationX=@rotationX, " + "rotationY=@rotationY, " + "rotationZ=@rotationZ, " + "creatorId=@creatorId, " + "creatorName=@creatorName " + "WHERE id=@id AND mapName=@mapName", new MySqlParameter("@id", building.Id), new MySqlParameter("@parentId", building.ParentId), new MySqlParameter("@dataId", building.DataId), new MySqlParameter("@currentHp", building.CurrentHp), new MySqlParameter("@mapName", mapName), new MySqlParameter("@positionX", building.Position.x), new MySqlParameter("@positionY", building.Position.y), new MySqlParameter("@positionZ", building.Position.z), new MySqlParameter("@rotationX", building.Rotation.eulerAngles.x), new MySqlParameter("@rotationY", building.Rotation.eulerAngles.y), new MySqlParameter("@rotationZ", building.Rotation.eulerAngles.z), new MySqlParameter("@creatorId", building.CreatorId), new MySqlParameter("@creatorName", building.CreatorName)); connection.Close(); }
private IEnumerator SaveBuildingRoutine(IBuildingSaveData buildingSaveData) { if (buildingSaveData != null && !savingBuildings.Contains(buildingSaveData.Id)) { savingBuildings.Add(buildingSaveData.Id); var job = new UpdateBuildingJob(Database, Assets.onlineScene.SceneName, buildingSaveData); job.Start(); yield return(StartCoroutine(job.WaitFor())); savingBuildings.Remove(buildingSaveData.Id); Debug.Log("Building [" + buildingSaveData.Id + "] Saved"); } }
public static T CloneTo <T>(this IBuildingSaveData from, T to) where T : IBuildingSaveData { to.Id = from.Id; to.ParentId = from.ParentId; to.DataId = from.DataId; to.CurrentHp = from.CurrentHp; to.Position = from.Position; to.Rotation = from.Rotation; to.CreatorId = from.CreatorId; to.CreatorName = from.CreatorName; DevExtUtils.InvokeStaticDevExtMethods(ClassType, "CloneTo", from, to); return(to); }
public override void CreateBuilding(string mapName, IBuildingSaveData saveData) { ExecuteNonQuery("INSERT INTO buildings (id, parentId, entityId, currentHp, mapName, positionX, positionY, positionZ, rotationX, rotationY, rotationZ, creatorId, creatorName) VALUES (@id, @parentId, @entityId, @currentHp, @mapName, @positionX, @positionY, @positionZ, @rotationX, @rotationY, @rotationZ, @creatorId, @creatorName)", new SqliteParameter("@id", saveData.Id), new SqliteParameter("@parentId", saveData.ParentId), new SqliteParameter("@entityId", saveData.EntityId), new SqliteParameter("@currentHp", saveData.CurrentHp), new SqliteParameter("@mapName", mapName), new SqliteParameter("@positionX", saveData.Position.x), new SqliteParameter("@positionY", saveData.Position.y), new SqliteParameter("@positionZ", saveData.Position.z), new SqliteParameter("@rotationX", saveData.Rotation.eulerAngles.x), new SqliteParameter("@rotationY", saveData.Rotation.eulerAngles.y), new SqliteParameter("@rotationZ", saveData.Rotation.eulerAngles.z), new SqliteParameter("@creatorId", saveData.CreatorId), new SqliteParameter("@creatorName", saveData.CreatorName)); }
public override void UpdateBuilding(string mapName, IBuildingSaveData building) { MySqlConnection connection = NewConnection(); OpenConnectionSync(connection); ExecuteNonQuerySync(connection, null, "UPDATE buildings SET " + "parentId=@parentId, " + "entityId=@entityId, " + "currentHp=@currentHp, " + "remainsLifeTime=@remainsLifeTime, " + "isLocked=@isLocked, " + "lockPassword=@lockPassword, " + "creatorId=@creatorId, " + "creatorName=@creatorName, " + "extraData=@extraData, " + "positionX=@positionX, " + "positionY=@positionY, " + "positionZ=@positionZ, " + "rotationX=@rotationX, " + "rotationY=@rotationY, " + "rotationZ=@rotationZ " + "WHERE id=@id AND mapName=@mapName", new MySqlParameter("@id", building.Id), new MySqlParameter("@parentId", building.ParentId), new MySqlParameter("@entityId", building.EntityId), new MySqlParameter("@currentHp", building.CurrentHp), new MySqlParameter("@remainsLifeTime", building.RemainsLifeTime), new MySqlParameter("@mapName", mapName), new MySqlParameter("@isLocked", building.IsLocked), new MySqlParameter("@lockPassword", building.LockPassword), new MySqlParameter("@creatorId", building.CreatorId), new MySqlParameter("@creatorName", building.CreatorName), new MySqlParameter("@extraData", building.ExtraData), new MySqlParameter("@positionX", building.Position.x), new MySqlParameter("@positionY", building.Position.y), new MySqlParameter("@positionZ", building.Position.z), new MySqlParameter("@rotationX", building.Rotation.eulerAngles.x), new MySqlParameter("@rotationY", building.Rotation.eulerAngles.y), new MySqlParameter("@rotationZ", building.Rotation.eulerAngles.z)); connection.Close(); }
public override void CreateBuilding(string mapName, IBuildingSaveData saveData) { MySqlConnection connection = NewConnection(); connection.Open(); ExecuteNonQuery(connection, null, "INSERT INTO buildings (id, parentId, dataId, currentHp, mapName, positionX, positionY, positionZ, rotationX, rotationY, rotationZ, creatorId, creatorName) VALUES (@id, @parentId, @dataId, @currentHp, @mapName, @positionX, @positionY, @positionZ, @rotationX, @rotationY, @rotationZ, @creatorId, @creatorName)", new MySqlParameter("@id", saveData.Id), new MySqlParameter("@parentId", saveData.ParentId), new MySqlParameter("@dataId", saveData.DataId), new MySqlParameter("@currentHp", saveData.CurrentHp), new MySqlParameter("@mapName", mapName), new MySqlParameter("@positionX", saveData.Position.x), new MySqlParameter("@positionY", saveData.Position.y), new MySqlParameter("@positionZ", saveData.Position.z), new MySqlParameter("@rotationX", saveData.Rotation.eulerAngles.x), new MySqlParameter("@rotationY", saveData.Rotation.eulerAngles.y), new MySqlParameter("@rotationZ", saveData.Rotation.eulerAngles.z), new MySqlParameter("@creatorId", saveData.CreatorId), new MySqlParameter("@creatorName", saveData.CreatorName)); connection.Close(); }
private IEnumerator SaveBuildingRoutine(IBuildingSaveData buildingSaveData) { if (buildingSaveData != null && !savingBuildings.Contains(buildingSaveData.Id)) { savingBuildings.Add(buildingSaveData.Id); UpdateBuildingJob job = new UpdateBuildingJob(Database, Assets.onlineScene.SceneName, buildingSaveData); job.Start(); yield return(StartCoroutine(job.WaitFor())); StorageId storageId = new StorageId(StorageType.Building, buildingSaveData.Id); if (storageItems.ContainsKey(storageId)) { UpdateStorageItemsJob updateStorageItemsJob = new UpdateStorageItemsJob(Database, storageId.storageType, storageId.storageOwnerId, storageItems[storageId]); updateStorageItemsJob.Start(); yield return(StartCoroutine(updateStorageItemsJob.WaitFor())); } savingBuildings.Remove(buildingSaveData.Id); if (LogInfo) { Debug.Log("Building [" + buildingSaveData.Id + "] Saved"); } } }
public override async UniTask CreateBuilding(string mapName, IBuildingSaveData saveData) { MySqlConnection connection = NewConnection(); await OpenConnection(connection); await ExecuteNonQuery(connection, null, "INSERT INTO buildings (id, parentId, entityId, currentHp, remainsLifeTime, mapName, positionX, positionY, positionZ, rotationX, rotationY, rotationZ, creatorId, creatorName) VALUES (@id, @parentId, @entityId, @currentHp, @remainsLifeTime, @mapName, @positionX, @positionY, @positionZ, @rotationX, @rotationY, @rotationZ, @creatorId, @creatorName)", new MySqlParameter("@id", saveData.Id), new MySqlParameter("@parentId", saveData.ParentId), new MySqlParameter("@entityId", saveData.EntityId), new MySqlParameter("@currentHp", saveData.CurrentHp), new MySqlParameter("@remainsLifeTime", saveData.RemainsLifeTime), new MySqlParameter("@mapName", mapName), new MySqlParameter("@positionX", saveData.Position.x), new MySqlParameter("@positionY", saveData.Position.y), new MySqlParameter("@positionZ", saveData.Position.z), new MySqlParameter("@rotationX", saveData.Rotation.eulerAngles.x), new MySqlParameter("@rotationY", saveData.Rotation.eulerAngles.y), new MySqlParameter("@rotationZ", saveData.Rotation.eulerAngles.z), new MySqlParameter("@creatorId", saveData.CreatorId), new MySqlParameter("@creatorName", saveData.CreatorName)); await connection.CloseAsync(); }
public UpdateBuildingJob(BaseDatabase database, string sceneName, IBuildingSaveData saveData, Action onFinished = null) : base(database, onFinished) { this.sceneName = sceneName; this.saveData = saveData; }
public abstract void UpdateBuilding(string mapName, IBuildingSaveData building);
public abstract void CreateBuilding(string mapName, IBuildingSaveData saveData);
public abstract UniTask UpdateBuilding(string mapName, IBuildingSaveData building);
public abstract UniTask CreateBuilding(string mapName, IBuildingSaveData saveData);